Jogl

What has JOGL got that LWJGL doesn’t?

Nothing except Nurbs support…



Chman

"Chman" wrote:
Nothing except Nurbs support...

Chman

So why add JOGL support?

Nurbs aren't used in games unless they are done beforehand like in Quake 3.

Dunno… Some people prefer JoGL over LWJGL, I can’t explain it… Maybe it’s because JoGL is considered as the “official” java opengl binding…



Chman

There are several reasons why we would want jogl. One of the biggest reason I can think of is that if lwjg or jogl die jme dose not have to. I think that jogl also supports more platforms then lwjgl.



Status update:



I got versions of almost all render states to compile. I have some problems with NPE that I hope will be easily solved. If any one wants to help I can use some so tell me.

One of the biggest reason I can think of is that if lwjg or jogl die jme dose not have to.

Good reason :)

I think that jogl also supports more platforms then lwjgl.

LWJGL support MacOSX, Linux and windows... What's more for jogl ?

Chman

JOGL suports Solaris :smiley:



If any one wants to work on jinput supports I would appreciate it.



Also I do not have a JOGL version of the shatter states, If want to make one tell me.

One thing I want to mention Badmi, especially after readin these posts you’ve made. (Please note this is in no way meant to be insulting). You need to be extra careful about your spelling (as there is going to be a lot of code for this, i.e. it’s not simply a single class). Not only the misspellings of words but the meaning of them as well, for example:



shatter = to break (like glass) when you mean shader.

dose = a measurement (doctor prescription) when you mean does.



These are things that the spell checker won’t catch because they are correctly spelled words, just not the ones you want to use.



I just mention this because of the large amount of code that the JOGL implementation will entail.

I know what you mean, spelling is not one of my speculates as I bet you can tell from my posts. I will keep a list of all the variables I make and have someone look over the spelling before I post it.

Can any one(Chman) see any thing wrong with this code? Nothing id drawn on the screen.






