X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fvideo%2Fdrawing_context.hpp;h=53e171aeedaa245f641b708e35638a3198e64ed7;hb=9eab9403c2b9ff629c07380e8d5f1032d21bd3f7;hp=13f28c94bfe95dd529cd4324328951b4408b456b;hpb=565c5387c0c8c2ee2e9e223b03973e6c114c7db1;p=supertux.git diff --git a/src/video/drawing_context.hpp b/src/video/drawing_context.hpp index 13f28c94b..53e171aee 100644 --- a/src/video/drawing_context.hpp +++ b/src/video/drawing_context.hpp @@ -26,24 +26,59 @@ #include "math/rectf.hpp" #include "math/vector.hpp" #include "video/color.hpp" -#include "video/drawing_request.hpp" #include "video/font.hpp" #include "video/font_ptr.hpp" #include "video/texture.hpp" +struct DrawingRequest; class Surface; class Texture; -class Renderer; -class Lightmap; +class VideoSystem; + +// some constants for predefined layer values +enum { + // Image/gradient backgrounds (should cover entire screen) + LAYER_BACKGROUND0 = -300, + // Particle backgrounds + LAYER_BACKGROUND1 = -200, + // Tilemap backgrounds + LAYER_BACKGROUNDTILES = -100, + // Solid tilemaps + LAYER_TILES = 0, + // Ordinary objects + LAYER_OBJECTS = 50, + // Objects that pass through walls + LAYER_FLOATINGOBJECTS = 150, + // + LAYER_FOREGROUNDTILES = 200, + // + LAYER_FOREGROUND0 = 300, + // + LAYER_FOREGROUND1 = 400, + // Hitpoints, time, coins, etc. + LAYER_HUD = 500, + // Menus, mouse, console etc. + LAYER_GUI = 600 +}; -inline int next_po2(int val) +class Blend { - int result = 1; - while(result < val) - result *= 2; +public: + GLenum sfactor; + GLenum dfactor; - return result; -} + Blend() + : sfactor(GL_SRC_ALPHA), dfactor(GL_ONE_MINUS_SRC_ALPHA) + {} + + Blend(GLenum s, GLenum d) + : sfactor(s), dfactor(d) + {} +}; + +enum Target { + NORMAL, LIGHTMAP +}; /** * This class provides functions for drawing things on screen. It also @@ -52,7 +87,7 @@ inline int next_po2(int val) class DrawingContext { public: - DrawingContext(Renderer& renderer, Lightmap& lightmap); + DrawingContext(VideoSystem& video_system); ~DrawingContext(); /// Adds a drawing request for a surface into the request list. @@ -63,8 +98,9 @@ public: float angle, const Color& color, const Blend& blend, int layer); /// Adds a drawing request for part of a surface. - void draw_surface_part(SurfacePtr surface, const Vector& source, - const Vector& size, const Vector& dest, int layer); + void draw_surface_part(SurfacePtr surface, + const Rectf& srcrect, const Rectf& dstrect, + int layer); /// Draws a text. void draw_text(FontPtr font, const std::string& text, const Vector& position, FontAlignment alignment, int layer, Color color = Color(1.0,1.0,1.0)); @@ -141,7 +177,7 @@ private: Transform() : translation(), - drawing_effect(NO_EFFECT), + drawing_effect(NO_EFFECT), alpha(1.0f) { } @@ -151,9 +187,10 @@ private: } }; + void clear_drawing_requests(DrawingRequests& requests); + private: - Renderer& renderer; - Lightmap& lightmap; + VideoSystem& video_system; /// the transform stack std::vector transformstack;