Jump to content
  • Advertisement
Sign in to follow this  
boing

OpenGL Super fast animation

This topic is 4146 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 need to display a series of 2d images, with a fast frame-rate. I have the data in a set of BMP images and have managed to load them all in memory and used glDrawPixels for displaying them with opengl, on windows. But this is giving a frame rate of only 4.5 frames per second on my 2.6 ghz single core intel with 2GB ram (without a 3d card). Images are around 1000x700 pixels in size. This is for a scientific simulation and I need around 50 frames per second. #. Is 4.5 fps using glDrawPixels expected? Or am I doing something wrong? #. How can I get around 50 fps? Is this even possible?

Share this post


Link to post
Share on other sites
Advertisement
DrawPixels is slow, but it shouldn't be that slow. You have some problems in your code.

Typically you would store that sort of thing in a texture then render a simple textured quad.

Also, be sure you work with power-of-two numbers. In your case that would probably be 1024 square, with an unused portion of the texture for your UV coordinates.

Textured quads will give you the fastest performance. In optimal situations you should be able to do millions or billions of those per second, depending on the video card, drivers, and settings. With no 3D acceleration you should still be able to handle tens or hundreds of thousands of those per second.

Share this post


Link to post
Share on other sites
glDrawPixels is generally not a fast way to draw things. Typically you want to load your image data into textures, then setup and ortho projection (glOrtho) and draw them as simple textured quads.

Bare in mind that unless you use extensions, textures have to be power-of-two in size (eg. 128x256, 512x1024), which might mean adding some padding onto your images and wasting some memory. 1000x700 is pretty big if you've got lots of images, you might also want to look into DXT (directX texture compression) to save some memory (and probably get better performance) at the cost of some image quality.

Share this post


Link to post
Share on other sites
OK, now I am getting around 80 FPS, thanks :-)

But there is a very visible and very annoying flicker. I tried playing with vsync setting in control panel and I am using SwapBuffers to update display so am assuming that double buffering must be enabled. But the flicker doesn't goes away.

How do I fix this for OpenGL? How do I check if double-buffering is enabled and is getting used? How do I enable/check vsync from within my program? Could the flicker be due to reasons other than vsync?

I found this code, but it doesn't works
http://www.gamedev.net/community/forums/topic.asp?topic_id=317721

Share this post


Link to post
Share on other sites
You're seeing a flicker at 80 FPS? Does it have a 50:50 duty cycle? It sounds like double buffer is off. Try:


...
PIXELFORMATDESCRIPTOR pfd = {0};
...
memset(&pfd, 0, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER; // <--------------
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cDepthBits = 32;
pfd.cColorBits = 32;
pfd.cStencilBits = 8;

pf = ChoosePixelFormat(hdc, &pfd);
SetPixelFormat(hdc, pf, &pfd);




Hope it helps...

Share this post


Link to post
Share on other sites
Thanks, I checked for PFD_DOUBLEBUFFER, its already there in my code.

I figured that flicker is because I was doing it in window, and that page-flipping works only fullscreen mode.

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!