Jump to content
  • Advertisement
Sign in to follow this  

OpenGL [EASY Q?] Screen not clearing on new frame

This topic is 2802 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

Somewhat new to opengl - just removed my dependency on glut and reworking a project at the same time.

I was/am using glDrawPixel on an array of pixels to draw to the screen.

defined like this:

struct RGBAType {
GLfloat r;
GLfloat g;
GLfloat b;
GLfloat a;
RGBAType() : a(1),r(0),g(0),b(0){}

(I included that to make sure I am using the right datatypes...I've read that the conversions of type may affect speed drastically)

I am initializing opengl as so:

//setup opengl
glShadeModel(GL_FLAT); // Enable Smooth Shading
glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glDisable(GL_DEPTH_TEST); // Disables Depth Testing


and every frame I draw with the follow:

void ce_MainRenderer::renderToScreen ( void ) // Create The Display Function
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glMatrixMode (GL_PROJECTION);
glOrtho (0, s_screenWidth, s_screenHeight, 0, 0, 1);

glRasterPos2f(0,s_screenHeight);//I just looked at this - I think this is setup wrong...
glDrawPixels(s_screenWidth,s_screenHeight,GL_RGBA,GL_FLOAT, pixelsToDraw);

When I first wrote this function I was redrawing every pixel every frame, now I am working on a graphing application and only redraw a very small ...... I just figured out what the problem was. My data structure does'nt get cleared out on every frame so the state of things simply carries over on the next frame...

I'm posting this anyways, f it - let me know if there is anything I am doing that is unnecessary ... plan to switch over to Pixel Buffer Objects soon

Share this post

Link to post
Share on other sites
Very minor, but this:

glClearColor(1.0f, 1.0f, 1.0f, 1.0f); // Black Background

is a white background, not a black one. Black is (0,0,0).

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!