- replaced calls to glgenlists and family as these gl calls are deprecated in newer opengl (and really did not do anything for us)

This commit is contained in:
Mark Vejvoda 2012-05-24 06:16:54 +00:00
parent 0fac755a5e
commit b6a4e33e7d
4 changed files with 264 additions and 177 deletions

View File

@ -1680,8 +1680,8 @@ void Game::renderWorker() {
} }
else { else {
Renderer &renderer= Renderer::getInstance(); Renderer &renderer= Renderer::getInstance();
if(renderer.getCustom3dMenuList() != NULL) { if(renderer.getCustom3dMenu() != NULL) {
renderer.setCustom3dMenuList(NULL); renderer.setCustom3dMenu(NULL);
} }
} }
@ -1924,7 +1924,7 @@ void Game::mouseDownLeft(int x, int y) {
MainMenu *newMenu = new MainMenu(program); // open keyboard shortcuts setup screen MainMenu *newMenu = new MainMenu(program); // open keyboard shortcuts setup screen
currentUIState = newMenu; currentUIState = newMenu;
Renderer &renderer= Renderer::getInstance(); Renderer &renderer= Renderer::getInstance();
renderer.setCustom3dMenuList(&statelist3dMenu); renderer.setCustom3dMenu(newMenu);
//currentUIState->load(); //currentUIState->load();
currentUIState->init(); currentUIState->init();

View File

@ -149,7 +149,7 @@ private:
int saveGamePopupMenuIndex; int saveGamePopupMenuIndex;
int loadGamePopupMenuIndex; int loadGamePopupMenuIndex;
int keyboardSetupPopupMenuIndex; int keyboardSetupPopupMenuIndex;
GLuint statelist3dMenu; //GLuint statelist3dMenu;
ProgramState *currentUIState; ProgramState *currentUIState;
bool masterserverMode; bool masterserverMode;

View File

@ -183,13 +183,15 @@ Renderer::Renderer() : BaseRenderer() {
shadowMapHandle=0; shadowMapHandle=0;
shadowMapHandleValid=false; shadowMapHandleValid=false;
list3d=0; //list3d=0;
list3dValid=false; //list3dValid=false;
list2d=0; //list2d=0;
list2dValid=false; //list2dValid=false;
list3dMenu=0; //list3dMenu=0;
list3dMenuValid=false; //list3dMenuValid=false;
customlist3dMenu=NULL; //customlist3dMenu=NULL;
mm3d = NULL;
custom_mm3d = NULL;
this->program = NULL; this->program = NULL;
@ -533,7 +535,9 @@ void Renderer::initMenu(const MainMenu *mm) {
void Renderer::reset3d() { void Renderer::reset3d() {
assertGl(); assertGl();
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SEPARATE_SPECULAR_COLOR);
glCallList(list3d); //glCallList(list3d);
render3dSetup();
pointCount= 0; pointCount= 0;
triangleCount= 0; triangleCount= 0;
assertGl(); assertGl();
@ -542,18 +546,21 @@ void Renderer::reset3d() {
void Renderer::reset2d() { void Renderer::reset2d() {
assertGl(); assertGl();
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
glCallList(list2d); //glCallList(list2d);
render2dMenuSetup();
assertGl(); assertGl();
} }
void Renderer::reset3dMenu() { void Renderer::reset3dMenu() {
assertGl(); assertGl();
glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR); glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL, GL_SINGLE_COLOR);
if(this->customlist3dMenu != NULL) { if(this->custom_mm3d != NULL) {
glCallList(*this->customlist3dMenu); render3dMenuSetup(this->custom_mm3d);
//glCallList(*this->customlist3dMenu);
} }
else { else {
glCallList(list3dMenu); render3dMenuSetup(this->mm3d);
//glCallList(list3dMenu);
} }
assertGl(); assertGl();
@ -591,10 +598,10 @@ void Renderer::end() {
} }
//delete 2d list //delete 2d list
if(list2dValid == true) { //if(list2dValid == true) {
glDeleteLists(list2d, 1); // glDeleteLists(list2d, 1);
list2dValid=false; // list2dValid=false;
} //}
Renderer::rendererEnded = true; Renderer::rendererEnded = true;
} }
@ -621,10 +628,10 @@ void Renderer::endScenario() {
shadowMapHandleValid=false; shadowMapHandleValid=false;
} }
if(list3dValid == true) { //if(list3dValid == true) {
glDeleteLists(list3d, 1); // glDeleteLists(list3d, 1);
list3dValid=false; // list3dValid=false;
} //}
//worldToScreenPosCache.clear(); //worldToScreenPosCache.clear();
ReleaseSurfaceVBOs(); ReleaseSurfaceVBOs();
@ -664,10 +671,10 @@ void Renderer::endGame(bool isFinalEnd) {
shadowMapHandleValid=false; shadowMapHandleValid=false;
} }
if(list3dValid == true) { //if(list3dValid == true) {
glDeleteLists(list3d, 1); // glDeleteLists(list3d, 1);
list3dValid=false; // list3dValid=false;
} //}
//worldToScreenPosCache.clear(); //worldToScreenPosCache.clear();
ReleaseSurfaceVBOs(); ReleaseSurfaceVBOs();
@ -695,12 +702,12 @@ void Renderer::endMenu() {
return; return;
} }
if(this->customlist3dMenu != NULL) { //if(this->customlist3dMenu != NULL) {
glDeleteLists(*this->customlist3dMenu,1); // glDeleteLists(*this->customlist3dMenu,1);
} //}
else { //else {
glDeleteLists(list3dMenu, 1); // glDeleteLists(list3dMenu, 1);
} //}
} }
void Renderer::reloadResources() { void Renderer::reloadResources() {
@ -6973,22 +6980,33 @@ void Renderer::init3dList() {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
const Metrics &metrics= Metrics::getInstance(); render3dSetup();
//const Metrics &metrics= Metrics::getInstance();
assertGl(); //assertGl();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
list3d= glGenLists(1); //list3d= glGenLists(1);
assertGl(); //assertGl();
list3dValid=true; //list3dValid=true;
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
glNewList(list3d, GL_COMPILE_AND_EXECUTE); //glNewList(list3d, GL_COMPILE_AND_EXECUTE);
//need to execute, because if not gluPerspective takes no effect and gluLoadMatrix is wrong //need to execute, because if not gluPerspective takes no effect and gluLoadMatrix is wrong
//render3dSetup();
//glEndList();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//assert
//assertGl();
}
void Renderer::render3dSetup() {
const Metrics &metrics= Metrics::getInstance();
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//misc //misc
glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH()); glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH());
@ -6997,7 +7015,7 @@ void Renderer::init3dList() {
glEnable(GL_CULL_FACE); glEnable(GL_CULL_FACE);
loadProjectionMatrix(); loadProjectionMatrix();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//texture state //texture state
glActiveTexture(shadowTexUnit); glActiveTexture(shadowTexUnit);
@ -7012,7 +7030,7 @@ void Renderer::init3dList() {
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//material state //material state
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defSpecularColor.ptr()); glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defSpecularColor.ptr());
@ -7034,7 +7052,7 @@ void Renderer::init3dList() {
glDepthMask(GL_TRUE); glDepthMask(GL_TRUE);
glDepthFunc(GL_LESS); glDepthFunc(GL_LESS);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//lighting state //lighting state
glEnable(GL_LIGHTING); glEnable(GL_LIGHTING);
@ -7046,19 +7064,19 @@ void Renderer::init3dList() {
//stencil test //stencil test
glDisable(GL_STENCIL_TEST); glDisable(GL_STENCIL_TEST);
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//fog //fog
const Tileset *tileset= NULL; const Tileset *tileset= NULL;
if(game != NULL && game->getWorld() != NULL) { if(game != NULL && game->getWorld() != NULL) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
tileset = game->getWorld()->getTileset(); tileset = game->getWorld()->getTileset();
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
if(tileset != NULL && tileset->getFog()) { if(tileset != NULL && tileset->getFog()) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
glEnable(GL_FOG); glEnable(GL_FOG);
if(tileset->getFogMode()==fmExp) { if(tileset->getFogMode()==fmExp) {
@ -7072,14 +7090,7 @@ void Renderer::init3dList() {
glFogfv(GL_FOG_COLOR, tileset->getFogColor().ptr()); glFogfv(GL_FOG_COLOR, tileset->getFogColor().ptr());
} }
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); //if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
glEndList();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//assert
assertGl();
} }
void Renderer::init2dList() { void Renderer::init2dList() {
@ -7087,15 +7098,20 @@ void Renderer::init2dList() {
return; return;
} }
// //this list sets the state for the 2d rendering
// list2d= glGenLists(1);
// assertGl();
// list2dValid=true;
//
// glNewList(list2d, GL_COMPILE);
// render2dMenuSetup();
// glEndList();
//
// assertGl();
}
void Renderer::render2dMenuSetup() {
const Metrics &metrics= Metrics::getInstance(); const Metrics &metrics= Metrics::getInstance();
//this list sets the state for the 2d rendering
list2d= glGenLists(1);
assertGl();
list2dValid=true;
glNewList(list2d, GL_COMPILE);
//projection //projection
glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH()); glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH());
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
@ -7124,10 +7140,6 @@ void Renderer::init2dList() {
//color //color
glColor4f(1.f, 1.f, 1.f, 1.f); glColor4f(1.f, 1.f, 1.f, 1.f);
glEndList();
assertGl();
} }
void Renderer::init3dListMenu(const MainMenu *mm) { void Renderer::init3dListMenu(const MainMenu *mm) {
@ -7135,6 +7147,8 @@ void Renderer::init3dListMenu(const MainMenu *mm) {
return; return;
} }
this->mm3d = mm;
/*
assertGl(); assertGl();
if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
@ -7229,9 +7243,75 @@ void Renderer::init3dListMenu(const MainMenu *mm) {
//assert //assert
assertGl(); assertGl();
*/
} }
void Renderer::render3dMenuSetup(const MainMenu *mm) {
const Metrics &metrics= Metrics::getInstance();
const MenuBackground *mb = NULL;
if(mm != NULL) {
mb = mm->getConstMenuBackground();
}
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//misc
glViewport(0, 0, metrics.getScreenW(), metrics.getScreenH());
glClearColor(0.4f, 0.4f, 0.4f, 1.f);
glFrontFace(GL_CW);
glEnable(GL_CULL_FACE);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(perspFov, metrics.getAspectRatio(), perspNearPlane, 1000000);
//texture state
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
//material state
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, defSpecularColor.ptr());
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, defAmbientColor.ptr());
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, defDiffuseColor.ptr());
glColor4fv(defColor.ptr());
glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
//blend state
glDisable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
//alpha test state
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.f);
//depth test state
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
glDepthFunc(GL_LESS);
//lighting state
glEnable(GL_LIGHTING);
//matrix mode
glMatrixMode(GL_MODELVIEW);
//stencil test
glDisable(GL_STENCIL_TEST);
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
//fog
if(mb != NULL && mb->getFog()) {
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
glEnable(GL_FOG);
glFogi(GL_FOG_MODE, GL_EXP2);
glFogf(GL_FOG_DENSITY, mb->getFogDensity());
}
//assert
assertGl();
//if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",extractFileFromDirectoryPath(__FILE__).c_str(),__FUNCTION__,__LINE__);
}
// ==================== misc ==================== // ==================== misc ====================
void Renderer::loadProjectionMatrix() { void Renderer::loadProjectionMatrix() {

View File

@ -275,13 +275,15 @@ private:
ParticleManager *particleManager[rsCount]; ParticleManager *particleManager[rsCount];
//state lists //state lists
GLuint list3d; //GLuint list3d;
bool list3dValid; //bool list3dValid;
GLuint list2d; //GLuint list2d;
bool list2dValid; //bool list2dValid;
GLuint list3dMenu; //GLuint list3dMenu;
bool list3dMenuValid; //bool list3dMenuValid;
GLuint *customlist3dMenu; //GLuint *customlist3dMenu;
const MainMenu *mm3d;
const MainMenu *custom_mm3d;
//shadows //shadows
GLuint shadowMapHandle; GLuint shadowMapHandle;
@ -586,8 +588,10 @@ public:
static Texture2D * preloadTexture(string logoFilename); static Texture2D * preloadTexture(string logoFilename);
inline int getCachedSurfaceDataSize() const { return mapSurfaceData.size(); } inline int getCachedSurfaceDataSize() const { return mapSurfaceData.size(); }
void setCustom3dMenuList(GLuint *customlist3dMenu) { this->customlist3dMenu = customlist3dMenu; } //void setCustom3dMenuList(GLuint *customlist3dMenu) { this->customlist3dMenu = customlist3dMenu; }
inline GLuint * getCustom3dMenuList() const { return this->customlist3dMenu; } //inline GLuint * getCustom3dMenuList() const { return this->customlist3dMenu; }
void setCustom3dMenu(const MainMenu *mm) { this->custom_mm3d = mm; }
const MainMenu * getCustom3dMenu() { return this->custom_mm3d; }
void init3dListMenu(const MainMenu *mm); void init3dListMenu(const MainMenu *mm);
@ -637,6 +641,9 @@ private:
static Texture2D::Filter strToTextureFilter(const string &s); static Texture2D::Filter strToTextureFilter(const string &s);
void cleanupScreenshotThread(); void cleanupScreenshotThread();
void render2dMenuSetup();
void render3dSetup();
void render3dMenuSetup(const MainMenu *mm);
}; };
}} //end namespace }} //end namespace