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
- };
+ 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[] = {
Lightmap::~Lightmap()
{
- texture_manager->remove_texture(lightmap);
+ if(texture_manager){
+ texture_manager->remove_texture(lightmap);
+ }
delete lightmap;
}
glViewport(0, screen->h - lightmap_height, lightmap_width, lightmap_height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
+#ifdef GL_VERSION_ES_CM_1_0
+ glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
+#else
glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
+#endif
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glViewport(0, 0, screen->w, screen->h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
+#ifdef GL_VERSION_ES_CM_1_0
+ glOrthof(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
+#else
glOrtho(0, SCREEN_WIDTH, SCREEN_HEIGHT, 0, -1.0, 1.0);
+#endif
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_BLEND);
glBlendFunc(GL_DST_COLOR, GL_ZERO);
glBindTexture(GL_TEXTURE_2D, texture->get_handle());
- glBegin(GL_QUADS);
-
- glTexCoord2f(0, lightmap_uv_bottom);
- glVertex2f(0, 0);
- glTexCoord2f(lightmap_uv_right, lightmap_uv_bottom);
- glVertex2f(SCREEN_WIDTH, 0);
-
- glTexCoord2f(lightmap_uv_right, 0);
- glVertex2f(SCREEN_WIDTH, SCREEN_HEIGHT);
+ float vertices[] = {
+ 0, 0,
+ SCREEN_WIDTH, 0,
+ SCREEN_WIDTH, SCREEN_HEIGHT,
+ 0, SCREEN_HEIGHT
+ };
+ glVertexPointer(2, GL_FLOAT, 0, vertices);
- glTexCoord2f(0, 0);
- glVertex2f(0, SCREEN_HEIGHT);
+ float uvs[] = {
+ 0, lightmap_uv_bottom,
+ lightmap_uv_right, lightmap_uv_bottom,
+ lightmap_uv_right, 0,
+ 0, 0
+ };
+ glTexCoordPointer(2, GL_FLOAT, 0, uvs);
- glEnd();
+ glDrawArrays(GL_TRIANGLE_FAN, 0, 4);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}