using now 3d asteroids

3d_asteroids
martin 2011-06-13 19:21:39 +02:00
parent 5c58595f35
commit 419ebc8783
2 changed files with 27 additions and 28 deletions

View File

@ -269,20 +269,6 @@ void View::Draw() {
DrawWorld (); DrawWorld ();
} }
glPushMatrix();
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
glRotatef (90, 1., 0., 0.);
// glScalef (10., 10., 10.);
DrawOBJModel (mAsteroidModel);
glDisable (GL_LIGHT0);
glDisable (GL_LIGHTING);
glPopMatrix();
DrawUi (); DrawUi ();
// Perform post-Draw actions // Perform post-Draw actions
@ -677,6 +663,8 @@ void View::DrawUiLevelIntro() {
GetModel()->SetPlayerLives(100); GetModel()->SetPlayerLives(100);
} }
glEnable(GL_BLEND);
stringstream level_info_stream; stringstream level_info_stream;
level_info_stream << "Level " << GetModel()->GetCurrentLevelIndex() + 1; level_info_stream << "Level " << GetModel()->GetCurrentLevelIndex() + 1;
@ -760,6 +748,8 @@ void View::DrawUiLevelIntro() {
level_author_dest_y - Engine::GetTimer("LevelIntroLevelAuthor") * level_author_delta_y level_author_dest_y - Engine::GetTimer("LevelIntroLevelAuthor") * level_author_delta_y
); );
glDisable(GL_BLEND);
if (Engine::CheckTimer("LevelIntroLevelStart")) { if (Engine::CheckTimer("LevelIntroLevelStart")) {
if(Engine::GUI::Button (1, "Start", (screen_right - button_width) * 0.5, screen_bottom * 0.5 + 180, button_width, button_height)) { if(Engine::GUI::Button (1, "Start", (screen_right - button_width) * 0.5, screen_bottom * 0.5 + 180, button_width, button_height)) {
PopViewState(); PopViewState();
@ -1661,8 +1651,24 @@ void View::DrawShip (ShipEntity *ship) {
} }
void View::DrawAsteroid (AsteroidEntity *asteroid) { void View::DrawAsteroid (AsteroidEntity *asteroid) {
mAsteroidSprite.SetScale (2. * asteroid->mPhysicState->mRadius / mAsteroidSprite.GetWidth()); // mAsteroidSprite.SetScale (2. * asteroid->mPhysicState->mRadius / mAsteroidSprite.GetWidth());
mAsteroidSprite.DrawAt(0., 0., 0.); // mAsteroidSprite.DrawAt(0., 0., 0.);
glPushMatrix();
glEnable (GL_LIGHTING);
glEnable (GL_LIGHT0);
// glRotatef (90, 1., 0., 0.);
float scale = 1.8 * asteroid->mPhysicState->mRadius;
glScalef (scale, scale, scale);
DrawOBJModel (mAsteroidModel);
glDisable (GL_LIGHT0);
glDisable (GL_LIGHTING);
glPopMatrix();
#ifdef DRAW_BOUNDARIES #ifdef DRAW_BOUNDARIES
glColor3f (1., 1., 1.); glColor3f (1., 1., 1.);

View File

@ -651,9 +651,6 @@ void ViewBase::DrawOBJModelShaded (OBJModelPtr obj_model) {
std::map<std::string, GLuint>::const_iterator iter; std::map<std::string, GLuint>::const_iterator iter;
GLuint texture = 0; GLuint texture = 0;
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (int i = 0; i < obj_model->getNumberOfMeshes(); ++i) for (int i = 0; i < obj_model->getNumberOfMeshes(); ++i)
{ {
pMesh = &obj_model->getMesh(i); pMesh = &obj_model->getMesh(i);
@ -721,7 +718,7 @@ void ViewBase::DrawOBJModelShaded (OBJModelPtr obj_model) {
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture); glBindTexture(GL_TEXTURE_2D, texture);
} else { } else {
LogMessage ("bumpmap %s not found", pMaterial->bumpMapFilename.c_str()); LogError ("bumpmap %s not found", pMaterial->bumpMapFilename.c_str());
} }
// Bind the color map texture. // Bind the color map texture.
@ -735,7 +732,7 @@ void ViewBase::DrawOBJModelShaded (OBJModelPtr obj_model) {
if (iter != mGLTextures.end()) { if (iter != mGLTextures.end()) {
texture = iter->second; texture = iter->second;
} else { } else {
LogMessage ("color map %s not found", pMaterial->colorMapFilename.c_str()); LogError ("color map %s not found", pMaterial->colorMapFilename.c_str());
} }
} }
@ -812,17 +809,13 @@ void ViewBase::DrawOBJModelShaded (OBJModelPtr obj_model) {
// as we might be using multiple textures (at least for the normal mapping // as we might be using multiple textures (at least for the normal mapping
// case) we have to disable both textures // case) we have to disable both textures
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, 0);
glActiveTexture(GL_TEXTURE1); glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_2D, 0);
glUseProgram(0); glActiveTexture(GL_TEXTURE0);
glDisable(GL_BLEND); glBindTexture(GL_TEXTURE_2D, 0);
// disable texture drawing glUseProgram(0);
// glDisable(GL_TEXTURE_2D);
} }
/* /*