Make it build with -DCOMPILE_AMALGATION=ON. Still not certain how intern_draw/next_po...
[supertux.git] / src / video / gl / gl_lightmap.cpp
index 57b9730..30df72a 100644 (file)
@@ -33,6 +33,7 @@
 #include "video/drawing_request.hpp"
 #include "video/font.hpp"
 #include "video/gl/gl_surface_data.hpp"
+#include "video/gl/gl_renderer.hpp"
 #include "video/gl/gl_texture.hpp"
 #include "video/glutil.hpp"
 #include "video/lightmap.hpp"
 #include "video/surface.hpp"
 #include "video/texture_manager.hpp"
 
-namespace {
-
-inline void intern_draw(float left, float top, float right, float bottom,
-                        float uv_left, float uv_top,
-                        float uv_right, float uv_bottom,
-                        float angle, float alpha,
-                        const Color& color,
-                        const Blend& blend,
-                        DrawingEffect effect)
-{
-  if(effect & HORIZONTAL_FLIP)
-    std::swap(uv_left, uv_right);
-  if(effect & VERTICAL_FLIP) 
-    std::swap(uv_top, uv_bottom);
-
-  // unrotated blit
-  glBlendFunc(blend.sfactor, blend.dfactor);
-  glColor4f(color.red, color.green, color.blue, color.alpha * alpha);
-  if (angle == 0.0f) {
-    float vertices[] = {
-      left, top,
-      right, top,
-      right, bottom,
-      left, bottom,
-    };
-    glVertexPointer(2, GL_FLOAT, 0, vertices);
-
-    float uvs[] = {
-      uv_left, uv_top,
-      uv_right, uv_top,
-      uv_right, uv_bottom,
-      uv_left, uv_bottom,
-    };
-    glTexCoordPointer(2, GL_FLOAT, 0, uvs);
-
-    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-  } else {
-    // rotated blit
-    float center_x = (left + right) / 2;
-    float center_y = (top + bottom) / 2;
-
-    float sa = sinf(angle/180.0f*M_PI);
-    float ca = cosf(angle/180.0f*M_PI);
-
-    left  -= center_x;
-    right -= center_x;
-
-    top    -= center_y;
-    bottom -= center_y;
-
-    float vertices[] = {
-      left*ca - top*sa + center_x, left*sa + top*ca + center_y,
-      right*ca - top*sa + center_x, right*sa + top*ca + center_y,
-      right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y,
-      left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y
-    };
-    glVertexPointer(2, GL_FLOAT, 0, vertices);
-
-    float uvs[] = {
-      uv_left, uv_top,
-      uv_right, uv_top,
-      uv_right, uv_bottom,
-      uv_left, uv_bottom,
-    };
-    glTexCoordPointer(2, GL_FLOAT, 0, uvs);
-
-    glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
-  }
-
-  // FIXME: find a better way to restore the blend mode
-  glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-  glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-}
-
-static inline int next_po2(int val)
-{
-  int result = 1;
-  while(result < val)
-    result *= 2;
-
-  return result;
-}
-
-} // namespace
-
 GLLightmap::GLLightmap() :
   screen(),
   lightmap(),