Sign in to follow this  
CyanPrime

Nothing showing up on screen?

Recommended Posts

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.)

[code]
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
}
[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote name='karwosts' timestamp='1302714254' post='4798017']
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.
[/quote]

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this