timelog("video");
std::unique_ptr<VideoSystem> video_system = VideoSystem::create(g_config->video);
- DrawingContext context(video_system->get_renderer(),
- video_system->get_lightmap());
+ DrawingContext context(*video_system);
init_video();
timelog("audio");
switch(event.window.event)
{
case SDL_WINDOWEVENT_RESIZED:
- VideoSystem::current()->get_renderer().resize(event.window.data1,
- event.window.data2);
+ VideoSystem::current()->resize(event.window.data1,
+ event.window.data2);
m_menu_manager->on_window_resize();
break;
}
else if (event.key.keysym.sym == SDLK_F11)
{
g_config->use_fullscreen = !g_config->use_fullscreen;
- VideoSystem::current()->get_renderer().apply_config();
+ VideoSystem::current()->apply_config();
m_menu_manager->on_window_resize();
}
else if (event.key.keysym.sym == SDLK_PRINTSCREEN ||
#include "video/texture_manager.hpp"
#include "video/video_system.hpp"
-DrawingContext::DrawingContext(Renderer& renderer_, Lightmap& lightmap_) :
- renderer(renderer_),
- lightmap(lightmap_),
+DrawingContext::DrawingContext(VideoSystem& video_system_) :
+ video_system(video_system_),
transformstack(),
transform(),
blend_stack(),
// PART1: create lightmap
if(use_lightmap) {
+ Lightmap& lightmap = video_system.get_lightmap();
+
lightmap.start_draw(ambient_color);
handle_drawing_requests(lightmap_requests);
lightmap.end_draw();
request->layer = LAYER_HUD - 1;
drawing_requests.push_back(request);
}
+
+ Renderer& renderer = video_system.get_renderer();
renderer.start_draw();
handle_drawing_requests(drawing_requests);
renderer.end_draw();
{
std::stable_sort(requests_.begin(), requests_.end(), RequestPtrCompare());
+ Renderer& renderer = video_system.get_renderer();
+ Lightmap& lightmap = video_system.get_lightmap();
+
DrawingRequests::const_iterator i;
for(i = requests_.begin(); i != requests_.end(); ++i) {
const DrawingRequest& request = **i;
#include "video/texture.hpp"
class DrawingRequest;
-class Lightmap;
-class Renderer;
class Surface;
class Texture;
+class VideoSystem;
// some constants for predefined layer values
enum {
class DrawingContext
{
public:
- DrawingContext(Renderer& renderer, Lightmap& lightmap);
+ DrawingContext(VideoSystem& video_system);
~DrawingContext();
/// Adds a drawing request for a surface into the request list.
void clear_drawing_requests(DrawingRequests& requests);
private:
- Renderer& renderer;
- Lightmap& lightmap;
+ VideoSystem& video_system;
/// the transform stack
std::vector<Transform> transformstack;
GLLightmap();
~GLLightmap();
- void start_draw(const Color &ambient_color);
- void end_draw();
- void do_draw();
- 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 get_light(const DrawingRequest& request) const;
+ void start_draw(const Color &ambient_color) override;
+ void end_draw() override;
+ void do_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 get_light(const DrawingRequest& request) const override;
private:
static const int s_LIGHTMAP_DIV = 5;
delete surface_data;
}
+void
+GLVideoSystem::apply_config()
+{
+ m_renderer->apply_config();
+}
+
+void
+GLVideoSystem::resize(int w, int h)
+{
+ m_renderer->resize(w, h);
+ m_lightmap.reset(new GLLightmap);
+}
+
/* EOF */
SurfaceData* new_surface_data(const Surface& surface) override;
void free_surface_data(SurfaceData* surface_data) override;
+ void apply_config() override;
+ void resize(int w, int h) override;
+
private:
GLVideoSystem(const GLVideoSystem&) = delete;
GLVideoSystem& operator=(const GLVideoSystem&) = delete;
virtual void draw_surface_part(const DrawingRequest& request) = 0;
virtual void draw_gradient(const DrawingRequest& request) = 0;
virtual void draw_filled_rect(const DrawingRequest& request) = 0;
+ virtual void draw_inverse_ellipse(const DrawingRequest& request) = 0;
virtual void get_light(const DrawingRequest& request) const = 0;
};
}
void
+SDLLightmap::draw_inverse_ellipse(const DrawingRequest& request)
+{
+ SDLPainter::draw_inverse_ellipse(m_renderer, request);
+}
+
+void
SDLLightmap::get_light(const DrawingRequest& request) const
{
const GetLightRequest* getlightrequest
SDLLightmap();
~SDLLightmap();
- void start_draw(const Color &ambient_color);
- void end_draw();
- void do_draw();
-
- 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 get_light(const DrawingRequest& request) const;
+ void start_draw(const Color &ambient_color) override;
+ void end_draw() override;
+ void do_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 get_light(const DrawingRequest& request) const override;
private:
SDL_Renderer* m_renderer;
delete surface_data;
}
+void
+SDLVideoSystem::apply_config()
+{
+ m_renderer->apply_config();
+}
+
+void
+SDLVideoSystem::resize(int w, int h)
+{
+ m_renderer->resize(w, h);
+ m_lightmap.reset(new SDLLightmap);
+}
+
/* EOF */
SurfaceData* new_surface_data(const Surface& surface) override;
void free_surface_data(SurfaceData* surface_data) override;
+ void apply_config() override;
+ void resize(int w, int h) override;
+
private:
SDLVideoSystem(const SDLVideoSystem&) = delete;
SDLVideoSystem& operator=(const SDLVideoSystem&) = delete;
virtual SurfaceData* new_surface_data(const Surface &surface) = 0;
virtual void free_surface_data(SurfaceData* surface_data) = 0;
+ virtual void apply_config() = 0;
+ virtual void resize(int w, int h) = 0;
+
private:
VideoSystem(const VideoSystem&) = delete;
VideoSystem& operator=(const VideoSystem&) = delete;