PDA

View Full Version : Using VGA Accelerator..



mehran20
01-29-2004, 08:58 PM
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.

Thanks in advance.
Mehran Ziadloo

mikael_aronsson
01-29-2004, 09:47 PM
Hi !

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.

What kind of hardware do you have ?

Mikael

mehran20
01-29-2004, 11:14 PM
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.

ZbuffeR
01-29-2004, 11:52 PM
I think all the drawing is done by my cptr's CPU and it makes it slow.
So you should download recent drivers for your card at http://www.nvidia.com

mehran20
01-30-2004, 01:30 AM
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..

Honk
01-30-2004, 03:43 AM
There is no API call to enable hardware acceleration. You need to pick an accelerated pixelformat thats all.

mehran20
01-30-2004, 04:02 AM
And how can I do that? I have a little experience in API programming, I really can use your help..
My currecnt Pixel Format is:

PIXELFORMATDESCRIPTOR pfd;
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_BITMAP | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_SUPPORT_GDI;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cDepthBits = 16;

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.

Thanks again.
Mehran Ziadloo

Honk
01-30-2004, 04:51 AM
1st:

using PFD_DOUBLEBUFFER and PFD_SUPPORT_GDI is mutally exclusive (check the documentation)

2nd:

PFD_SUPPORT_GDI and PFD_DRAW_TO_BITMAP will force OpenGL to use the microsoft software renderer.

From what I understand from your post, you want to draw some lines onto a given bitmap, is that correct?

Then you could use:

a.) use glDrawPixels() to draw the bitmap into your RC and then draw your lines using OpenGL calls.

b.) upload your bitmap as a texture and use that onto a quad and then draw your lines. using.

I not sure if I understood your post 100% though...

mehran20
01-30-2004, 07:40 AM
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."

Thank You
Mehran Ziadloo

ZbuffeR
01-30-2004, 11:25 AM
(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.

Honk
01-31-2004, 05:09 AM
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