From aaa4c308db56d202669f61aea3e77a1d811a2f66 Mon Sep 17 00:00:00 2001 From: Nick Gasson Date: Fri, 5 Jun 2009 12:57:55 +0100 Subject: [PATCH] Get rid of the ConstructAsteroid function --- src/Asteroid.cpp | 16 +++++++--------- src/Asteroid.hpp | 5 ++--- src/Game.cpp | 4 +--- src/OpenGL.cpp | 10 ++++++++++ 4 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/Asteroid.cpp b/src/Asteroid.cpp index 81f506f..bdd845e 100644 --- a/src/Asteroid.cpp +++ b/src/Asteroid.cpp @@ -23,7 +23,8 @@ Texture* Asteroid::surfTexture[Surface::NUM_SURF_TEX]; -Asteroid::Asteroid() +Asteroid::Asteroid(int x, int y, int width, int surftex) + : StaticObject(x, y, width, 4) { LOAD_ONCE { surfTexture[0] = new Texture("images/dirt_surface2.png"); @@ -33,14 +34,6 @@ Asteroid::Asteroid() } display_list = glGenLists(1); -} - -void Asteroid::ConstructAsteroid(int x, int y, int width, int surftex) -{ - xpos = x; - ypos = y; - this->width = width; - height = 4; int change, texloop=0; @@ -118,6 +111,11 @@ void Asteroid::ConstructAsteroid(int x, int y, int width, int surftex) GenerateDisplayList(surftex); } +Asteroid::~Asteroid() +{ + //glDeleteLists(display_list, 1); +} + void Asteroid::GenerateDisplayList(int texidx) { glNewList(display_list, GL_COMPILE); diff --git a/src/Asteroid.hpp b/src/Asteroid.hpp index df43b41..24eae05 100644 --- a/src/Asteroid.hpp +++ b/src/Asteroid.hpp @@ -26,10 +26,9 @@ class Asteroid : public StaticObject { public: - Asteroid(); - ~Asteroid() {} + Asteroid(int x, int y, int width, int surftex); + ~Asteroid(); - void ConstructAsteroid(int x, int y, int width, int surftex); void Draw(int viewadjust_x, int viewadjust_y) const; bool CheckCollision(const Ship& ship) const; LineSegment GetUpBoundary(int poly) const; diff --git a/src/Game.cpp b/src/Game.cpp index 7259f6f..4f8c332 100644 --- a/src/Game.cpp +++ b/src/Game.cpp @@ -467,9 +467,7 @@ void Game::MakeAsteroids(int surftex) } // Generate the asteroid - Asteroid a; - a.ConstructAsteroid(x, y, width, surftex); - asteroids_.push_back(a); + asteroids_.push_back(Asteroid(x, y, width, surftex)); } } diff --git a/src/OpenGL.cpp b/src/OpenGL.cpp index f1e0328..d548a58 100644 --- a/src/OpenGL.cpp +++ b/src/OpenGL.cpp @@ -23,6 +23,8 @@ #include +#include + OpenGL::OpenGL() : screen_width(0), screen_height(0), fullscreen(false), running(false), active(true), @@ -183,6 +185,14 @@ void OpenGL::DrawGLScene() glLoadIdentity(); ScreenManager::GetInstance().Display(); + + // Check for OpenGL errors + GLenum error = glGetError(); + if (error != GL_NO_ERROR) { + throw runtime_error + ("OpenGL error: " + boost::lexical_cast(gluErrorString(error))); + } + SDL_GL_SwapBuffers(); if (deferredScreenShot) { -- 2.39.2