public void draw(TriMesh t) {
            System.out.println(gl.glGetError());
      predrawMesh(t);

      IntBuffer indices = t.getIndexAsBuffer();
      if (statisticsOn) {
         numberOfTris += (t.getTriangleQuantity() >= 0 ? t
               .getTriangleQuantity() : t.getIndices().length / 3);
         numberOfVerts += (t.getVertQuantity() >= 0 ? t.getVertQuantity()
               : t.getVertices().length);
      }

      if (OpenGL12)
         gl.glDrawRangeElements(gl.GL_TRIANGLES, 0, t.getVertQuantity(),indices.remaining(),gl.GL_UNSIGNED_BYTE, indices);
      else
         gl.glDrawElements(gl.GL_TRIANGLES, indices.remaining(), gl.GL_UNSIGNED_BYTE, indices);

      postdrawMesh();
                 System.out.println(gl.glGetError());
   }


   private void predrawMesh(TriMesh t) {
      // set world matrix
      Quaternion rotation = t.getWorldRotation();
      Vector3f translation = t.getWorldTranslation();
      Vector3f scale = t.getWorldScale();
      float rot = rotation.toAngleAxis(vRot);
      gl.glMatrixMode(gl.GL_MODELVIEW);
      gl.glPushMatrix();

      gl.glTranslatef(translation.x, translation.y, translation.z);
      gl.glRotatef(rot, vRot.x, vRot.y, vRot.z);
      gl.glScalef(scale.x, scale.y, scale.z);
      if (!(scale.x == 1 && scale.y == 1 && scale.z == 1))
         gl.glEnable(gl.GL_NORMALIZE); // since we are using
      // glScalef, we should enable
      // this to keep normals
      // working.

      prepVBO(t);

      // render the object

      FloatBuffer verticies = t.getVerticeAsFloatBuffer();
      if (prevVerts != verticies) {
         gl.glEnableClientState(gl.GL_VERTEX_ARRAY);
         if (t.isVBOVertexEnabled() && OpenGL15) {
            usingVBO = true;
            gl.glBindBuffer(gl.GL_ARRAY_BUFFER, t.getVBOVertexID());
            gl.glVertexPointer(3, gl.GL_FLOAT, 0, null);
         } else {
            if (usingVBO)
               gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0);
            gl.glVertexPointer(3, gl.GL_FLOAT, 0,  t.getVerticeAsFloatBuffer());
         }
      }
      prevVerts = verticies;

      FloatBuffer normals = t.getNormalAsFloatBuffer();
      if (prevNorms != normals) {
         if (normals != null || t.getVBONormalID() > 0) {
            gl.glEnableClientState(gl.GL_NORMAL_ARRAY);
            if (t.isVBONormalEnabled() && OpenGL15) {
               usingVBO = true;
               gl.glBindBuffer(gl.GL_ARRAY_BUFFER, t.getVBONormalID());
               gl.glNormalPointer(gl.GL_FLOAT, 0, null);
            } else {
               if (usingVBO)
                  gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0);
               gl.glNormalPointer(gl.GL_FLOAT,0, normals);
            }
         } else {
            gl.glDisableClientState(gl.GL_NORMAL_ARRAY);
         }
      }
      prevNorms = normals;

      FloatBuffer colors = t.getColorAsFloatBuffer();
      if (colors == null || prevColor != colors) {
         if (colors != null || t.getVBOColorID() > 0) {
            gl.glEnableClientState(gl.GL_COLOR_ARRAY);
            if (t.isVBOColorEnabled() && OpenGL15) {
               usingVBO = true;
               gl.glBindBuffer(gl.GL_ARRAY_BUFFER, t.getVBOColorID());
               gl.glColorPointer(4, gl.GL_FLOAT, 0, null);
            } else {
               if (usingVBO)
                  gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0);
               gl.glColorPointer(4,gl.GL_FLOAT,  0, colors);
            }
            prevColor = colors;
         } else {
            gl.glDisableClientState(gl.GL_COLOR_ARRAY);
         }
      }

      for (int i = 0; i < t.getNumberOfUnits(); i++) {
         FloatBuffer textures = t.getTextureAsFloatBuffer(i);
         if (prevTex[i] != textures && textures != null) {
            if (GL_ARB_multitexture && OpenGL13) {
               gl.glClientActiveTexture(gl.GL_TEXTURE0 + i);
            }
            if (textures != null || t.getVBOTextureID(i) > 0) {

               gl.glEnableClientState(gl.GL_TEXTURE_COORD_ARRAY);
               if (t.isVBOTextureEnabled() && OpenGL15) {
                  usingVBO = true;
                  gl.glBindBuffer(gl.GL_ARRAY_BUFFER, t
                        .getVBOTextureID(i));
                  gl.glTexCoordPointer(2, gl.GL_FLOAT, 0, null);
               } else {
                  if (usingVBO)
                     gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0);
                  gl.glTexCoordPointer(2,gl.GL_FLOAT,  0, textures);
               }
            } else {
               gl.glDisableClientState(gl.GL_TEXTURE_COORD_ARRAY);
            }
         }
         prevTex[i] = textures;
      }

   private void postdrawMesh() {
      gl.glMatrixMode(gl.GL_MODELVIEW);
      gl.glPopMatrix();
   }

