Show Posts
|
|
Pages: [1]
|
|
4
|
Java Game APIs & Engines / JOGL Development / Will no one use fixed functions in the future?
|
on: 2010-02-09 08:45:24
|
Hi. I heard that whole fixed function pipe line is removed since OpenGL3.1 I have a few questions about that news.  Does this mean that most people don't use the fixed functions but instead they prefer the shading? Or both of OpenGL 3.x and OpenGL 2.x will be steadily maintained for being used in the different domain?  If the graphics driver supports ≥ Opengl 3.1, programs written in fixed functions can't be executed? Thank you. Junyeong
|
|
|
|
|
6
|
Java Game APIs & Engines / JOGL Development / Re: light opposite side
|
on: 2010-02-02 06:06:03
|
I think that the problem might come from the method which I use for drawing a sphere. Because "glutSolidSphere()" works fine with the light but "drawSphere()" does not... Would you try this code and let me know what the problem is? The method "drawSphere()" draws a sphere of which radius is 1 and centered at the origin. And you can change the number of subdivision to alter the variable "depth". Thank you.  The code for drawing sphere is as follows. 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
| private final float sVdata[][] = { {1.0f, 0.0f, 0.0f} , {0.0f, 1.0f, 0.0f} , {0.0f, 0.0f, 1.0f} , {-1.0f, 0.0f, 0.0f} , {0.0f, -1.0f, 0.0f} , {0.0f, 0.0f, -1.0f} }; private int depth = 4;
public void drawSphere() { subdivideSphere(sVdata[0], sVdata[1], sVdata[2], depth); subdivideSphere(sVdata[0], sVdata[2], sVdata[4], depth); subdivideSphere(sVdata[0], sVdata[4], sVdata[5], depth); subdivideSphere(sVdata[0], sVdata[5], sVdata[1], depth);
subdivideSphere(sVdata[3], sVdata[1], sVdata[5], depth); subdivideSphere(sVdata[3], sVdata[5], sVdata[4], depth); subdivideSphere(sVdata[3], sVdata[4], sVdata[2], depth); subdivideSphere(sVdata[3], sVdata[2], sVdata[1], depth); }
private void subdivideSphere(float v1[], float v2[], float v3[], long depth) { float v12[] = new float[3]; float v23[] = new float[3]; float v31[] = new float[3]; int i;
if (depth==0) { gl.glColor3f(v1[0]*v1[0], v2[1]*v2[1], v3[2]*v3[2]); drawtriangle(v1, v2, v3); return; } for (i = 0; i<3; i++) { v12[i] = v1[i]+v2[i]; v23[i] = v2[i]+v3[i]; v31[i] = v3[i]+v1[i]; } normalize(v12); normalize(v23); normalize(v31); subdivideSphere(v1, v12, v31, depth-1); subdivideSphere(v2, v23, v12, depth-1); subdivideSphere(v3, v31, v23, depth-1); subdivideSphere(v12, v23, v31, depth-1); }
public void normalize(float vector[]) { float d = (float) Math.sqrt(vector[0] * vector[0] + vector[1] * vector[1] + vector[2] * vector[2]);
if (d == 0) { System.out.println("0 length vector: normalize()."); return; } vector[0] /= d; vector[1] /= d; vector[2] /= d; }
public void drawtriangle(float[] v1, float[] v2, float[] v3) { gl.glBegin(GL2.GL_TRIANGLES); gl.glVertex3fv(v1, 0); gl.glVertex3fv(v2, 0); gl.glVertex3fv(v3, 0); gl.glEnd(); }
|
|
|
|
|
|
7
|
Java Game APIs & Engines / JOGL Development / Re: light opposite side
|
on: 2010-02-01 17:06:10
|
Thank you for your response  I tried your suggestion that applying glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE); I notice that the SPECULAR and DIFFUSE light doesn't apply to back face. Only AMBIENT does. For example, I tried this for another source code. I set the same material properties to FRONT_AND_BACK face. I expected that the both faces turns white. As expected, the front face turns white. However the back face turns pure red.  Why the back face uses the AMBIENT property only? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| gl.glLightModeli(GL2.GL_LIGHT_MODEL_TWO_SIDE,GL2.GL_TRUE); gl.glLightModeli(GL2.GL_LIGHT_MODEL_LOCAL_VIEWER, GL2.GL_TRUE); gl.glLightModelfv(GL2.GL_LIGHT_MODEL_AMBIENT, new float[] {0,0,0,0}, 0); gl.glLightModeli(GL2.GL_LIGHT_MODEL_COLOR_CONTROL, GL2.GL_SEPARATE_SPECULAR_COLOR);
gl.glEnable(GL2.GL_LIGHT1); gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_POSITION, new float[] {0,0,1,0}, 0); gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_AMBIENT, new float[] {1.0f,1.0f,1.0f,1.0f}, 0); gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_DIFFUSE, new float[] {1.0f,1.0f,1.0f,1}, 0); gl.glLightfv(GL2.GL_LIGHT1, GL2.GL_SPECULAR, new float[] {1,1,1,1}, 0);
gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_EMISSION, new float[] {0,0,0,0}, 0); gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_AMBIENT, new float[] {1,0,0,0}, 0); gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_DIFFUSE, new float[] {1,1,1,1}, 0); gl.glMaterialfv(GL2.GL_FRONT_AND_BACK, GL2.GL_SPECULAR, new float[] {1,1,1,1}, 0); gl.glMaterialf(GL2.GL_FRONT_AND_BACK, GL2.GL_SHININESS, 25.0f); |
|
|
|
|
|
8
|
Java Game APIs & Engines / JOGL Development / light opposite side
|
on: 2010-01-31 16:04:04
|
Hi, JOGL users. I write a jogl program which draws 2 spheres, a big and a small one. Assume that the bigger sphere is the Earth and the smaller one revolves around the Earth. The smaller sphere is drawn at the very location where a local-light-source places. But I have a problem. Not only the side which faces the light-source but also the opposite side which doesn't face the light source are lit up. Why the both side lit up? And how not to light the oppsosite side of the sphere? I feel that my explanation is poor  I hope that the attached picture helps you recognize my problem. Thanks.
|
|
|
|
|
11
|
Java Game APIs & Engines / JOGL Development / How to figure out which surface I'm clicking?
|
on: 2010-01-20 03:24:11
|
Hi, JOGL & OpenGL users. Assume that there's a cube and each of the faces has a number like a dice. The cube rotates around arbitrary axis and degree. So far, it's fine. But I don't know what to do next step. The next step is implementing this: when a user clicks a face of the cube, the application recognizes what face is clicked and notifies a user what number is choosed. Any advice is welcomed.  Thank you. sincerely, Junyeong
|
|
|
|
|