Added some m_ prefixes to member variables in GLRenderer and related classes
authorIngo Ruhnke <grumbel@gmail.com>
Sun, 17 Aug 2014 02:47:26 +0000 (04:47 +0200)
committerIngo Ruhnke <grumbel@gmail.com>
Sun, 17 Aug 2014 02:47:26 +0000 (04:47 +0200)
src/video/gl/gl_lightmap.cpp
src/video/gl/gl_lightmap.hpp
src/video/gl/gl_painter.cpp
src/video/gl/gl_painter.hpp
src/video/gl/gl_renderer.cpp
src/video/gl/gl_renderer.hpp
src/video/gl/gl_texture.cpp
src/video/gl/gl_texture.hpp

index a0ce5e4..8df70db 100644 (file)
@@ -52,22 +52,22 @@ inline int next_po2(int val)
 }
 
 GLLightmap::GLLightmap() :
-  lightmap(),
-  lightmap_width(),
-  lightmap_height(),
-  lightmap_uv_right(),
-  lightmap_uv_bottom()
+  m_lightmap(),
+  m_lightmap_width(),
+  m_lightmap_height(),
+  m_lightmap_uv_right(),
+  m_lightmap_uv_bottom()
 {
-  lightmap_width = SCREEN_WIDTH / LIGHTMAP_DIV;
-  lightmap_height = SCREEN_HEIGHT / LIGHTMAP_DIV;
-  unsigned int width = next_po2(lightmap_width);
-  unsigned int height = next_po2(lightmap_height);
+  m_lightmap_width = SCREEN_WIDTH / s_LIGHTMAP_DIV;
+  m_lightmap_height = SCREEN_HEIGHT / s_LIGHTMAP_DIV;
+  unsigned int width = next_po2(m_lightmap_width);
+  unsigned int height = next_po2(m_lightmap_height);
 
-  lightmap.reset(new GLTexture(width, height));
+  m_lightmap.reset(new GLTexture(width, height));
 
-  lightmap_uv_right = static_cast<float>(lightmap_width) / static_cast<float>(width);
-  lightmap_uv_bottom = static_cast<float>(lightmap_height) / static_cast<float>(height);
-  texture_manager->register_texture(lightmap.get());
+  m_lightmap_uv_right = static_cast<float>(m_lightmap_width) / static_cast<float>(width);
+  m_lightmap_uv_bottom = static_cast<float>(m_lightmap_height) / static_cast<float>(height);
+  texture_manager->register_texture(m_lightmap.get());
 }
 
 GLLightmap::~GLLightmap()
@@ -78,8 +78,8 @@ void
 GLLightmap::start_draw(const Color &ambient_color)
 {
 
-  glGetFloatv(GL_VIEWPORT, old_viewport); //save viewport
-  glViewport(old_viewport[0], old_viewport[3] - lightmap_height + old_viewport[1], lightmap_width, lightmap_height);
+  glGetFloatv(GL_VIEWPORT, m_old_viewport); //save viewport
+  glViewport(m_old_viewport[0], m_old_viewport[3] - m_lightmap_height + m_old_viewport[1], m_lightmap_width, m_lightmap_height);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
 #ifdef GL_VERSION_ES_CM_1_0
@@ -98,10 +98,10 @@ void
 GLLightmap::end_draw()
 {
   glDisable(GL_BLEND);
-  glBindTexture(GL_TEXTURE_2D, lightmap->get_handle());
-  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, old_viewport[0], old_viewport[3]  - lightmap_height + old_viewport[1], lightmap_width, lightmap_height);
+  glBindTexture(GL_TEXTURE_2D, m_lightmap->get_handle());
+  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_old_viewport[0], m_old_viewport[3] - m_lightmap_height + m_old_viewport[1], m_lightmap_width, m_lightmap_height);
 
-  glViewport(old_viewport[0], old_viewport[1], old_viewport[2], old_viewport[3]);
+  glViewport(m_old_viewport[0], m_old_viewport[1], m_old_viewport[2], m_old_viewport[3]);
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
 #ifdef GL_VERSION_ES_CM_1_0
@@ -123,7 +123,7 @@ GLLightmap::do_draw()
   // multiple the lightmap with the framebuffer
   glBlendFunc(GL_DST_COLOR, GL_ZERO);
 
