request->layer = LAYER_HUD - 1;
drawing_requests.push_back(request);
}
+ renderer.start_draw();
handle_drawing_requests(drawing_requests);
+ renderer.end_draw();
clear_drawing_requests(lightmap_requests);
clear_drawing_requests(drawing_requests);
}
void
+GLRenderer::start_draw()
+{
+}
+
+void
+GLRenderer::end_draw()
+{
+}
+
+void
GLRenderer::draw_surface(const DrawingRequest& request)
{
GLPainter::draw_surface(request);
GLRenderer();
~GLRenderer();
- void draw_surface(const DrawingRequest& request);
- void draw_surface_part(const DrawingRequest& request);
- void draw_gradient(const DrawingRequest& request);
- void draw_filled_rect(const DrawingRequest& request);
- void draw_inverse_ellipse(const DrawingRequest& request);
- void do_take_screenshot();
- void flip();
- void resize(int w, int h);
- void apply_config();
- void apply_video_mode();
- Vector to_logical(int physical_x, int physical_y);
- void set_gamma(float gamma);
+ void start_draw() override;
+ void end_draw() override;
+ void draw_surface(const DrawingRequest& request) override;
+ void draw_surface_part(const DrawingRequest& request) override;
+ void draw_gradient(const DrawingRequest& request) override;
+ void draw_filled_rect(const DrawingRequest& request) override;
+ void draw_inverse_ellipse(const DrawingRequest& request) override;
+ void do_take_screenshot() override;
+ void flip() override;
+ void resize(int w, int h) override;
+ void apply_config() override;
+ Vector to_logical(int physical_x, int physical_y) override;
+ void set_gamma(float gamma) override;
+
SDL_Window* get_window() const { return window; }
private:
+ void apply_video_mode();
+
+private:
GLRenderer(const GLRenderer&) = delete;
GLRenderer& operator=(const GLRenderer&) = delete;
};
Renderer();
virtual ~Renderer();
+ virtual void start_draw() = 0;
+ virtual void end_draw() = 0;
virtual void draw_surface(const DrawingRequest& request) = 0;
virtual void draw_surface_part(const DrawingRequest& request) = 0;
virtual void draw_gradient(const DrawingRequest& request) = 0;
window(),
renderer(),
viewport(),
- desktop_size(0, 0)
+ desktop_size(0, 0),
+ m_scale(1.0f, 1.0f)
{
Renderer::instance_ = this;
}
void
+SDLRenderer::start_draw()
+{
+ SDL_RenderSetScale(renderer, m_scale.x, m_scale.y);
+}
+
+void
+SDLRenderer::end_draw()
+{
+}
+
+void
SDLRenderer::draw_surface(const DrawingRequest& request)
{
SDLPainter::draw_surface(renderer, request);
Size max_size(1280, 800);
Size min_size(640, 480);
- Vector scale;
Size logical_size;
calculate_viewport(min_size, max_size,
target_size,
pixel_aspect_ratio,
g_config->magnification,
- scale, logical_size, viewport);
+ m_scale, logical_size, viewport);
SCREEN_WIDTH = logical_size.width;
SCREEN_HEIGHT = logical_size.height;
SDL_RenderClear(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, scale.x, scale.y);
+ SDL_RenderSetScale(renderer, m_scale.x, m_scale.y);
}
void
SDLRenderer();
~SDLRenderer();
- void draw_surface(const DrawingRequest& request);
- void draw_surface_part(const DrawingRequest& request);
- void draw_gradient(const DrawingRequest& request);
- void draw_filled_rect(const DrawingRequest& request);
- void draw_inverse_ellipse(const DrawingRequest& request);
- void do_take_screenshot();
- void flip();
- void resize(int w, int h);
- void apply_config();
- Vector to_logical(int physical_x, int physical_y);
- void set_gamma(float gamma);
+ void start_draw() override;
+ void end_draw() override;
+ void draw_surface(const DrawingRequest& request) override;
+ void draw_surface_part(const DrawingRequest& request) override;
+ void draw_gradient(const DrawingRequest& request) override;
+ void draw_filled_rect(const DrawingRequest& request) override;
+ void draw_inverse_ellipse(const DrawingRequest& request) override;
+ void do_take_screenshot() override;
+ void flip() override;
+ void resize(int w, int h) override;
+ void apply_config() override;
+ 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_Renderer* renderer;
SDL_Rect viewport;
Size desktop_size;
+ Vector m_scale;
private:
SDLRenderer(const SDLRenderer&);