From 70cf2b95439cefbbbee6405ba3bf6413b0247e7b Mon Sep 17 00:00:00 2001 From: Vladislav Khorev Date: Sat, 22 Sep 2018 23:56:31 +0500 Subject: [PATCH] Prepare to set up shaders --- gl_base.cpp | 0 gl_cityview.cpp | 0 gl_screen.cpp | 49 ++++++++++++++++++++++++++++++++++++++++--------- viewer.cpp | 2 +- 4 files changed, 41 insertions(+), 10 deletions(-) mode change 100644 => 100755 gl_base.cpp mode change 100644 => 100755 gl_cityview.cpp diff --git a/gl_base.cpp b/gl_base.cpp old mode 100644 new mode 100755 diff --git a/gl_cityview.cpp b/gl_cityview.cpp old mode 100644 new mode 100755 diff --git a/gl_screen.cpp b/gl_screen.cpp index 1de37ed..1a93e7b 100755 --- a/gl_screen.cpp +++ b/gl_screen.cpp @@ -243,28 +243,59 @@ namespace OpenGL { ERROR << "No symbol 'wglSwapIntervalEXT' found - cannot use WGL vsync" << std::endl; #endif } - /* - GLfloat LightAmbient[] = { 0.1f, 0.1f, 0.1f, 1.0f }; - GLfloat LightDiffuse[] = { 1.0f, 1.0f, 1.0f, 1.0f }; - GLfloat LightPosition[] = { 1.0f, 1.0f, 0.0f, 0.0f }; - */ + + GLfloat LightAmbient[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + GLfloat LightDiffuse[] = { 0.0f, 0.0f, 0.0f, 1.0f }; + GLfloat LightPosition[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + //glShadeModel( GL_SMOOTH ); glClearColor( 0.0f, 0.0f, 0.0f, 0.0f ); glEnable( GL_DEPTH_TEST ); - /* + glEnable( GL_LIGHTING ); + glEnable(GL_LIGHT0); + //glDisable(GL_LIGHT0); + glEnable(GL_LIGHT1); + //glDisable(GL_LIGHT1); glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST ); glLightfv( GL_LIGHT0, GL_AMBIENT, LightAmbient ); glLightfv( GL_LIGHT0, GL_DIFFUSE, LightDiffuse ); glLightfv( GL_LIGHT0, GL_POSITION, LightPosition ); - glEnable( GL_LIGHT0 ); - */ - glEnable( GL_COLOR_MATERIAL); + + GLfloat LightAmbient2[] = { 1.0f, 1.0f, 1.0f, 1.0f }; + + + glLightfv(GL_LIGHT1, GL_AMBIENT, LightAmbient2); + glLightfv(GL_LIGHT1, GL_DIFFUSE, LightDiffuse); + glLightfv(GL_LIGHT1, GL_POSITION, LightPosition); + + + glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD); + + + //glColorMaterial(GL_BACK, GL_AMBIENT_AND_DIFFUSE); glCullFace(GL_BACK); //glPolygonMode(GL_FRONT, GL_FILL); //glPolygonMode(GL_BACK, GL_LINE); glEnable(GL_TEXTURE_2D); + GLfloat MaterialAmbient[] = { 0.0f, 0.0f, 1.0f, 1.0f }; + + glEnable(GL_COLOR_MATERIAL); + + + glLightModelfv(GL_LIGHT_MODEL_AMBIENT, MaterialAmbient); + + + glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE); + glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, MaterialAmbient); + glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, MaterialAmbient); + glColorMaterial(GL_FRONT_AND_BACK, GL_EMISSION); + glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, MaterialAmbient); + + + //glEnable(GL_COLOR_MATERIAL); + if (queryExtension("GL_EXT_texture_filter_anisotropic")) { GLfloat maxAniso = 1.0f; glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &maxAniso); diff --git a/viewer.cpp b/viewer.cpp index ad7a64a..ffc8bd6 100755 --- a/viewer.cpp +++ b/viewer.cpp @@ -1001,7 +1001,7 @@ void drawScene(Uint32 ticks) { glPopMatrix();*/ GUI::ManagerHolder::Instance().draw(); - + num_frames_drawn += 1; glEnable(GL_DEPTH_TEST);