// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
+#include "video/drawing_context.hpp"
+
#include <algorithm>
#include <config.h>
-#include "video/drawing_context.hpp"
-
+#include "math/sizef.hpp"
#include "supertux/gameconfig.hpp"
#include "supertux/globals.hpp"
#include "util/obstackpp.hpp"
#include "video/texture_manager.hpp"
#include "video/video_systems.hpp"
-static inline int next_po2(int val)
-{
- int result = 1;
- while(result < val)
- result *= 2;
-
- return result;
-}
-
DrawingContext::DrawingContext() :
renderer(0),
lightmap(0),
delete renderer;
delete lightmap;
- renderer = new_renderer();
- lightmap = new_lightmap();
+ renderer = VideoSystem::new_renderer();
+ lightmap = VideoSystem::new_lightmap();
}
void
-DrawingContext::draw_surface(const Surface* surface, const Vector& position,
+DrawingContext::draw_surface(SurfacePtr surface, const Vector& position,
float angle, const Color& color, const Blend& blend,
int layer)
{
request->color = color;
request->blend = blend;
- request->request_data = const_cast<Surface*> (surface);
+ request->request_data = surface.get();
requests->push_back(request);
}
void
-DrawingContext::draw_surface(const Surface* surface, const Vector& position,
+DrawingContext::draw_surface(SurfacePtr surface, const Vector& position,
int layer)
{
draw_surface(surface, position, 0.0f, Color(1.0f, 1.0f, 1.0f), Blend(), layer);
}
void
-DrawingContext::draw_surface_part(const Surface* surface, const Vector& source,
+DrawingContext::draw_surface_part(SurfacePtr surface, const Vector& source,
const Vector& size, const Vector& dest, int layer)
{
assert(surface != 0);
SurfacePartRequest* surfacepartrequest = new(obst) SurfacePartRequest();
surfacepartrequest->size = size;
surfacepartrequest->source = source;
- surfacepartrequest->surface = surface;
+ surfacepartrequest->surface = surface.get();
// clip on screen borders
if(request->pos.x < 0) {
}
void
-DrawingContext::draw_text(const Font* font, const std::string& text,
+DrawingContext::draw_text(FontPtr font, const std::string& text,
const Vector& position, FontAlignment alignment, int layer, Color color)
{
DrawingRequest* request = new(obst) DrawingRequest();
request->color = color;
TextRequest* textrequest = new(obst) TextRequest();
- textrequest->font = font;
+ textrequest->font = font.get();
textrequest->text = text;
textrequest->alignment = alignment;
request->request_data = textrequest;
}
void
-DrawingContext::draw_center_text(const Font* font, const std::string& text,
+DrawingContext::draw_center_text(FontPtr font, const std::string& text,
const Vector& position, int layer, Color color)
{
draw_text(font, text, Vector(position.x + SCREEN_WIDTH/2, position.y),
requests->push_back(request);
}
+Rectf
+DrawingContext::get_cliprect() const
+{
+ return Rectf(get_translation().x, get_translation().y,
+ get_translation().x + SCREEN_WIDTH,
+ get_translation().y + SCREEN_HEIGHT);
+}
+
void
DrawingContext::get_light(const Vector& position, Color* color)
{