Show Posts
|
|
Pages: [1]
|
|
1
|
Java Game APIs & Engines / JOGL Development / Textures were not found when enabling webstart...
|
on: 2009-07-15 15:21:22
|
|
Hi there, i got an perfectly fine workling wee jogl prg, which loads some textures and comes up with an rotating planet with nice textures. So far so good. Compiling and running works fine, but when i enable webstart and try to start it, out of a sudden, my applet cannot find the texture files. Nothing in the code changed. What happend? My Code to load the texture is: texSphere = TextureIO.newTexture(new File("planetsurface.jpg"), true); Do i have to specify certain directories where to load my textures??
Any help would be appreciated! Thanks, normen
|
|
|
|
|
2
|
Java Game APIs & Engines / JOGL Development / Re: How to draw a 3D globe?
|
on: 2009-07-15 14:56:31
|
|
Hey, you also can put your LINE_LOOP in a DisplaylIst, then call it in a for next loop 360 times and rotate it around one axis, y-axis for example. Or just use the glut-method GlutWireSphere, glutSolidSphere?!?! Why not these? best regards, normen
|
|
|
|
|
4
|
Java Game APIs & Engines / JOGL Development / "Correct" texture mapping switches and filter for environment mapping
|
on: 2009-06-15 21:34:31
|
Hi there, Due to lack of of a proper code for a ksybox, i built myself a 'manual' skybox, by positioning 6 quads around a sphere. The code is working fine, no prob there, but i got some troubles with the 'right' texture mapping filters for my 'walls' For my center shining sphere i use: 1 2 3 4 5 6 7 8
| texSphere.setTexParameteri(GL.GL_TEXTURE_WRAP_S, GL.GL_REPEAT); texSphere.setTexParameteri(GL.GL_TEXTURE_WRAP_T, GL.GL_REPEAT); gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_REFLECTION_MAP); gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_REFLECTION_MAP); gl.glTexGeni(GL.GL_R, GL.GL_TEXTURE_GEN_MODE, GL.GL_REFLECTION_MAP); gl.glEnable(GL.GL_TEXTURE_GEN_S); gl.glEnable(GL.GL_TEXTURE_GEN_T); gl.glEnable(GL.GL_TEXTURE_GEN_R); |
For my walls i use the same... Now during the rotation of the sourounding cube, my 'wall' textures moving and bending around too. I mean that looks fancy, but i want to have static textures for the walls. Does any of you have an idea, how to use these texture filters properly to create an 'correct' environment mapping? Thanks, Regards, normen
|
|
|
|
|
5
|
Java Game APIs & Engines / JOGL Development / Re: Problems with Cylabs's GLSL Demo - running/Compile...
|
on: 2009-06-14 21:07:59
|
yeah sure.. try { // Load some texture Texture texture = TextureIO.newTexture(glsl1.class.getResource("moon.png"), false, "png"); // Store the OpenGL texture object ID for later use textureID = texture.getTextureObject(); } that moon.png can be read by anyone and is locateted in my root of my project folder with its subfolders: src, lib, librc and bin.. I also put the pic in the different sub folders too, just to check...then i got the error: URL was null. Quite funny and irritating;-) I'll get an white rectangle on black ground. Absolutly correct when there is no texture to load, but the file exists;-) Here your code: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268
| package glsl1;
import com.sun.opengl.util.Animator; import com.sun.opengl.util.texture.Texture; import com.sun.opengl.util.texture.TextureIO; import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.logging.Level; import java.util.logging.Logger; import javax.media.opengl.GL; import javax.media.opengl.GLAutoDrawable; import javax.media.opengl.GLCanvas; import javax.media.opengl.GLEventListener; import javax.media.opengl.glu.GLU; import static javax.media.opengl.GL.*;
public class glsl1 implements GLEventListener { private GLU glu = new GLU();
private int program; private int textureID;
public static void main(String[] args) { Frame frame = new Frame("Simple JOGL GLSL Application"); GLCanvas canvas = new GLCanvas();
canvas.addGLEventListener(new glsl1()); frame.add(canvas); frame.setSize(640, 480); final Animator animator = new Animator(canvas); frame.addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { new Thread(new Runnable() { public void run() { animator.stop(); System.exit(0); } }).start(); } }); frame.setLocationRelativeTo(null); frame.setVisible(true); animator.start(); }
public void init(GLAutoDrawable drawable) { GL gl = drawable.getGL();
String errors = null;
try { Texture texture = TextureIO.newTexture(glsl1.class.getResource("moon.png"), false, "png");
textureID = texture.getTextureObject(); } catch (Exception ex) { Logger.getLogger(glsl1.class.getName()).log(Level.SEVERE, null, ex); }
String[] shader = { "uniform sampler2D texUnit;\n" + "void main(void)\n" + "{\n" + " vec2 texCoord = gl_TexCoord[0].xy;\n" + " vec4 texel = texture2D(texUnit, texCoord);\n" + " gl_FragColor = texel * vec4(1.0, 0.0, 1.0, 1.0);\n" + "}\n" };
int[] lengths = { shader[0].length() };
program = gl.glCreateProgramObjectARB();
int frag = gl.glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB);
gl.glAttachObjectARB(program, frag);
gl.glShaderSourceARB(frag, shader.length, shader, lengths, 0);
gl.glCompileShaderARB(frag);
if ((errors = getGLErrorLog(gl, frag)) != null) throw new RuntimeException("Compile error\n" + errors);
gl.glLinkProgramARB(program);
if ((errors = getGLErrorLog(gl, program)) != null) throw new RuntimeException("Link error\n" + errors);
gl.glUseProgramObjectARB(program);
int texUnit = gl.glGetUniformLocationARB(program, "texUnit");
gl.glUniform1iARB(texUnit, 0);
gl.setSwapInterval(1);
gl.glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
}
public void display(GLAutoDrawable drawable) { GL gl = drawable.getGL();
gl.glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
gl.glLoadIdentity();
gl.glTranslatef(0.0f, 0.0f, -3.0f);
gl.glActiveTexture(GL_TEXTURE0);
gl.glBindTexture(GL_TEXTURE_2D, textureID);
gl.glUseProgramObjectARB(program);
gl.glBegin(GL_QUADS); { gl.glTexCoord2f(0, 0); gl.glVertex3f(-1, -1, 0); gl.glTexCoord2f(1, 0); gl.glVertex3f(1, -1, 0); gl.glTexCoord2f(1, 1); gl.glVertex3f(1, 1, 0); gl.glTexCoord2f(0, 1); gl.glVertex3f(-1, 1, 0); } gl.glEnd();
gl.glUseProgramObjectARB(0);
gl.glFlush(); }
public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) { GL gl = drawable.getGL();
if (height <= 0) { height = 1; } final float h = (float) width / (float) height; gl.glViewport(0, 0, width, height); gl.glMatrixMode(GL_PROJECTION); gl.glLoadIdentity(); glu.gluPerspective(45.0f, h, 1.0, 20.0); gl.glMatrixMode(GL_MODELVIEW); gl.glLoadIdentity(); }
public void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged) { }
private String getGLError(GL gl) { boolean hasError = false; String message = ""; for (int glErr = gl.glGetError(); glErr != GL.GL_NO_ERROR; glErr = gl.glGetError()) { message += (hasError ? "\n" : "") + glu.gluErrorString(glErr); hasError = true; } return hasError ? message : null; }
private String getGLErrorLog(GL gl, int obj) { boolean hasError = false; int[] infologLength = {0}; int[] charsWritten = {0}; byte[] infoLog;
String message = ""; String error = getGLError(gl); if (error != null) { message += error; hasError = true; }
gl.glGetObjectParameterivARB(obj, GL_OBJECT_INFO_LOG_LENGTH_ARB, infologLength, 0); error = getGLError(gl); if (error != null) { message += (hasError ? "\n" : "") + error; hasError = true; }
if (infologLength[0] > 1) { infoLog = new byte[infologLength[0]]; gl.glGetInfoLogARB(obj, infologLength[0], charsWritten, 0, infoLog, 0); message += (hasError ? "\n" : "") + "InfoLog:\n" + new String(infoLog); hasError = true; } error = getGLError(gl); if (error != null) { message += (hasError ? "\n" : "") + error; hasError = true; } return hasError ? message : null; } } |
|
|
|
|
|
6
|
Java Game APIs & Engines / JOGL Development / Problems with Cylabs's GLSL Demo - running/Compile...
|
on: 2009-06-13 17:39:33
|
Hi there, I've tried the sample code to test & experiment glsl functionality. Unfortunately, the code doesn't run or compile..What do i miss? 1 2 3 4 5 6
| SCHWERWIEGEND: null java.io.IOException: URL was null at com.sun.opengl.util.texture.TextureIO.newTextureDataImpl(TextureIO.java:818) at com.sun.opengl.util.texture.TextureIO.newTextureData(TextureIO.java:236) at com.sun.opengl.util.texture.TextureIO.newTexture(TextureIO.java:521) at glsl1.glsl1.init(glsl1.java:73) |
I assume, he cannot find the picture file i want to use for the texture. But its deffo there. Does anyone else have this problem? any hints od tips? I'm using Eclipse with OpenGL Plugin as well netbeans 6.5 with opengl pack, just to check, unfortunately both doesn't work. Thanks, el Normeo
|
|
|
|
|
7
|
Java Game APIs & Engines / JOGL Development / GLSL Basics II
|
on: 2009-06-11 11:49:06
|
|
Hi there, i got an theoretical question regarding jogl & glsl. I've read: If you use your own shader (vertex or fragment) the built in fixed pipeline functions are disabled, you you have to program your own translation, lightning, etc. Is it possible to 'simulate' the fixed structures by using already programmed 'Templates' and only add the one effect somebody might want? I'm not quite sure what exactly happen, maybe you can help me. Does actually the programmed shader code overwrite the fixed methods or does the shader code disable the entire vertex or fragment pipeline, so you have to do everything from the scratch again? My main purpose is to program Raleigh Scattering on a textured planet's surface. On the way to that point, i'll need some information gathering how exactly it work. Cylab was so kind ( i think, it was you;-) ) to program a function how to load a shader from file into oyur program and use it. Thats exactly the stuff, we n00bs need to get to a simple functional jogl code to experiment with shaders.
Thanks for any hints or ideas Best Regards, el Normeo
|
|
|
|
|
8
|
Java Game APIs & Engines / JOGL Development / Re: Help me: Textured earth globe using JOGL
|
on: 2009-06-11 11:05:21
|
Coool, how did yoo do that?;-) I used gluQuadrics to do that.... Generally its an advanced task, therefore, i'm not sure where on your opengl knowledge level you are: here, this is my code to do that, i'm pretty sure, there are more sophisticated possibilities to do that...Have fun to experiment.... You also can use the mouse to rotate the spere and use the mous buttons to move the lightsource (sun).. Please ignore too those outcommented code for shaders. etc. etc. Also please keep in mind to look for nice textures. I found them at: http://planetpixelemporium.com/planets.htmlAlso nasa.gov is a good site. Please find attached the jogl code in txt file Good luck, Elnormeo
|
|
|
|
|
9
|
Java Game APIs & Engines / JOGL Development / Visibale Spotlights using Fog
|
on: 2009-03-05 10:45:08
|
|
Hey there, i got an design question..
How do i get visible Spotlights in an dark room/enviroment.
Usually, when you are at a gig or show, you see actually the spotlight light with about 30cm length upon the spot itself coz of the smoke in the room.
I was tinking how could it be possible to simulate such an effect without using shaders or particles or other advanced tech. Maybe you can help me with this.
Lets say, we have an object and setup three lightsources as Spotlights in green, yellow and red. Could it be possible to archive this goal by using:
void light() Light-Setup void fog () Fog setup
void display do the render stuff, draw an object
call fog, call light swapBuffers
Could it work in that order or is that far more complicated than i thought? What do you think?
Best Regards, nomek
|
|
|
|
|
11
|
Java Game APIs & Engines / JOGL Development / Re: Multiple Lights not possible with JOGL????
|
on: 2009-03-02 08:38:35
|
|
Thanks for the link. But to be honest. I don't see any suspicious line, why LIGHT1-7 are treated otherwise than LIGHT0. What makes them so special??? I also could'nt find that information in the red book 6th edition. Yes, there is that example of LIGHT1 as an Spot, but i'm quite sure i did'nt saw any line like "LIGHT0 is only for the "main" light and use LIGHT1-7 ONLY as spots like that......." Maybe i'm to old or blind;-) but could someone push my nose upon that particular information?? Thanks again...
|
|
|
|
|
12
|
Java Game APIs & Engines / JOGL Development / Multiple Lights not possible with JOGL????
|
on: 2009-03-01 22:30:36
|
Hey Folx, I'm trying to program a little demo by using all 8 lightsources. But somehow i cannot turn on more than LIGHT0. I did several approaches to use additional Lights. But somehow non of Light1 - LIGHT7 seem to work. I did a simple test. a solid sphere from the glut packages with one default init of light like Ambient, Diffues, Position etc. It works. Its no rocket science. But somehow turning on more than one light is;-) Has someone also this odd behavior?  I just copied my Light init of Light0, moved the LIGHT1 Position abit to see the effect, but ANY LIGHT than LIGHT0 Won't work. I'm quite puzzled!!!! Is there an issue with JOGL regarding this??? Thanks for any help or hint Nomek
|
|
|
|
|
14
|
Java Game APIs & Engines / JOGL Development / How to rotate an object around 3 axis with the mouse?????
|
on: 2009-02-09 21:10:41
|
Hi there, i got a tricky one..... How do i rotate an object around its 3 axis WITH a mouse?;-) What i did is: I got a mouselistener running and convert the incoming integer values for x and y of the mouse into float values. Then i scaled that values down by multiplying them with 0.01 to get values i can use with glRotatef. (mrot+n are my float values , while mov+n are my integers i got from my mouse. mrotx = (movx * 0.01f); mroty = (movy * 0.01f); mrotz = (movx/2)+ (movy/2); Therefore a mouse got no 3rd axis, i helped myself by creating an float mrotz from the x and y values. I know, dirty. Then i rotate the whole scene by passing the values through: gl.glRotatef(mrotz, mrotx, 0f, 0f); gl.glRotatef(mrotz, 0f, mroty, 0f); gl.glRotatef(mrotx, 0f, 0f, mrotz); So, when i move the mouse, i got an rotation like an drunken elk. It actually rotates around 3 axis, but lously;-))  Does anyone of you got an code snippet for an cool and realistic rotation around the z Axis or how could i simulate this with my two x and y values from the mouse? I actually want to rotate an whole scen of an rotating planet with moving cloudsphere, incl. an sourounding moon. The scene itself runs smoothly by the way, no probs there. Thanks very much, elnormeo
|
|
|
|
|
15
|
Java Game APIs & Engines / JOGL Development / Re: How to load an external shader from disk to use it in JOGL?
|
on: 2009-01-24 23:20:20
|
|
heyho! The error is gone;-) I got an error message when i tried to create an instance of Shader by typing: "Shader shady = new Shader(); Therefore you said, thats not possible, coz i got the error message: cannot find symbol symbol: constructor Shader (); location: bla.blu.bla.Shader
So right now without this, my program, including your subclasses at least show no errors at all. I can run them with of course no effect at all;-) I just test this by let the prg loading some shaders which comes with the Shader Designer. What i'm trying to do is:
I wrote an little scene with a texture mapping planet, over it an rotating, blended cloud sphere, including an third little texture moon, which rotate around the planet. My FINAL Goal is: Rayleigh Scattering! So i want to setup an basic prg, where i'm able to experiment with the shaders to get that effect. There are tons of papers & stuff which explain how to program that fancy atmospheric look. Thats why i need to setup and load the functionality of shaders. Due to the Orange Book, it looked soo easy to setup the shaders;-) lol
Right now, when i move the code where the prg loads the shaderfiles into the Init method, nothing happens. When i put that snippet into my Display Method, the program hangs instantly and throws a 'NullPointerException'. Thanks anyway, i think, that Shader Issue is just to high for me right now. ;-)
|
|
|
|
|
16
|
Java Game APIs & Engines / JOGL Development / Re: How to load an external shader from disk to use it in JOGL?
|
on: 2009-01-24 21:44:07
|
Thanks very much!  Allthough by creating instances of Program & Shader in my GL Thread, i suppose you mean the init method or just below the class declaration by typing: Program prg = new program(); Shader shady = new Shader(); ?? Unfortunately, he don't like it to create an instance of Shader. It says 'cannot find symbol...' I use Netbeans 6.5 with OpenGL Pack. I just creates two subclasses and put your code into it. Subclass 'Program' looks good but not 'Shader'. Do you got any Idea? Thanks anyway;-)!!
|
|
|
|
|
17
|
Java Game APIs & Engines / JOGL Development / How to load an external shader from disk to use it in JOGL?
|
on: 2009-01-24 18:38:12
|
hello I'm looking for code how to load an external shader file from disk to use it in my JOGL program. There is a very good code i found, while searching for hours, but that one doesn't work. Here is the link: http://www.davidcornette.com/glsl/ & code: int v = gl.glCreateShader(GL.GL_VERTEX_SHADER); int f = gl.glCreateShader(GL.GL_FRAGMENT_SHADER); BufferedReader brv = new BufferedReader(new FileReader("./shader/vertex.shader")); String vsrc = ""; String line; while ((line=brv.readLine()) != null) { vsrc += line + "\n"; } gl.glShaderSource(v, 1, vsrc, (int[])null); gl.glCompileShader(v); BufferedReader brf = new BufferedReader(new FileReader("./shader/fragment.shader")); String fsrc = ""; while ((line=brf.readLine()) != null) { fsrc += line + "\n"; } gl.glShaderSource(f, 1, fsrc, (int[])null); gl.glCompileShader(f); int shaderprogram = gl.glCreateProgram(); gl.glAttachShader(shaderprogram, v); gl.glAttachShader(shaderprogram, f); gl.glLinkProgram(shaderprogram); gl.glValidateProgram(shaderprogram); gl.glUseProgram(shaderprogram); Unfortunately, this doesn't work, coz of some string vs. string array issue. Does anyone have a clue how to do that properly??!?!? Thanks very much,
|
|
|
|
|
19
|
Java Game APIs & Engines / JOGL Development / Unable to Build Projects with Netbeans 6.5 OpenGL Pack
|
on: 2009-01-04 17:16:06
|
Hi there, I'm new to Java and did OpenGL ages ago. So, i thought,better combine both together and found the OpenGL Pack for Netbeans. Netbeans + OpenGL Packs work fine, i can RUN my project without any troubles. But when it comes to 'building' them, i'll get stuck. when i click on 'Build main projet' i got the error message: D:\..\nbproject\build-jogl-template-impl.xml:74: The following error occurred while executing this line: Target "jnlp-init-generate-master" does not exist in the project xyz... I can't nowhere find this jnlp-init-generate-master.xml. It must have something to do with the configuration, i'll guess, coz running my projects works fine!!! There must be a way, please help!!!!  Thanks, normen
|
|
|
|
|
|
Add your game by posting it in the WIP section,
or publish it in Showcase.
The first screenshot will be displayed as a thumbnail.
|
|