summaryrefslogtreecommitdiffstats
path: root/src/demos
diff options
context:
space:
mode:
Diffstat (limited to 'src/demos')
-rw-r--r--src/demos/dualDepthPeeling/Model.java15
-rwxr-xr-xsrc/demos/es2/perftst/PerfTextLoad.java16
2 files changed, 14 insertions, 17 deletions
diff --git a/src/demos/dualDepthPeeling/Model.java b/src/demos/dualDepthPeeling/Model.java
index d0dc8f3..c67c9b1 100644
--- a/src/demos/dualDepthPeeling/Model.java
+++ b/src/demos/dualDepthPeeling/Model.java
@@ -17,11 +17,10 @@ package demos.dualDepthPeeling;
import java.io.BufferedReader;
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
-import java.net.URL;
+import java.net.URLConnection;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.util.HashMap;
@@ -96,13 +95,13 @@ public class Model {
//
//////////////////////////////////////////////////////////////
public boolean loadModelFromFile( Class<?> context, String file ) {
- URL fileURL = IOUtil.getResource(context, file);
- if ( fileURL != null )
+ URLConnection conn = IOUtil.getResource(context, file);
+ if ( conn != null )
{
BufferedReader input = null;
try {
- input = new BufferedReader(new InputStreamReader(fileURL.openStream()));
+ input = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line = null;
float[] val = new float[4];
int[][] idx = new int[3][3];
@@ -215,11 +214,7 @@ public class Model {
} catch (NumberFormatException kIO) {
System.err.println("Problem reading the shader file " + file);
} finally {
- try {
- if (input != null) {
- input.close();
- }
- } catch (IOException closee) {}
+ IOUtil.close(input, false);
}
}
return false;
diff --git a/src/demos/es2/perftst/PerfTextLoad.java b/src/demos/es2/perftst/PerfTextLoad.java
index f603796..543ce93 100755
--- a/src/demos/es2/perftst/PerfTextLoad.java
+++ b/src/demos/es2/perftst/PerfTextLoad.java
@@ -9,9 +9,6 @@ import javax.media.opengl.*;
import com.jogamp.opengl.util.*;
import com.jogamp.opengl.util.texture.*;
-import com.jogamp.newt.*;
-import com.jogamp.newt.opengl.*;
-
public class PerfTextLoad extends PerfModule {
static final int MAX_TEXTURE_ENGINES = 8;
@@ -38,12 +35,17 @@ public class PerfTextLoad extends PerfModule {
try {
for(int i=0; i<numObjs; i++) {
textName = "data/"+textBaseName+"."+(i+1)+".tga";
- URL urlText = IOUtil.getResource(Perftst.class, textName);
- if(urlText==null) {
+ URLConnection connText = IOUtil.getResource(Perftst.class, textName);
+ if(connText==null) {
throw new RuntimeException("couldn't fetch "+textName);
}
- textDatas[i] = TextureIO.newTextureData(gl.getGLProfile(), urlText.openStream(), false, TextureIO.TGA);
- System.out.println(textBaseName+": "+textDatas[i]);
+ final InputStream in = connText.getInputStream();
+ try {
+ textDatas[i] = TextureIO.newTextureData(gl.getGLProfile(), in, false, TextureIO.TGA);
+ System.out.println(textBaseName+": "+textDatas[i]);
+ } finally {
+ IOUtil.close(in, false);
+ }
}
for(int i=0; i<numTextures; i++) {