Jump to content
  • Advertisement
Sign in to follow this  
CyanPrime

Nothing showing up on screen?

This topic is 2686 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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


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
}

Share this post


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

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.


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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!