-  glBindTexture(GL_TEXTURE_2D, lightmap->get_handle());
+  glBindTexture(GL_TEXTURE_2D, m_lightmap->get_handle());
 
   float vertices[] = {
     0, 0,
@@ -134,9 +134,9 @@ GLLightmap::do_draw()
   glVertexPointer(2, GL_FLOAT, 0, vertices);
 
   float uvs[] = {
-    0,                 lightmap_uv_bottom,
-    lightmap_uv_right, lightmap_uv_bottom,
-    lightmap_uv_right, 0,
+    0,                 m_lightmap_uv_bottom,
+    m_lightmap_uv_right, m_lightmap_uv_bottom,
+    m_lightmap_uv_right, 0,
     0, 0
   };
   glTexCoordPointer(2, GL_FLOAT, 0, uvs);
@@ -186,8 +186,8 @@ GLLightmap::get_light(const DrawingRequest& request) const
   for( int i = 0; i<3; i++)
     pixels[i] = 0.0f; //set to black
 
-  float posX = request.pos.x * lightmap_width / SCREEN_WIDTH + old_viewport[0];
-  float posY = old_viewport[3] + old_viewport[1] - request.pos.y * lightmap_height / SCREEN_HEIGHT;
+  float posX = request.pos.x * m_lightmap_width / SCREEN_WIDTH + m_old_viewport[0];
+  float posY = m_old_viewport[3] + m_old_viewport[1] - request.pos.y * m_lightmap_height / SCREEN_HEIGHT;
   glReadPixels((GLint) posX, (GLint) posY , 1, 1, GL_RGB, GL_FLOAT, pixels);
   *(getlightrequest->color_ptr) = Color( pixels[0], pixels[1], pixels[2]);
 }
index 0cd473c..5c4ad5d 100644 (file)
@@ -40,14 +40,14 @@ public:
   void get_light(const DrawingRequest& request) const;
 
 private:
-  static const int LIGHTMAP_DIV = 5;
-
-  boost::shared_ptr<GLTexture> lightmap;
-  int lightmap_width;
-  int lightmap_height;
-  float lightmap_uv_right;
-  float lightmap_uv_bottom;
-  GLfloat old_viewport[4]; //holds vieport before redefining in start_draw - returned from glGet
+  static const int s_LIGHTMAP_DIV = 5;
+
+  boost::shared_ptr<GLTexture> m_lightmap;
+  int m_lightmap_width;
+  int m_lightmap_height;
+  float m_lightmap_uv_right;
+  float m_lightmap_uv_bottom;
+  GLfloat m_old_viewport[4]; //holds vieport before redefining in start_draw - returned from glGet
 
 private:
   GLLightmap(const GLLightmap&);
index 3617dde..6ff1d80 100644 (file)
@@ -20,7 +20,7 @@
 #include "video/gl/gl_surface_data.hpp"
 #include "video/gl/gl_texture.hpp"
 
-GLuint GLPainter::last_texture = static_cast<GLuint>(-1);
+GLuint GLPainter::s_last_texture = static_cast<GLuint>(-1);
 
 namespace {
 
@@ -120,8 +120,8 @@ GLPainter::draw_surface(const DrawingRequest& request)
   }
 
   GLuint th = gltexture->get_handle();
