#include "glutil.hpp"
#include "gl_renderer.hpp"
#include "gl_texture.hpp"
+#include "gl_surface_data.hpp"
#include "drawing_context.hpp"
#include "drawing_request.hpp"
#include "surface.hpp"
{
const Surface* surface = (const Surface*) request.request_data;
GL::Texture *gltexture = dynamic_cast<GL::Texture *>(surface->get_texture());
+ GL::SurfaceData *surface_data = reinterpret_cast<GL::SurfaceData *>(surface->get_surface_data());
+
glBindTexture(GL_TEXTURE_2D, gltexture->get_handle());
intern_draw(request.pos.x, request.pos.y,
request.pos.x + surface->get_width(),
request.pos.y + surface->get_height(),
- surface->get_uv_left(),
- surface->get_uv_top(),
- surface->get_uv_right(),
- surface->get_uv_bottom(),
+ surface_data->get_uv_left(),
+ surface_data->get_uv_top(),
+ surface_data->get_uv_right(),
+ surface_data->get_uv_bottom(),
request.angle,
request.alpha,
request.color,
= (SurfacePartRequest*) request.request_data;
const Surface *surface = surfacepartrequest->surface;
GL::Texture *gltexture = dynamic_cast<GL::Texture *>(surface->get_texture());
+ GL::SurfaceData *surface_data = reinterpret_cast<GL::SurfaceData *>(surface->get_surface_data());
- float uv_width = surface->get_uv_right() - surface->get_uv_left();
- float uv_height = surface->get_uv_bottom() - surface->get_uv_top();
+ float uv_width = surface_data->get_uv_right() - surface_data->get_uv_left();
+ float uv_height = surface_data->get_uv_bottom() - surface_data->get_uv_top();
- float uv_left = surface->get_uv_left() + (uv_width * surfacepartrequest->source.x) / surface->get_width();
- float uv_top = surface->get_uv_top() + (uv_height * surfacepartrequest->source.y) / surface->get_height();
- float uv_right = surface->get_uv_left() + (uv_width * (surfacepartrequest->source.x + surfacepartrequest->size.x)) / surface->get_width();
- float uv_bottom = surface->get_uv_top() + (uv_height * (surfacepartrequest->source.y + surfacepartrequest->size.y)) / surface->get_height();
+ float uv_left = surface_data->get_uv_left() + (uv_width * surfacepartrequest->source.x) / surface->get_width();
+ float uv_top = surface_data->get_uv_top() + (uv_height * surfacepartrequest->source.y) / surface->get_height();
+ float uv_right = surface_data->get_uv_left() + (uv_width * (surfacepartrequest->source.x + surfacepartrequest->size.x)) / surface->get_width();
+ float uv_bottom = surface_data->get_uv_top() + (uv_height * (surfacepartrequest->source.y + surfacepartrequest->size.y)) / surface->get_height();
glBindTexture(GL_TEXTURE_2D, gltexture->get_handle());
intern_draw(request.pos.x, request.pos.y,
}
void
- Renderer::draw_text(const DrawingRequest& request)
- {
- const TextRequest* textrequest = (TextRequest*) request.request_data;
-
- textrequest->font->draw(this, textrequest->text, request.pos,
- textrequest->alignment, request.drawing_effect, request.alpha);
- }
-
- void
Renderer::draw_filled_rect(const DrawingRequest& request)
{
const FillRectRequest* fillrectrequest
// copy array line-by-line
for (int i = 0; i < SCREEN_HEIGHT; i++) {
char* src = pixels + (3 * SCREEN_WIDTH * (SCREEN_HEIGHT - i - 1));
+ if(SDL_MUSTLOCK(shot_surf))
+ {
+ SDL_LockSurface(shot_surf);
+ }
char* dst = ((char*)shot_surf->pixels) + i * shot_surf->pitch;
memcpy(dst, src, 3 * SCREEN_WIDTH);
+ if(SDL_MUSTLOCK(shot_surf))
+ {
+ SDL_UnlockSurface(shot_surf);
+ }
}
// free array