Nothing showing up on screen?

Started by
1 comment, last by CyanPrime 13 years ago
Alright, so I'm converting my engine to Java using LWJGL, and when I draw stuff it doesn't show up on screen. I'm doing the same thing I did in c++, but maybe I got something wrong? (Note, you should be able to read this and answer if you know c++, as it's the same thing with GL11. in frount of everything.)


private void initGL(int Width, int Height) {
GL11.glViewport(0, 0, Width, Height);
GL11.glClearColor(0.0f, 0.0f, 0.0f, 0.0f); // This Will Clear The Background Color To Black
GL11.glClearDepth(1.0); // Enables Clearing Of The Depth Buffer
GL11.glDepthFunc(GL11.GL_LESS); // The Type Of Depth Test To Do
GL11.glDisable(GL11.GL_DEPTH_TEST); // Enables Depth Testing
//glShadeModel(GL_SMOOTH); // Enables Smooth Color Shading
GL11.glEnable(GL11.GL_TEXTURE_2D); // Enable Texture Mapping ( NEW )
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glMatrixMode(GL11.GL_PROJECTION);
GL11.glEnable(GL11.GL_BLEND);
GL11.glBlendFunc(GL11.GL_SRC_ALPHA , GL11.GL_ONE_MINUS_SRC_ALPHA);
GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
GL11.glAlphaFunc(GL11.GL_GREATER, 0.5f);


GL11.glMatrixMode(GL11.GL_PROJECTION);//configuring projection matrix now
GL11.glLoadIdentity();//reset matrix
GL11.glOrtho(0, 640, 0, 480, 0.0f, 100.0f);//set a 2d projection matrix
}

private void render() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // Clear The Screen And The Depth Buffer
GL11.glLoadIdentity(); // Reset The Current Modelview Matrix

GL11.glMatrixMode(GL11.GL_MODELVIEW);//configuring modelview matrix now
GL11.glLoadIdentity();//reset matrix

GL11.glBegin(GL11.GL_QUADS); // Draw A Quad
GL11.glVertex3f(0, 50, 0); // Top Left
GL11.glVertex3f(50,50, 0); // Top Right
GL11.glVertex3f(50,100,0); // Bottom Right
GL11.glVertex3f(0,100, 0); // Bottom Left
GL11.glEnd(); // Done Drawing The Quad
}
Advertisement
Couple thoughts:

1) You call LoadIdentity in the beginning of render on an unspecified matrix stack. Does this clear the projection matrix on the first pass, as that stack is still bound when you exit the setup function?

2) What color is your quad supposed to be? Why is texturing enabled?

3) Your quad is lying on the near plane, not sure how the clipping calculations work exactly but I'm not positive if things exactly on the near plane get clipped or not.
[size=2]My Projects:
[size=2]Portfolio Map for Android - Free Visual Portfolio Tracker
[size=2]Electron Flux for Android - Free Puzzle/Logic Game

Couple thoughts:

1) You call LoadIdentity in the beginning of render on an unspecified matrix stack. Does this clear the projection matrix on the first pass, as that stack is still bound when you exit the setup function?

2) What color is your quad supposed to be? Why is texturing enabled?

3) Your quad is lying on the near plane, not sure how the clipping calculations work exactly but I'm not positive if things exactly on the near plane get clipped or not.


yup, it was 1, the LoadIdentity. Thank you very much ^_^

This topic is closed to new replies.

Advertisement