[Off-Topic] Drawing text, menus etc. in OpenGL
Posted: 2008-01-03, 15:46
Hi,
I was playing around with OpenGL, and I am making a simple (2D) game. Anyway, the way I am currently drawing text is to have a text class, which in the constructor renders the text, then loads it as a texture. Then, in the draw method, it draws a quad with that texture mapped to it.
This works quite well, but I was wondering if there's an easier way of doing it... How do you do it in Ca3DE?
Then there are the menus - I just have a class which has a couple of vectors in it (one for each type of control), which just goes through and calls each of their draw methods when its draw method is called. I then have arrays of menus so I can draw them like this:
(in a switch case checking the gamestate)
Is this a good way to do this? The main hindrance is that it's hard to keep track of all the menu items, say if I want to change one of them. Most of the time, I just add controls like this:
If I wanted to change, say, the caption of the button, I would have no way to unless I had a bunch of pointers for all the menu items, which I was trying to avoid with my system... I really don't want to have to keep track of a bunch of pointers - do you think I should give the controls numerical IDs or names?
Thanks for your advice,
-Stephen
I was playing around with OpenGL, and I am making a simple (2D) game. Anyway, the way I am currently drawing text is to have a text class, which in the constructor renders the text, then loads it as a texture. Then, in the draw method, it draws a quad with that texture mapped to it.
This works quite well, but I was wondering if there's an easier way of doing it... How do you do it in Ca3DE?
Then there are the menus - I just have a class which has a couple of vectors in it (one for each type of control), which just goes through and calls each of their draw methods when its draw method is called. I then have arrays of menus so I can draw them like this:
Code: Select all
case E_MENU : _Menus[_CurrentMenu]->Draw();
Is this a good way to do this? The main hindrance is that it's hard to keep track of all the menu items, say if I want to change one of them. Most of the time, I just add controls like this:
Code: Select all
_Menus[E_MAIN]->AddControl(new Button(...));
Thanks for your advice,
-Stephen