public void prepVBO(Geometry g) {
      if (!OpenGL15)
         return;
      int verts = g.getVertQuantity();
      if (verts < 0)
         verts = g.getVertices().length;
      if (g.isVBOVertexEnabled() && g.getVBOVertexID() <= 0) {
         gl.glGenBuffers(buf.remaining(),buf);
         g.setVBOVertexID(buf.get(0));
         gl.glBindBuffer(gl.GL_ARRAY_BUFFER, g.getVBOVertexID());
         gl.glBufferData(gl.GL_ARRAY_BUFFER, verts * 3 * 4, g
               .getVerticeAsFloatBuffer(), gl.GL_STATIC_DRAW);
         buf.clear();
      }
      if (g.isVBONormalEnabled() && g.getVBONormalID() <= 0) {
         gl.glGenBuffers(buf.remaining(),buf);
         g.setVBONormalID(buf.get(0));
         gl.glBindBuffer(gl.GL_ARRAY_BUFFER, g.getVBONormalID());
         gl.glBufferData(gl.GL_ARRAY_BUFFER, verts * 3 * 4, g
               .getNormalAsFloatBuffer(), gl.GL_STATIC_DRAW);
         buf.clear();
      }
      if (g.isVBOColorEnabled() && g.getVBOColorID() <= 0) {
         gl.glGenBuffers(buf.remaining(),buf);
         g.setVBOColorID(buf.get(0));
         gl.glBindBuffer(gl.GL_ARRAY_BUFFER, g.getVBOColorID());
         gl.glBufferData(gl.GL_ARRAY_BUFFER, verts * 4 * 4, g
               .getColorAsFloatBuffer(), gl.GL_STATIC_DRAW);
         buf.clear();
      }
      if (g.isVBOTextureEnabled()) {
         for (int i = 0; i < g.getNumberOfUnits(); i++) {

            if (g.getVBOTextureID(i) <= 0
                  && g.getTextureAsFloatBuffer(i) != null) {
               gl.glGenBuffers(buf.remaining(),buf);
               g.setVBOTextureID(i, buf.get(0));
               gl.glBindBuffer(gl.GL_ARRAY_BUFFER, g
                     .getVBOTextureID(i));
               gl.glBufferData(gl.GL_ARRAY_BUFFER, verts * 2 * 4, g
                     .getTextureAsFloatBuffer(i), gl.GL_STATIC_DRAW);
               buf.clear();
            }
         }
      }
      buf.clear();
      gl.glBindBuffer(gl.GL_ARRAY_BUFFER, 0);
   }


My computer suports GL 1.3 the booleans are set up properly.

Hmm that’s a lot of code… Have you made a plain LWJGL to JoGL convert ?



Chman

I copy/pased the code from lwjgl then modified it so it would compile with jogl. When there was a discrepancy with the functions I looked at the lwjgl source to see how they called the naïve functions wich are much more similar to the jogl functions.

I am going to work on input until someone can fined the problem with the code. If no one can then I will be forced to use the old fashion method for the initial release. I can not fined anything wrong with it, prably because I do not know OpenGL well. So please take the time to look at the code, if you do not want the old fashion method.

The GL part seems to be good, it may be a JoGL issue. Some of my “brut convert from lwjgl to jogl” don’t work too… I’ve used JoGL but I’m not an expert, I suspect the VBO part to be broken… A little demo for VBOs I’ve wrote in the past with LWJGL doesn’t run with JoGL.

The JoGL forum should be helpful.



Chman

I found the problem. For some reason the vertex array was of type GL_UNSIGNED_INT not GL_UNSIGNED_BYTE like lwjgl uses. (!)



I got full screen working today and finished rendering text but it is untested.



I can’t figure out on how to read from the screen or get screen coordinates. The JOGL reindeer needs all calls to gl to be in render. I think I will leave it unwritten in the initial release along with render to texture and Vertex and Fragment programs.

I am trying to jinput working with jme. jinput dose not appear to be an active project. Is there any other system I can use? I can’t seem to get the keyboard input working.

I got part of the input working with jinput but still can not figure out how to make the hide the mouse curser disappear. Dose any one know how?





I am also having problems keeping up with the cvs. When I finally release the code it probably will be out of date. :frowning:

I don’t know if you can hide the mouse cursor with jinput.



About the cvs version, I can send you a complete snapshot of the last release if you want.



Chman

The problem is not updating from the cvs, the problem is merging the two bits if code. I probably will finish the code and merge them right before it is put into the cvs.

Chman, dose jogl support Headless rendering? How do you access it?



Dose it pay to add Headless rendering to my renderer? The rendering would be much faster if we removed Headless rendering form jme and replaced it with component rendering. Basically there would be a method



Component createComponentDisplaySystem(int width,int height);



witch would just return a Gl canvass in jogl. In lwjgl it would return the system we are certainly using. This would be much faster using jogl and have no speed decrees in lwjgl.