Need speed boost., on 2d (??)
Hello everyone. I'm a new open gl programmer, however I'm not that new to C++ in general.
In my current project I have a 2d menu system. From looking at the nehe tutorials, it seems that gl doesnt have its own 2d command library, and 2d must be drawn by using planes and gl blending modes.
Right now, the actual drawing works fine. I made a control system where I can define controls such as drop boxes, command buttons, list boxes, etc.. And then draw each one.
My problem is that after I add more than 3 or 4 controls, it starts lagging ALOT.
Since the entire menu system is going to be in 2d for the most part, my question is, what can I do to speed this up? I use hundreds of polys in the 3d game play with out lag at all, but when I try to draw the low-poly menus, I get a signifgant speed loss.
The only difference from the game play is that the menus use 2d sprite masking heavily, while the actual gameplay only uses it in a few places, however I can't see how this would be the cause of the lag.
I considered actually just drawing two signle planes (full screen) with two textures (mask, image) and editing the bitmap in ram.... I couldnt figure out how to access where gl stores textures once you load them. And when you define the GLuint texture, its just an integer vaulue that means something to glBindTexture, not a pointer to the texture.
Any help on how I could give my 2d system a speed boost would be greatly appriciated, also if possible, code examples would be greatly appriciated.
Thanks
)>-GTRONICS-<(
)>- Gt -<(
Just one simple question: Are you using Windows bitmap fonts?
Then the answer would be: Stop! Make your own font engine or use a library... After a couple of lines of bitmap fonts you won't suceed in any fast 2D engine...
Then the answer would be: Stop! Make your own font engine or use a library... After a couple of lines of bitmap fonts you won't suceed in any fast 2D engine...
Killers don't end up in jailThey end up on a high-score!
Another question...
Are you using quads to your menus and buttons?
It could be the reason why it is really slow. If you are using quads then try to use 2 triangles instead.
Are you using quads to your menus and buttons?
It could be the reason why it is really slow. If you are using quads then try to use 2 triangles instead.
Quote: Original post by Gtronics
The only difference from the game play is that the menus use 2d sprite masking heavily, while the actual gameplay only uses it in a few places, however I can't see how this would be the cause of the lag.
Maybe not, but do not use masks. Use alpha test!
Quote: Original post by Gtronics
I considered actually just drawing two signle planes (full screen) with two textures (mask, image) and editing the bitmap in ram.... I couldnt figure out how to access where gl stores textures once you load them. And when you define the GLuint texture, its just an integer vaulue that means something to glBindTexture, not a pointer to the texture.
You can' get acces to them and even if you could never read anything from the video memory! It's slow. If you need to modify a texture you need reload it to the video memory (glSubTexImage2D).
Most likely you are doing too much over draw or you are doing something that is not hardware accelereted. Try commenting out the code to identify witch part is causing the slowdown.
Quote:
Are you using quads to your menus and buttons?
It could be the reason why it is really slow. If you are using quads then try to use 2 triangles instead
With a low polycount it really does not make a difference.
Quote: Original post by master of void
Another question...
Are you using quads to your menus and buttons?
It could be the reason why it is really slow. If you are using quads then try to use 2 triangles instead.
Hmm, well, NO!
Not even 100.000 quads would be slow in something as simple as a menu! You almost don't render anything in a menu, so even if you draw the same quads 10 times per frame it wouldn't affect the framerate much.
Anyways, you emit two glVertex2f more with 2 triangles than with 1 quad, and the splitting up in the GPU won't be hurting anything in a menu. Of course, if your menu consist of 200.000 textured quads, then you might want to look into another solution :D
Killers don't end up in jailThey end up on a high-score!
Quote: Original post by master of void
Another question...
Are you using quads to your menus and buttons?
It could be the reason why it is really slow. If you are using quads then try to use 2 triangles instead.
Actuarly quads(and all other polygon tools exept points and lines) creates triangles, the only difference is in wireframe mode, so there is no real speed difference between the two methods.
The most common reason why things suddenly slows down to a crawl for no apparent reason is that the driver has to go into software mode.
For instance, if you have an old nvidia card(gf3 or simmilar) with the latest drivers and the textures for your buttons are NPOT(Non Power Of Two), old gfx cards wouldn't be able to render it in hardware, so the driver has to go into software mode.
Now if you would have an 5x.xx or older driver it would just ignore the texture and replace it with the color white.
But then again, i could be wrong.
www.flashbang.se | www.thegeekstate.com | nehe.gamedev.net | glAux fix for lesson 6 | [twitter]thegeekstate[/twitter]
Quote: Original post by nife
Just one simple question: Are you using Windows bitmap fonts?
Then the answer would be: Stop! Make your own font engine or use a library... After a couple of lines of bitmap fonts you won't suceed in any fast 2D engine...
You nailed it, now it runs fine!
Thanks alot
As for your other suggestions thanks for the advice, for future reference.
Thanks again,
)>-GTRONICS-<(
)>- Gt -<(
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement