Hi
I’m using OpenGL in my program, and I have a lot of lines to draw. It’s so many that it takes lots of time to refresh the view port (something like 4000 to 5000 lines or even more, and it might take 2 or 3 secs).
I’ve seen these great games and how they use OpenGL and they won’t flick even once. I think they are using VGA cards capabilities. How they do that? There should be a way to enable them, I think that’s what I’m looking for… All I want to do is to draw faster.
And I’m using MS Visual C++ 6.0.
Drawing 5000 lines should not be a big problem with any any modern hardware even though mots hardware today is game oriented, that means that they usually are much better on drawing filled triangles then lines.
I know that it’s not a big deal for an up-to-date computer to draw 5000 lines. And that’s why I’m amazed of the slow result. All the programs I’ve written with OpenGL are the same in this case (I mean they are so slow), 2D and 3D both.
I have a 1600+ Athlon-AMD CPU and a 32MB TNT2. I’m somehow sure that my programs are not using my VGA capabilities and I think that’s the cause of their slowness. I think all the drawing is done by my cptr’s CPU and it makes it slow.
Well, I agree.
The problem is that, I think I already have my VGA’s driver installed. I mean I know about these kinds of drivers and that each hardware needs its driver to work properly.
To make you sure that I have my VGA’s driver installed, when I go to “Display Properties” I have a tab named “OpenGL” too. But I think there should be function call (perhaps a Windows’ API) to tell the OS to use Video Accelerator (if it’s available) when a program is going to draw an OpenGL object. I’m looking for that function call.
Still needs help, if anyone can help me…
And something that is important to me, is that I need to draw on my window with out losing its content. I mean I first load a bitmap on the Device Context and then I’m going to draw some lines with OpenGL on it.
I hope there’s a solution for it, becuase it means to me alot.
Which one do you think would be faster?
And would you please explain your second choice more. Is it an OpenGL solution or it’s using Windows API?
About your second choice I mean:
“b.) upload your bitmap as a texture and use that onto a quad and then draw your lines. using.”
(Using your background bitmap as an OpenGL texture mapped onto a simple quad is likely to be faster, but maybe harder to setup.
The texture have to be square, and each dimension must be “power of 2”, that is 256, 512, 1024, 2048… Up to your hardware limit.)
From your problem description, you seem to draw your bitmap only once, right ? So performance for the bitmap is not really important.
So, use glDrawPixels, it will be easier for your purpose.
Like ZBuffer said. Rendering your Bitmap as a textured quad will be faster, especially when you need to clear the color buffer.
And yes, its an OpenGL solution.
-upload your bitmap as texture
Loop:
-clear color & zbuffer
-disable zbuffer writes
-draw a quad the size of your window using that texture
-enable zbuffer writes
-draw your lines.
-goto Loop