From 7a36481e6e7475ef7dbc7ea60298168b756d5843 Mon Sep 17 00:00:00 2001 From: Ingo Ruhnke Date: Sun, 17 Aug 2014 04:33:06 +0200 Subject: [PATCH] Added some m_ prefixes to member variables in SDLRenderer and related classes --- src/video/sdl/sdl_lightmap.cpp | 75 +++++++++++++++++++------------------- src/video/sdl/sdl_lightmap.hpp | 10 +++--- src/video/sdl/sdl_renderer.cpp | 82 +++++++++++++++++++++--------------------- src/video/sdl/sdl_renderer.hpp | 12 +++---- src/video/sdl/sdl_texture.cpp | 19 +++++----- src/video/sdl/sdl_texture.hpp | 16 ++++----- 6 files changed, 106 insertions(+), 108 deletions(-) diff --git a/src/video/sdl/sdl_lightmap.cpp b/src/video/sdl/sdl_lightmap.cpp index e27e18634..19ca449e3 100644 --- a/src/video/sdl/sdl_lightmap.cpp +++ b/src/video/sdl/sdl_lightmap.cpp @@ -23,24 +23,23 @@ #include "video/sdl/sdl_painter.hpp" SDLLightmap::SDLLightmap() : - renderer(static_cast(Renderer::instance())->get_sdl_renderer()), - texture(), - width(), - height(), - LIGHTMAP_DIV() + m_renderer(static_cast(Renderer::instance())->get_sdl_renderer()), + m_texture(), + m_width(), + m_height(), + m_LIGHTMAP_DIV() { - LIGHTMAP_DIV = 8; - - width = SCREEN_WIDTH; - height = SCREEN_HEIGHT; - - SDL_Renderer* renderer = static_cast(Renderer::instance())->get_sdl_renderer(); - texture = SDL_CreateTexture(renderer, - SDL_PIXELFORMAT_RGB888, - SDL_TEXTUREACCESS_TARGET, - width / LIGHTMAP_DIV, - height / LIGHTMAP_DIV); - if (!texture) + m_LIGHTMAP_DIV = 8; + + m_width = SCREEN_WIDTH; + m_height = SCREEN_HEIGHT; + + m_texture = SDL_CreateTexture(m_renderer, + SDL_PIXELFORMAT_RGB888, + SDL_TEXTUREACCESS_TARGET, + m_width / m_LIGHTMAP_DIV, + m_height / m_LIGHTMAP_DIV); + if (!m_texture) { std::stringstream msg; msg << "Couldn't create lightmap texture: " << SDL_GetError(); @@ -50,83 +49,83 @@ SDLLightmap::SDLLightmap() : SDLLightmap::~SDLLightmap() { - SDL_DestroyTexture(texture); + SDL_DestroyTexture(m_texture); } void SDLLightmap::start_draw(const Color &ambient_color) { - SDL_SetRenderTarget(renderer, texture); + SDL_SetRenderTarget(m_renderer, m_texture); Uint8 r = static_cast(ambient_color.red * 255); Uint8 g = static_cast(ambient_color.green * 255); Uint8 b = static_cast(ambient_color.blue * 255); - SDL_SetRenderDrawColor(renderer, r, g, b, 255); - SDL_RenderClear(renderer); - SDL_RenderSetScale(renderer, 1.0f / LIGHTMAP_DIV, 1.0f / LIGHTMAP_DIV); + SDL_SetRenderDrawColor(m_renderer, r, g, b, 255); + SDL_RenderClear(m_renderer); + SDL_RenderSetScale(m_renderer, 1.0f / m_LIGHTMAP_DIV, 1.0f / m_LIGHTMAP_DIV); } void SDLLightmap::end_draw() { - SDL_RenderSetScale(renderer, 1.0f, 1.0f); - SDL_SetRenderTarget(renderer, NULL); + SDL_RenderSetScale(m_renderer, 1.0f, 1.0f); + SDL_SetRenderTarget(m_renderer, NULL); } void SDLLightmap::do_draw() { - SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_MOD); + SDL_SetTextureBlendMode(m_texture, SDL_BLENDMODE_MOD); SDL_Rect dst_rect; dst_rect.x = 0; dst_rect.y = 0; - dst_rect.w = width; - dst_rect.h = height; + dst_rect.w = m_width; + dst_rect.h = m_height; - SDL_RenderCopy(renderer, texture, NULL, &dst_rect); + SDL_RenderCopy(m_renderer, m_texture, NULL, &dst_rect); } void SDLLightmap::draw_surface(const DrawingRequest& request) { - SDLPainter::draw_surface(renderer, request); + SDLPainter::draw_surface(m_renderer, request); } void SDLLightmap::draw_surface_part(const DrawingRequest& request) { - SDLPainter::draw_surface_part(renderer, request); + SDLPainter::draw_surface_part(m_renderer, request); } void SDLLightmap::draw_gradient(const DrawingRequest& request) { - SDLPainter::draw_gradient(renderer, request); + SDLPainter::draw_gradient(m_renderer, request); } void SDLLightmap::draw_filled_rect(const DrawingRequest& request) { - SDLPainter::draw_filled_rect(renderer, request); + SDLPainter::draw_filled_rect(m_renderer, request); } void SDLLightmap::get_light(const DrawingRequest& request) const { const GetLightRequest* getlightrequest - = (GetLightRequest*) request.request_data; + = static_cast(request.request_data); SDL_Rect rect; - rect.x = static_cast(request.pos.x * width / SCREEN_WIDTH); - rect.y = static_cast(request.pos.y * height / SCREEN_HEIGHT); + rect.x = static_cast(request.pos.x * m_width / SCREEN_WIDTH); + rect.y = static_cast(request.pos.y * m_height / SCREEN_HEIGHT); rect.w = 1; rect.h = 1; - SDL_SetRenderTarget(renderer, texture); + SDL_SetRenderTarget(m_renderer, m_texture); Uint8 pixel[4]; - int ret = SDL_RenderReadPixels(renderer, &rect, + int ret = SDL_RenderReadPixels(m_renderer, &rect, SDL_PIXELFORMAT_RGB888, pixel, 1); @@ -134,7 +133,7 @@ SDLLightmap::get_light(const DrawingRequest& request) const { log_warning << "failed to read pixels: " << SDL_GetError() << std::endl; } - SDL_SetRenderTarget(renderer, 0); + SDL_SetRenderTarget(m_renderer, 0); *(getlightrequest->color_ptr) = Color(pixel[2] / 255.0f, pixel[1] / 255.0f, diff --git a/src/video/sdl/sdl_lightmap.hpp b/src/video/sdl/sdl_lightmap.hpp index df451be4a..e13b61c63 100644 --- a/src/video/sdl/sdl_lightmap.hpp +++ b/src/video/sdl/sdl_lightmap.hpp @@ -42,11 +42,11 @@ public: void get_light(const DrawingRequest& request) const; private: - SDL_Renderer* renderer; - SDL_Texture* texture; - int width; - int height; - int LIGHTMAP_DIV; + SDL_Renderer* m_renderer; + SDL_Texture* m_texture; + int m_width; + int m_height; + int m_LIGHTMAP_DIV; private: SDLLightmap(const SDLLightmap&); diff --git a/src/video/sdl/sdl_renderer.cpp b/src/video/sdl/sdl_renderer.cpp index 86c85f775..72ef39d01 100644 --- a/src/video/sdl/sdl_renderer.cpp +++ b/src/video/sdl/sdl_renderer.cpp @@ -33,10 +33,10 @@ #include "video/util.hpp" SDLRenderer::SDLRenderer() : - window(), - renderer(), - viewport(), - desktop_size(0, 0), + m_window(), + m_renderer(), + m_viewport(), + m_desktop_size(0, 0), m_scale(1.0f, 1.0f) { Renderer::instance_ = this; @@ -48,7 +48,7 @@ SDLRenderer::SDLRenderer() : } else { - desktop_size = Size(mode.w, mode.h); + m_desktop_size = Size(mode.w, mode.h); } log_info << "creating SDLRenderer" << std::endl; @@ -75,15 +75,15 @@ SDLRenderer::SDLRenderer() : SCREEN_WIDTH = width; SCREEN_HEIGHT = height; - viewport.x = 0; - viewport.y = 0; - viewport.w = width; - viewport.h = height; + m_viewport.x = 0; + m_viewport.y = 0; + m_viewport.w = width; + m_viewport.h = height; SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, "2"); int ret = SDL_CreateWindowAndRenderer(width, height, flags, - &window, &renderer); + &m_window, &m_renderer); if(ret != 0) { std::stringstream msg; @@ -93,7 +93,7 @@ SDLRenderer::SDLRenderer() : } SDL_RendererInfo info; - if (SDL_GetRendererInfo(renderer, &info) != 0) + if (SDL_GetRendererInfo(m_renderer, &info) != 0) { log_warning << "Couldn't get RendererInfo: " << SDL_GetError() << std::endl; } @@ -123,14 +123,14 @@ SDLRenderer::SDLRenderer() : SDLRenderer::~SDLRenderer() { - SDL_DestroyRenderer(renderer); - SDL_DestroyWindow(window); + SDL_DestroyRenderer(m_renderer); + SDL_DestroyWindow(m_window); } void SDLRenderer::start_draw() { - SDL_RenderSetScale(renderer, m_scale.x, m_scale.y); + SDL_RenderSetScale(m_renderer, m_scale.x, m_scale.y); } void @@ -141,31 +141,31 @@ SDLRenderer::end_draw() void SDLRenderer::draw_surface(const DrawingRequest& request) { - SDLPainter::draw_surface(renderer, request); + SDLPainter::draw_surface(m_renderer, request); } void SDLRenderer::draw_surface_part(const DrawingRequest& request) { - SDLPainter::draw_surface_part(renderer, request); + SDLPainter::draw_surface_part(m_renderer, request); } void SDLRenderer::draw_gradient(const DrawingRequest& request) { - SDLPainter::draw_gradient(renderer, request); + SDLPainter::draw_gradient(m_renderer, request); } void SDLRenderer::draw_filled_rect(const DrawingRequest& request) { - SDLPainter::draw_filled_rect(renderer, request); + SDLPainter::draw_filled_rect(m_renderer, request); } void SDLRenderer::draw_inverse_ellipse(const DrawingRequest& request) { - SDLPainter::draw_inverse_ellipse(renderer, request); + SDLPainter::draw_inverse_ellipse(m_renderer, request); } void @@ -174,7 +174,7 @@ SDLRenderer::do_take_screenshot() // [Christoph] TODO: Yes, this method also takes care of the actual disk I/O. Split it? int width; int height; - if (SDL_GetRendererOutputSize(renderer, &width, &height) != 0) + if (SDL_GetRendererOutputSize(m_renderer, &width, &height) != 0) { log_warning << "SDL_GetRenderOutputSize failed: " << SDL_GetError() << std::endl; } @@ -199,7 +199,7 @@ SDLRenderer::do_take_screenshot() } else { - int ret = SDL_RenderReadPixels(renderer, NULL, + int ret = SDL_RenderReadPixels(m_renderer, NULL, SDL_PIXELFORMAT_ABGR8888, surface->pixels, surface->pitch); @@ -237,7 +237,7 @@ SDLRenderer::do_take_screenshot() void SDLRenderer::flip() { - SDL_RenderPresent(renderer); + SDL_RenderPresent(m_renderer); } void @@ -253,14 +253,14 @@ SDLRenderer::apply_video_mode() { 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; @@ -279,7 +279,7 @@ SDLRenderer::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 << ": " @@ -287,7 +287,7 @@ SDLRenderer::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 << ": " @@ -313,12 +313,12 @@ SDLRenderer::apply_viewport() 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); } @@ -331,27 +331,27 @@ SDLRenderer::apply_viewport() target_size, pixel_aspect_ratio, g_config->magnification, - m_scale, logical_size, viewport); + m_scale, logical_size, 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 the screen to avoid garbage in unreachable areas after we // reset the coordinate system - SDL_SetRenderDrawColor(renderer, 0, 0, 0, 255); - SDL_SetRenderDrawBlendMode(renderer, SDL_BLENDMODE_NONE); - SDL_RenderClear(renderer); - SDL_RenderPresent(renderer); - SDL_RenderClear(renderer); + SDL_SetRenderDrawColor(m_renderer, 0, 0, 0, 255); + SDL_SetRenderDrawBlendMode(m_renderer, SDL_BLENDMODE_NONE); + SDL_RenderClear(m_renderer); + SDL_RenderPresent(m_renderer); + SDL_RenderClear(m_renderer); } // SetViewport() works in scaled screen coordinates, so we have to // reset it to 1.0, 1.0 to get meaningful results - SDL_RenderSetScale(renderer, 1.0f, 1.0f); - SDL_RenderSetViewport(renderer, &viewport); - SDL_RenderSetScale(renderer, m_scale.x, m_scale.y); + SDL_RenderSetScale(m_renderer, 1.0f, 1.0f); + SDL_RenderSetViewport(m_renderer, &m_viewport); + SDL_RenderSetScale(m_renderer, m_scale.x, m_scale.y); } void @@ -364,8 +364,8 @@ SDLRenderer::apply_config() Vector SDLRenderer::to_logical(int physical_x, int physical_y) { - return Vector(static_cast(physical_x - viewport.x) * SCREEN_WIDTH / viewport.w, - static_cast(physical_y - viewport.y) * SCREEN_HEIGHT / viewport.h); + return Vector(static_cast(physical_x - m_viewport.x) * SCREEN_WIDTH / m_viewport.w, + static_cast(physical_y - m_viewport.y) * SCREEN_HEIGHT / m_viewport.h); } void @@ -373,7 +373,7 @@ SDLRenderer::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 */ diff --git a/src/video/sdl/sdl_renderer.hpp b/src/video/sdl/sdl_renderer.hpp index 2ce622b53..fa3cd0a7d 100644 --- a/src/video/sdl/sdl_renderer.hpp +++ b/src/video/sdl/sdl_renderer.hpp @@ -40,18 +40,18 @@ 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_Renderer* get_sdl_renderer() const { return renderer; }; + SDL_Window* get_window() const { return m_window; } + SDL_Renderer* get_sdl_renderer() const { return m_renderer; }; private: void apply_video_mode(); void apply_viewport(); private: - SDL_Window* window; - SDL_Renderer* renderer; - SDL_Rect viewport; - Size desktop_size; + SDL_Window* m_window; + SDL_Renderer* m_renderer; + SDL_Rect m_viewport; + Size m_desktop_size; Vector m_scale; private: diff --git a/src/video/sdl/sdl_texture.cpp b/src/video/sdl/sdl_texture.cpp index 853bef2bf..fcb8d73c8 100644 --- a/src/video/sdl/sdl_texture.cpp +++ b/src/video/sdl/sdl_texture.cpp @@ -29,27 +29,26 @@ #include SDLTexture::SDLTexture(SDL_Surface* image) : - texture(), - width(), - height() + m_texture(), + m_width(), + m_height() { - texture = SDL_CreateTextureFromSurface(static_cast(Renderer::instance())->get_sdl_renderer(), - image); - if (!texture) + m_texture = SDL_CreateTextureFromSurface(static_cast(Renderer::instance())->get_sdl_renderer(), + image); + if (!m_texture) { std::ostringstream msg; msg << "couldn't create texture: " << SDL_GetError(); throw std::runtime_error(msg.str()); } - width = image->w; - height = image->h; + m_width = image->w; + m_height = image->h; } SDLTexture::~SDLTexture() { - SDL_DestroyTexture(texture); + SDL_DestroyTexture(m_texture); } -/* vim: set sw=2 sts=2 et : */ /* EOF */ diff --git a/src/video/sdl/sdl_texture.hpp b/src/video/sdl/sdl_texture.hpp index e92c31618..7673800de 100644 --- a/src/video/sdl/sdl_texture.hpp +++ b/src/video/sdl/sdl_texture.hpp @@ -28,9 +28,9 @@ class SDLTexture : public Texture { protected: - SDL_Texture* texture; - int width; - int height; + SDL_Texture* m_texture; + int m_width; + int m_height; public: SDLTexture(SDL_Surface* sdlsurface); @@ -38,27 +38,27 @@ public: SDL_Texture *get_texture() const { - return texture; + return m_texture; } unsigned int get_texture_width() const { - return width; + return m_width; } unsigned int get_texture_height() const { - return height; + return m_height; } unsigned int get_image_width() const { - return width; + return m_width; } unsigned int get_image_height() const { - return height; + return m_height; } private: -- 2.11.0