#include "math/size.hpp"
#include "video/drawing_request.hpp"
#include "video/renderer.hpp"
#include <math.h>
Go to the source code of this file.
Classes | |
class | GLRenderer |
Functions | |
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) |
void @512::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 | |||
) | [inline, static] |
Definition at line 28 of file gl_renderer.hpp.
References Color::alpha, Color::blue, Blend::dfactor, GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA, Color::green, HORIZONTAL_FLIP, Color::red, Blend::sfactor, and VERTICAL_FLIP.
Referenced by GLRenderer::draw_surface(), GLLightmap::draw_surface(), GLRenderer::draw_surface_part(), and GLLightmap::draw_surface_part().
00035 { 00036 if(effect & HORIZONTAL_FLIP) 00037 std::swap(uv_left, uv_right); 00038 00039 if(effect & VERTICAL_FLIP) 00040 std::swap(uv_top, uv_bottom); 00041 00042 glBlendFunc(blend.sfactor, blend.dfactor); 00043 glColor4f(color.red, color.green, color.blue, color.alpha * alpha); 00044 00045 // unrotated blit 00046 if (angle == 0.0f) { 00047 float vertices[] = { 00048 left, top, 00049 right, top, 00050 right, bottom, 00051 left, bottom, 00052 }; 00053 glVertexPointer(2, GL_FLOAT, 0, vertices); 00054 00055 float uvs[] = { 00056 uv_left, uv_top, 00057 uv_right, uv_top, 00058 uv_right, uv_bottom, 00059 uv_left, uv_bottom, 00060 }; 00061 glTexCoordPointer(2, GL_FLOAT, 0, uvs); 00062 00063 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); 00064 } else { 00065 // rotated blit 00066 float center_x = (left + right) / 2; 00067 float center_y = (top + bottom) / 2; 00068 00069 float sa = sinf(angle/180.0f*M_PI); 00070 float ca = cosf(angle/180.0f*M_PI); 00071 00072 left -= center_x; 00073 right -= center_x; 00074 00075 top -= center_y; 00076 bottom -= center_y; 00077 00078 float vertices[] = { 00079 left*ca - top*sa + center_x, left*sa + top*ca + center_y, 00080 right*ca - top*sa + center_x, right*sa + top*ca + center_y, 00081 right*ca - bottom*sa + center_x, right*sa + bottom*ca + center_y, 00082 left*ca - bottom*sa + center_x, left*sa + bottom*ca + center_y 00083 }; 00084 glVertexPointer(2, GL_FLOAT, 0, vertices); 00085 00086 float uvs[] = { 00087 uv_left, uv_top, 00088 uv_right, uv_top, 00089 uv_right, uv_bottom, 00090 uv_left, uv_bottom, 00091 }; 00092 glTexCoordPointer(2, GL_FLOAT, 0, uvs); 00093 00094 glDrawArrays(GL_TRIANGLE_FAN, 0, 4); 00095 } 00096 00097 // FIXME: find a better way to restore the blend mode 00098 glColor4f(1.0f, 1.0f, 1.0f, 1.0f); 00099 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 00100 }