Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.

Greg K

SwapBuffer trouble

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

In my program, swapbuffers() takes 100 milliseconds. I know that openGL queues up commands and does them all in one go but I am only rendering at most 140 quads per frame! And not only that but they are 2D quads! Does anyone have an explanation/tip on how to speed this up? -Greg Reverie Entertainment

Share this post

Link to post
Share on other sites
OpenGL doesn''t queue up commands. swapbuffers just waits till all the commands are complete. Post your code.

PS: What do you mean 2D quads?!

"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

Share this post

Link to post
Share on other sites
somebody told me anything about glFlush() or glFinish() and that they should be called before glSwapBuffers().

If it won''t help, try to check whether you really have TWO buffers, not one(can''t swap->copying->slow) or three (need special accelerated functions->copying->slow).

Share this post

Link to post
Share on other sites

static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be

sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor

1, // Version Number

PFD_DRAW_TO_WINDOW | // Format Must Support Window

PFD_SUPPORT_OPENGL | // Format Must Support OpenGL

PFD_DOUBLEBUFFER, // Must Support Double Buffering

PFD_TYPE_RGBA, // Request An RGBA Format

16, // Select Our Color Depth

0, 0, 0, 0, 0, 0, // Color Bits Ignored

0, // No Alpha Buffer

0, // Shift Bit Ignored

0, // No Accumulation Buffer

0, 0, 0, 0, // Accumulation Bits Ignored

16, // 16Bit Z-Buffer (Depth Buffer)

0, // No Stencil Buffer

0, // No Auxiliary Buffer

PFD_MAIN_PLANE, // Main Drawing Layer

0, // Reserved

0, 0, 0 // Layer Masks Ignored



glClearColor(0.0f, 0.0f, 0.0f, 1.0f);

glViewport(0, 0, width, height);
glOrtho(0, 800, 600, 0,-1.0f,1.0f);

glBindTexture(GL_TEXTURE_2D, nTexID);

glTexCoord2s( 0, 0 );glVertex2s(nX , nY );
glTexCoord2s( 1, 0 );glVertex2s(nX+nWidth, nY );
glTexCoord2s( 1, 1 );glVertex2s(nX+nWidth, nY-nHeight);
glTexCoord2s( 0, 1 );glVertex2s(nX , nY-nHeight);


Here are some code tidbits. Hope this helps...

[edited by - Greg K on August 12, 2003 9:25:04 AM]

Share this post

Link to post
Share on other sites
huh no idea...

ma brain almost dead now, but try not to send type _short_ arguments, opengl computes only with floats.

Yes, i understand. this hasn't any chance to survive...


AND TRY TO RUN WITH MORE COLORS, 16-bit is nearly palletized.
nothing? again?


have you sent your pfd to windows? i don't see that

[edited by - exa_einstein on August 12, 2003 9:35:43 AM]

Share this post

Link to post
Share on other sites
of course I sent it to windows. It wouldn't run otherwise would it? Those are just snippets. I don't see why I shouldn't use shorts, there is an ogl function that accepts them and maybe they can do some compression on them when sending them to vid hardware? Also, how would 32 bits speed anything up? I would think it would slow it down.

[edited by - Greg K on August 12, 2003 9:44:22 AM]

Share this post

Link to post
Share on other sites
glFlush(); //forces ogl computing
glFinish(); //waits for finishing ogl comkputing
try to check your videocard (if you are using some tweaker, check it too) and look for some threads/processes/viruses, they can slow it down. and then...RESET WINDO.S

...i hate smiles.
but my favourite smile is...

<:-=| SADDAM

Share this post

Link to post
Share on other sites
Check your profiler again (or do it from memory). Exactly WHAT is takin 100 milliseconds? Just the SwapBuffers() function or the entire renderloop?

My best guess anyway is that you are running in software mode. Query for GL_VENDOR. If it sais your driver, then something fishy is going on somewhere. If it says Windows, then you are in software mode and that''s why you are slow.

Sander Maréchal
[Lone Wolves Game Development][RoboBlast][Articles][GD Emporium][Webdesign][E-mail]

GSACP: GameDev Society Against Crap Posting
To join: Put these lines in your signature and don''t post crap!

Share this post

Link to post
Share on other sites

  • 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!