Sign in to follow this  

Beginner question about OpenGL problem

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

I 'm sure this had been asked somewhere before, but I used the search, and was unable to find anyone with the same problem as me. Heres what I want to do: Create a 3d application that doesn't clear any buffers after each loop. glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); ^-- Thats what I want to leave out. When I leave this out on the computers at my school, or on any other computer at my house, it does what I want it to do. Which is leave previously drawn pixels on the screen. On my computer, when I run the program, all of the static/lines/error-looking-stuff is in the window, flashing like crazy. I'm guessing its a problem with my graphics card or something, but I'm not sure. I have an Intel 82915G/GV/910GL Express Chipset Family Graphics card (I don't know if this information is helpful, but just in case...) On previous occasions, I just started out every OpenGL application with a black rotating quad that cleared whatever data seemed to be stuck where it didn't belong. But now I am running into situations where this won't be practical. I am using Dev-C++, and this problem occurs in the OpenGL template included with Dev-C++, and with the NeHe template I downloaded through the DevPacks sever. How do I fix this problem? (If necessary, I can post my source, although it's not much different than the templates.)

Share this post


Link to post
Share on other sites
It's flashing like crazy because of double-buffering; one of the buffers is cleared, and the other one is filled with cruft. Disable double buffering, and all should be peachy.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
It's flashing like crazy because of double-buffering; one of the buffers is cleared, and the other one is filled with cruft. Disable double buffering, and all should be peachy.


How exactly would I do that? I'm still new to this.

EDIT: Should I have put this in the OpenGL section? I just noticed there was one.

Share this post


Link to post
Share on other sites
Double buffering is handled by Win32, SDL, GLut, or whatever else you are using to make the window. Tell us what you're using and we'll be able to help more.

Oh, and for a beginner question about OpenGL, both the OpenGL and For Beginners forumsare fine. Just flip a coin!

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezbez
Double buffering is handled by Win32, SDL, GLut, or whatever else you are using to make the window. Tell us what you're using and we'll be able to help more.

Oh, and for a beginner question about OpenGL, both the OpenGL and For Beginners forumsare fine. Just flip a coin!


Thanks.

----------

void EnableOpenGL (HWND hWnd, HDC *hDC, HGLRC *hRC)
{
PIXELFORMATDESCRIPTOR pfd;
int iFormat;

/* get the device context (DC) */
*hDC = GetDC (hWnd);

/* set the pixel format for the DC */
ZeroMemory (&pfd, sizeof (pfd));
pfd.nSize = sizeof (pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW |
PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; //-- Should I change this?
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cColorBits = 67;
pfd.cDepthBits = 16;
pfd.iLayerType = PFD_MAIN_PLANE;
iFormat = ChoosePixelFormat (*hDC, &pfd);
SetPixelFormat (*hDC, iFormat, &pfd);

/* create and enable the render context (RC) */
*hRC = wglCreateContext( *hDC );
wglMakeCurrent( *hDC, *hRC );

}

----------

I think this is being handled by win32, but I'm not sure.

Share this post


Link to post
Share on other sites
If you're using the NeHe template, in the main loop there should be a call to SwapBuffers, just comment out that line and it should work. (Because it never swaps to 2nd buffer)

Share this post


Link to post
Share on other sites
Quote:
Original post by Ganoosh_
If you're using the NeHe template, in the main loop there should be a call to SwapBuffers, just comment out that line and it should work. (Because it never swaps to 2nd buffer)


The only place I was able to find SwapBuffers was in NeHeGL.cpp, so I commented it out, and commented out glClear. Now all I get is a gray window.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ezbez
I don't use NeHe base code, but doesn't the SwapBuffers() call also update the screen? Thats what most APIs do.


Well, I Tried commenting out the SwapBuffers() in the Dev-C++ OpenGL template, and the screen was blank, and nothing happened.

Share this post


Link to post
Share on other sites
You have to leave the initial glClear in. Also, if you aren't calling SwapBuffers, you may need to call glFinish after each frame. Also, of course, you need to remove the PFD_DOUBLEBUFFER attribute.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
You have to leave the initial glClear in. Also, if you aren't calling SwapBuffers, you may need to call glFinish after each frame. Also, of course, you need to remove the PFD_DOUBLEBUFFER attribute.


Thanks. I think I can get it working from here.

Edit: Yep. It's working now. Thanks again.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
You have to leave the initial glClear in. Also, if you aren't calling SwapBuffers, you may need to call glFinish after each frame. Also, of course, you need to remove the PFD_DOUBLEBUFFER attribute.


It was the DOUBLEBUFFER attribute. If you leave it in, since drawing goes to the back buffer, you never see it if you don't swap buffers.

Share this post


Link to post
Share on other sites

This topic is 4298 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.

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