PDA

View Full Version : OpenGL code performance



digitalshooter
08-24-2008, 06:22 PM
Hi all, I have a C# OpenGL program which draw a torus and 50 small spheres. It's actually the sample program in chapter 4 of the OpenGL super bible book I'm reading, the sample program is in C++ and I tried to converted to C#.

I have corrected output but terrible performance with my C# program, it takes 500ms to draw the scene, while the orignal sample program is crazily fast.

I'm thinking my problem could be I'm using software implementation of OpenGL on windows, and the sample is using my graphics hardware ? Could anyone help to how to improve my C# program? :( Many thanks.

ZbuffeR
08-25-2008, 01:07 AM
Try one of the viewers here, if they say something like "vendor: microsoft" then it means you need to install recent drivers for your video card, to have opengl acceleration.
http://www.opengl.org/wiki/index.php/Getting_started#OpenGL_Viewers

In your code, you can call those to check :
glGetString(GL_VENDOR)
glGetString(GL_RENDERER)
glGetString(GL_VERSION)

It is possible that when request a GL context with some constraints, it can not create it accelerated, and gives you an unaccelerated context. But normally the gets above should give you the same info as the GL viewers.

ZbuffeR
08-25-2008, 01:11 AM
Then I you still have problems with performance, with an accelerated context : http://www.opengl.org/wiki/index.php/Performance

digitalshooter
08-25-2008, 03:14 PM
I changed something with my set pixel format function, and it returned: vendor ="Intel", renderer= "Intel G915M". Before it returned : vendor ="Microsoft", renderer="GDI Generic".

But the performance of my program still be very slow when I click F5 in Visual studio. But when I used Ctrl + F5, the performance is very, very good.

Thank you very much for your advice :)

PaladinOfKaos
08-25-2008, 03:18 PM
as I recall, F5 hooks the debugger in, and CTRL+F5 runs the program on its own. That would explain the discrepancy.

digitalshooter
08-25-2008, 03:45 PM
I want to use display list to improve the performance further, I'm reading my book and it says that some openGL commands are not good or does not make sense within a display list. It does not say anything about matrix operations (modelview, projection..)

Can I use these matrix operations within a display list ?

PaladinOfKaos
08-25-2008, 03:48 PM
Display lists are obsolete. You can learn them if you want, but in the long run they won't be very helpful.

You'd be better off moving from immediate mode to vertex arrays, or even to VBOs.