-  if (th != last_texture) {
-    last_texture = th;
+  if (th != s_last_texture) {
+    s_last_texture = th;
     glBindTexture(GL_TEXTURE_2D, th);
   }
   intern_draw(request.pos.x, request.pos.y,
@@ -156,8 +156,8 @@ GLPainter::draw_surface_part(const DrawingRequest& request)
   float uv_bottom = surface_data->get_uv_top() + (uv_height * surfacepartrequest->srcrect.p2.y) / surface->get_height();
 
   GLuint th = gltexture->get_handle();
-  if (th != last_texture) {
-    last_texture = th;
+  if (th != s_last_texture) {
+    s_last_texture = th;
     glBindTexture(GL_TEXTURE_2D, th);
   }
   intern_draw(request.pos.x, request.pos.y,
index 3b006af..16a197d 100644 (file)
@@ -25,7 +25,7 @@ class DrawingRequest;
 class GLPainter
 {
 private:
-  static GLuint last_texture;
+  static GLuint s_last_texture;
 
 public:
   GLPainter();
index d5f71fe..2c813f3 100644 (file)
 #endif
 
 GLRenderer::GLRenderer() :
-  window(),
-  glcontext(),
-  viewport(),
-  desktop_size(0, 0),
-  fullscreen_active(false)
+  m_window(),
+  m_glcontext(),
+  m_viewport(),
+  m_desktop_size(0, 0),
+  m_fullscreen_active(false)
 {
   Renderer::instance_ = this;
 
   SDL_DisplayMode mode;
   SDL_GetCurrentDisplayMode(0, &mode);
-  desktop_size = Size(mode.w, mode.h);
+  m_desktop_size = Size(mode.w, mode.h);
 
   if(texture_manager != 0)
     texture_manager->save_textures();
@@ -104,8 +104,8 @@ GLRenderer::GLRenderer() :
 
 GLRenderer::~GLRenderer()
 {
-  SDL_GL_DeleteContext(glcontext);
-  SDL_DestroyWindow(window);
+  SDL_GL_DeleteContext(m_glcontext);
+  SDL_DestroyWindow(m_window);
 }
 
 void
@@ -181,7 +181,7 @@ void
 GLRenderer::flip()
 {
   assert_gl("drawing");
-  SDL_GL_SwapWindow(window);
+  SDL_GL_SwapWindow(m_window);
 }
 
 void
@@ -198,18 +198,18 @@ GLRenderer::apply_config()
   apply_video_mode();
 
   Size target_size = g_config->use_fullscreen ?
-    ((g_config->fullscreen_size == Size(0, 0)) ? desktop_size : g_config->fullscreen_size) :
+    ((g_config->fullscreen_size == Size(0, 0)) ? m_desktop_size : g_config->fullscreen_size) :
     g_config->window_size;
 
   float pixel_aspect_ratio = 1.0f;
   if (g_config->aspect_size != Size(0, 0))
   {
-    pixel_aspect_ratio = calculate_pixel_aspect_ratio(desktop_size,
+    pixel_aspect_ratio = calculate_pixel_aspect_ratio(m_desktop_size,
                                                       g_config->aspect_size);
   }
   else if (g_config->use_fullscreen)
   {
-    pixel_aspect_ratio = calculate_pixel_aspect_ratio(desktop_size,
+    pixel_aspect_ratio = calculate_pixel_aspect_ratio(m_desktop_size,
                                                       target_size);
   }
 
@@ -223,21 +223,21 @@ GLRenderer::apply_config()
                      g_config->magnification,
                      scale,
                      logical_size,
-                     viewport);
+                     m_viewport);
 
   SCREEN_WIDTH = logical_size.width;
   SCREEN_HEIGHT = logical_size.height;
 
-  if (viewport.x != 0 || viewport.y != 0)
+  if (m_viewport.x != 0 || m_viewport.y != 0)
   {
     // Clear both buffers so that we get a clean black border without junk
     glClear(GL_COLOR_BUFFER_BIT);
-    SDL_GL_SwapWindow(window);
+    SDL_GL_SwapWindow(m_window);
     glClear(GL_COLOR_BUFFER_BIT);
-    SDL_GL_SwapWindow(window);
+    SDL_GL_SwapWindow(m_window);
   }
 
-  glViewport(viewport.x, viewport.y, viewport.w, viewport.h);
+  glViewport(m_viewport.x, m_viewport.y, m_viewport.w, m_viewport.h);
 
   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
@@ -253,18 +253,18 @@ GLRenderer::apply_config()
 void
 GLRenderer::apply_video_mode()
 {
-  if (window)
+  if (m_window)
   {
     if (!g_config->use_fullscreen)
     {
-      SDL_SetWindowFullscreen(window, 0);
+      SDL_SetWindowFullscreen(m_window, 0);
     }
     else
     {
       if (g_config->fullscreen_size.width == 0 &&
           g_config->fullscreen_size.height == 0)
       {
-        if (SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)
+        if (SDL_SetWindowFullscreen(m_window, SDL_WINDOW_FULLSCREEN_DESKTOP) != 0)
         {
           log_warning << "failed to switch to desktop fullscreen mode: "
                       << SDL_GetError() << std::endl;
@@ -283,7 +283,7 @@ GLRenderer::apply_video_mode()
         mode.refresh_rate = g_config->fullscreen_refresh_rate;
         mode.driverdata = 0;
 
-        if (SDL_SetWindowDisplayMode(window, &mode) != 0)
+        if (SDL_SetWindowDisplayMode(m_window, &mode) != 0)
         {
           log_warning << "failed to set display mode: "
                       << mode.w << "x" << mode.h << "@" << mode.refresh_rate << ": "
@@ -291,7 +291,7 @@ GLRenderer::apply_video_mode()
         }
         else
         {
-          if (SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN) != 0)
+          if (SDL_SetWindowFullscreen(m_window, SDL_WINDOW_FULLSCREEN) != 0)
           {
             log_warning << "failed to switch to fullscreen mode: "
                         << mode.w << "x" << mode.h << "@" << mode.refresh_rate << ": "
@@ -315,7 +315,7 @@ GLRenderer::apply_video_mode()
       if (g_config->fullscreen_size == Size(0, 0))
       {
         flags |= SDL_WINDOW_FULLSCREEN_DESKTOP;
-        size = desktop_size;
+        size = m_desktop_size;
       }
       else
       {
@@ -329,11 +329,11 @@ GLRenderer::apply_video_mode()
       size = g_config->window_size;
     }
 
-    window = SDL_CreateWindow("SuperTux",
+    m_window = SDL_CreateWindow("SuperTux",
                               SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
                               size.width, size.height,
                               flags);
-    if (!window)
+    if (!m_window)
     {
       std::ostringstream msg;
       msg << "Couldn't set video mode " << size.width << "x" << size.height << ": " << SDL_GetError();
@@ -341,12 +341,12 @@ GLRenderer::apply_video_mode()
     }
     else
     {
-      glcontext = SDL_GL_CreateContext(window);
+      m_glcontext = SDL_GL_CreateContext(m_window);
 
       SCREEN_WIDTH = size.width;
       SCREEN_HEIGHT = size.height;
 
-      fullscreen_active = g_config->use_fullscreen;
+      m_fullscreen_active = g_config->use_fullscreen;
     }
   }
 }
@@ -394,8 +394,8 @@ GLRenderer::draw_inverse_ellipse(const DrawingRequest& request)
 Vector
 GLRenderer::to_logical(int physical_x, int physical_y)
 {
-  return Vector(static_cast<float>(physical_x - viewport.x) * SCREEN_WIDTH / viewport.w,
-                static_cast<float>(physical_y - viewport.y) * SCREEN_HEIGHT / viewport.h);
+  return Vector(static_cast<float>(physical_x - m_viewport.x) * SCREEN_WIDTH / m_viewport.w,
+                static_cast<float>(physical_y - m_viewport.y) * SCREEN_HEIGHT / m_viewport.h);
 }
 
 void
@@ -403,7 +403,7 @@ GLRenderer::set_gamma(float gamma)
 {
   Uint16 ramp[256];
   SDL_CalculateGammaRamp(gamma, ramp);
-  SDL_SetWindowGammaRamp(window, ramp, ramp, ramp);
+  SDL_SetWindowGammaRamp(m_window, ramp, ramp, ramp);
 }
 
 /* EOF */
index ae0e186..5da04a8 100644 (file)
 class GLRenderer : public Renderer
 {
 private:
-  SDL_Window* window;
-  SDL_GLContext glcontext;
-  SDL_Rect viewport;
-  Size desktop_size;
-  bool fullscreen_active;
+  SDL_Window* m_window;
+  SDL_GLContext m_glcontext;
+  SDL_Rect m_viewport;
+  Size m_desktop_size;
+  bool m_fullscreen_active;
 
 public:
   GLRenderer();
@@ -51,7 +51,7 @@ public:
   Vector to_logical(int physical_x, int physical_y) override;
   void set_gamma(float gamma) override;
 
-  SDL_Window* get_window() const { return window; }
+  SDL_Window* get_window() const { return m_window; }
 
 private:
   void apply_video_mode();
index 298e0f7..fe3864c 100644 (file)
@@ -35,70 +35,71 @@ inline int next_power_of_two(int val)
 } // namespace
 
 GLTexture::GLTexture(unsigned int width, unsigned int height) :
-  handle(),
-  texture_width(),
-  texture_height(),
-  image_width(),
-  image_height()
+  m_handle(),
+  m_texture_width(),
+  m_texture_height(),
+  m_image_width(),
+  m_image_height()
 {
 #ifdef GL_VERSION_ES_CM_1_0
   assert(is_power_of_2(width));
   assert(is_power_of_2(height));
 #endif
-  texture_width  = width;
-  texture_height = height;
-  image_width  = width;
-  image_height = height;
+  m_texture_width  = width;
+  m_texture_height = height;
+  m_image_width  = width;
+  m_image_height = height;
 
   assert_gl("before creating texture");
-  glGenTextures(1, &handle);
+  glGenTextures(1, &m_handle);
 
   try {
-    glBindTexture(GL_TEXTURE_2D, handle);
+    glBindTexture(GL_TEXTURE_2D, m_handle);
 
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width,
-                 texture_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 
+                 m_texture_width, m_texture_height, 
+                 0, GL_RGBA, GL_UNSIGNED_BYTE, 0);
 
     set_texture_params();
   } catch(...) {
-    glDeleteTextures(1, &handle);
+    glDeleteTextures(1, &m_handle);
     throw;
   }
 }
 
 GLTexture::GLTexture(SDL_Surface* image) :
-  handle(),
-  texture_width(),
-  texture_height(),
-  image_width(),
-  image_height()
+  m_handle(),
+  m_texture_width(),
+  m_texture_height(),
+  m_image_width(),
+  m_image_height()
 {
 #ifdef GL_VERSION_ES_CM_1_0
-  texture_width = next_power_of_two(image->w);
-  texture_height = next_power_of_two(image->h);
+  m_texture_width = next_power_of_two(image->w);
+  m_texture_height = next_power_of_two(image->h);
 #else
   if (GLEW_ARB_texture_non_power_of_two)
   {
-    texture_width  = image->w;
-    texture_height = image->h;
+    m_texture_width  = image->w;
+    m_texture_height = image->h;
   }
   else
   {
-    texture_width = next_power_of_two(image->w);
-    texture_height = next_power_of_two(image->h);
+    m_texture_width = next_power_of_two(image->w);
+    m_texture_height = next_power_of_two(image->h);
   }
 #endif
 
-  image_width  = image->w;
-  image_height = image->h;
+  m_image_width  = image->w;
+  m_image_height = image->h;
 
 #if SDL_BYTEORDER == SDL_BIG_ENDIAN
   SDL_Surface* convert = SDL_CreateRGBSurface(0,
-                                              texture_width, texture_height, 32,
+                                              m_texture_width, m_texture_height, 32,
                                               0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff);
 #else
   SDL_Surface* convert = SDL_CreateRGBSurface(0,
-                                              texture_width, texture_height, 32,
+                                              m_texture_width, m_texture_height, 32,
                                               0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000);
 #endif
 
@@ -110,7 +111,7 @@ GLTexture::GLTexture(SDL_Surface* image) :
   SDL_BlitSurface(image, 0, convert, 0);
 
   assert_gl("before creating texture");
-  glGenTextures(1, &handle);
+  glGenTextures(1, &m_handle);
 
   try {
     GLenum sdl_format;
@@ -123,7 +124,7 @@ GLTexture::GLTexture(SDL_Surface* image) :
       assert(false);
     }
 
-    glBindTexture(GL_TEXTURE_2D, handle);
+    glBindTexture(GL_TEXTURE_2D, m_handle);
     glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
 #ifdef GL_UNPACK_ROW_LENGTH
     glPixelStorei(GL_UNPACK_ROW_LENGTH, convert->pitch/convert->format->BytesPerPixel);
@@ -138,8 +139,8 @@ GLTexture::GLTexture(SDL_Surface* image) :
       SDL_LockSurface(convert);
     }
 
-    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, texture_width,
-                 texture_height, 0, sdl_format,
+    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 
+                 m_texture_width, m_texture_height, 0, sdl_format,
                  GL_UNSIGNED_BYTE, convert->pixels);
 
     // no not use mipmaps
@@ -157,7 +158,7 @@ GLTexture::GLTexture(SDL_Surface* image) :
 
     set_texture_params();
   } catch(...) {
-    glDeleteTextures(1, &handle);
+    glDeleteTextures(1, &m_handle);
     SDL_FreeSurface(convert);
     throw;
   }
@@ -166,7 +167,7 @@ GLTexture::GLTexture(SDL_Surface* image) :
 
 GLTexture::~GLTexture()
 {
-  glDeleteTextures(1, &handle);
+  glDeleteTextures(1, &m_handle);
 }
 
 void
index 4b24d48..7cb634f 100644 (file)
 class GLTexture : public Texture
 {
 protected:
-  GLuint handle;
-  unsigned int texture_width;
-  unsigned int texture_height;
-  unsigned int image_width;
-  unsigned int image_height;
+  GLuint m_handle;
+  unsigned int m_texture_width;
+  unsigned int m_texture_height;
+  unsigned int m_image_width;
+  unsigned int m_image_height;
 
 public:
   GLTexture(unsigned int width, unsigned int height);
@@ -39,41 +39,41 @@ public:
   ~GLTexture();
 
   const GLuint &get_handle() const {
-    return handle;
+    return m_handle;
   }
 
   void set_handle(GLuint handle) {
-    this->handle = handle;
+    m_handle = handle;
   }
 
   unsigned int get_texture_width() const
   {
-    return texture_width;
+    return m_texture_width;
   }
 
   unsigned int get_texture_height() const
   {
-    return texture_height;
+    return m_texture_height;
   }
 
   unsigned int get_image_width() const
   {
-    return image_width;
+    return m_image_width;
   }
 
   unsigned int get_image_height() const
   {
-    return image_height;
+    return m_image_height;
   }
 
   void set_image_width(unsigned int width)
   {
-    image_width = width;
+    m_image_width = width;
   }
 
   void set_image_height(unsigned int height)
   {
-    image_height = height;
+    m_image_height = height;
   }
 
 private: