Original Post
🔒 Locked
Rendering Question
Advertisement
If you have multiple interchangeable objects of the same type that render exclusive with respect to each other...use a pointer to that object type and swap objects to that pointer then just render the object pointed to by that pointer.
Say that in English you say? :o)
For your menu do as you have now:
void Render()
{
if(bMenuIsUp)
RenderMenu()
...
I like to have a menu object and a pointer to a menu object that indicates whether my menu is up or not... So my code looks like this:
if(m_pCurrentMenu != NULL)
m_pCurrentMenu->Render();
When m_pCurrentMenu == NULL my menu is not open. When I open my menu, I point m_pCurrentMenu to it. When I close my menu, I set m_pCurrentMenu = NULL.
So if you have multiple ''levels'' that you are rendering and they are all of type CLevel or something, then you just use a pointer to a CLevel type. Something like this:
CLevel* m_pCurrentLevel;
Then in your Render() function you say...
if(m_pCurrentLevel != NULL)
m_pCurrentLevel->Render();
And in your code where you change levels you set m_pCurrentLevel = &LevelOne, m_pCurrentLevel = &LevelTwo and so on.
This all works as long as your levels are all objects of the same type as the pointer.
Of course, this is all object oriented and C++ with classes so if you aren''t using that then it will be a bit harder to do it this way.
Say that in English you say? :o)
For your menu do as you have now:
void Render()
{
if(bMenuIsUp)
RenderMenu()
...
I like to have a menu object and a pointer to a menu object that indicates whether my menu is up or not... So my code looks like this:
if(m_pCurrentMenu != NULL)
m_pCurrentMenu->Render();
When m_pCurrentMenu == NULL my menu is not open. When I open my menu, I point m_pCurrentMenu to it. When I close my menu, I set m_pCurrentMenu = NULL.
So if you have multiple ''levels'' that you are rendering and they are all of type CLevel or something, then you just use a pointer to a CLevel type. Something like this:
CLevel* m_pCurrentLevel;
Then in your Render() function you say...
if(m_pCurrentLevel != NULL)
m_pCurrentLevel->Render();
And in your code where you change levels you set m_pCurrentLevel = &LevelOne, m_pCurrentLevel = &LevelTwo and so on.
This all works as long as your levels are all objects of the same type as the pointer.
Of course, this is all object oriented and C++ with classes so if you aren''t using that then it will be a bit harder to do it this way.
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement