Index: code/graphics/gropenglbmpman.cpp
===================================================================
--- code/graphics/gropenglbmpman.cpp (revision 8105)
+++ code/graphics/gropenglbmpman.cpp (working copy)
@@ -582,7 +582,11 @@
MIN(*width, *height) = MAX(*width, *height);
}
- Assert( is_power_of_two(*width, *height) );
+ // Only enforce power of two size if not supported
+ if (!(Is_Extension_Enabled(OGL_ARB_TEXTURE_NON_POWER_OF_TWO)))
+ {
+ Assert( is_power_of_two(*width, *height) );
+ }
if ( opengl_make_render_target(bm_bitmaps[n].handle, n, width, height, bpp, mm_lvl, flags) ) {
return 1;
Index: code/graphics/gropengldraw.cpp
===================================================================
--- code/graphics/gropengldraw.cpp (revision 8105)
+++ code/graphics/gropengldraw.cpp (working copy)
@@ -50,6 +50,9 @@
int Scene_texture_width;
int Scene_texture_height;
+GLfloat Scene_texture_u_scale = 1.0f;
+GLfloat Scene_texture_v_scale = 1.0f;
+
void gr_opengl_pixel(int x, int y, bool resize)
{
gr_line(x, y, x, y, resize);
@@ -2234,6 +2237,20 @@
vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, Scene_framebuffer);
+ if (GL_rendering_to_framebuffer)
+ {
+ Scene_texture_u_scale = i2fl(gr_screen.max_w) / i2fl(Scene_texture_width);
+ Scene_texture_v_scale = i2fl(gr_screen.max_h) / i2fl(Scene_texture_height);
+
+ CLAMP(Scene_texture_u_scale, 0.0f, 1.0f);
+ CLAMP(Scene_texture_v_scale, 0.0f, 1.0f);
+ }
+ else
+ {
+ Scene_texture_u_scale = 1.0f;
+ Scene_texture_v_scale = 1.0f;
+ }
+
GLenum buffers[] = { GL_COLOR_ATTACHMENT0_EXT, GL_COLOR_ATTACHMENT1_EXT };
vglDrawBuffers(2, buffers);
@@ -2266,7 +2283,7 @@
GLboolean blend = GL_state.Blend(GL_FALSE);
GLboolean cull = GL_state.CullFace(GL_FALSE);
- vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+ vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, opengl_get_rtt_framebuffer());
GL_state.Texture.SetActiveUnit(0);
GL_state.Texture.SetTarget(GL_TEXTURE_2D);
@@ -2276,19 +2293,38 @@
glClear(GL_COLOR_BUFFER_BIT);
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
- glBegin(GL_QUADS);
- glTexCoord2f(0.0f, 0.0f);
- glVertex2f(0.0f, (float)gr_screen.max_h);
+ if (GL_rendering_to_framebuffer)
+ {
+ glBegin(GL_QUADS);
+ glTexCoord2f(Scene_texture_u_scale, 0.0f);
+ glVertex2f(0.0f, (float)gr_screen.max_h);
+
+ glTexCoord2f(0.0f, 0.0f);
+ glVertex2f((float)gr_screen.max_w, (float)gr_screen.max_h);
+
+ glTexCoord2f(0.0f, Scene_texture_v_scale);
+ glVertex2f((float)gr_screen.max_w, 0.0f);
+
+ glTexCoord2f(Scene_texture_u_scale, Scene_texture_v_scale);
+ glVertex2f(0.0f, 0.0f);
+ glEnd();
+ }
+ else
+ {
+ glBegin(GL_QUADS);
+ glTexCoord2f(0.0f, 0.0f);
+ glVertex2f(0.0f, (float)gr_screen.max_h);
- glTexCoord2f(1.0f, 0.0f);
- glVertex2f((float)gr_screen.max_w, (float)gr_screen.max_h);
+ glTexCoord2f(Scene_texture_u_scale, 0.0f);
+ glVertex2f((float)gr_screen.max_w, (float)gr_screen.max_h);
- glTexCoord2f(1.0f, 1.0f);
- glVertex2f((float)gr_screen.max_w, 0.0f);
+ glTexCoord2f(Scene_texture_u_scale, Scene_texture_v_scale);
+ glVertex2f((float)gr_screen.max_w, 0.0f);
- glTexCoord2f(0.0f, 1.0f);
- glVertex2f(0.0f, 0.0f);
- glEnd();
+ glTexCoord2f(0.0f, Scene_texture_v_scale);
+ glVertex2f(0.0f, 0.0f);
+ glEnd();
+ }
GL_state.Texture.SetActiveUnit(0);
GL_state.Texture.Disable();
@@ -2301,6 +2337,11 @@
GL_state.CullFace(cull);
}
+ // Reset the UV scale values
+
+ Scene_texture_u_scale = 1.0f;
+ Scene_texture_v_scale = 1.0f;
+
Scene_framebuffer_in_frame = false;
}
Index: code/graphics/gropengldraw.h
===================================================================
--- code/graphics/gropengldraw.h (revision 8105)
+++ code/graphics/gropengldraw.h (working copy)
@@ -56,4 +56,7 @@
extern int Scene_texture_width;
extern int Scene_texture_height;
+extern float Scene_texture_u_scale;
+extern float Scene_texture_v_scale;
+
#endif // !GR_OPENGLDRAW_H
Index: code/graphics/gropenglpostprocessing.cpp
===================================================================
--- code/graphics/gropenglpostprocessing.cpp (revision 8105)
+++ code/graphics/gropenglpostprocessing.cpp (working copy)
@@ -209,9 +209,9 @@
// reset viewport, scissor test and exit
glViewport(0, 0, gr_screen.max_w, gr_screen.max_h);
GL_state.ScissorTest(scissor_test);
+
+ vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, opengl_get_rtt_framebuffer());
- vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-
return true;
}
@@ -308,14 +308,14 @@
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(-1.0f, -1.0f);
-
- glTexCoord2f(1.0f, 0.0f);
+
+ glTexCoord2f(Scene_texture_u_scale, 0.0f);
glVertex2f(1.0f, -1.0f);
-
- glTexCoord2f(1.0f, 1.0f);
+
+ glTexCoord2f(Scene_texture_u_scale, Scene_texture_v_scale);
glVertex2f(1.0f, 1.0f);
-
- glTexCoord2f(0.0f, 1.0f);
+
+ glTexCoord2f(0.0f, Scene_texture_v_scale);
glVertex2f(-1.0f, 1.0f);
glEnd();
@@ -336,14 +336,14 @@
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(-1.0f, -1.0f);
-
- glTexCoord2f(1.0f, 0.0f);
+
+ glTexCoord2f(Scene_texture_u_scale, 0.0f);
glVertex2f(1.0f, -1.0f);
-
- glTexCoord2f(1.0f, 1.0f);
+
+ glTexCoord2f(Scene_texture_u_scale, Scene_texture_v_scale);
glVertex2f(1.0f, 1.0f);
-
- glTexCoord2f(0.0f, 1.0f);
+
+ glTexCoord2f(0.0f, Scene_texture_v_scale);
glVertex2f(-1.0f, 1.0f);
glEnd();
@@ -373,9 +373,8 @@
opengl_post_pass_fxaa();
}
- // done with screen render framebuffer
- //vglBindRenderbufferEXT(GL_RENDERBUFFER_EXT, 0);
-
+ // Bind the correct framebuffer. opengl_get_rtt_framebuffer returns 0 if not doing RTT
+ vglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, opengl_get_rtt_framebuffer());
opengl_shader_set_current( &GL_post_shader[6] );
float x,y;
// should we even be here?
@@ -495,14 +494,14 @@
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2f(-1.0f, -1.0f);
-
- glTexCoord2f(1.0f, 0.0f);
+
+ glTexCoord2f(Scene_texture_u_scale, 0.0f);
glVertex2f(1.0f, -1.0f);
-
- glTexCoord2f(1.0f, 1.0f);
+
+ glTexCoord2f(Scene_texture_u_scale, Scene_texture_v_scale);
glVertex2f(1.0f, 1.0f);
-
- glTexCoord2f(0.0f, 1.0f);
+
+ glTexCoord2f(0.0f, Scene_texture_v_scale);
glVertex2f(-1.0f, 1.0f);
glEnd();
Index: code/graphics/gropengltexture.cpp
===================================================================
--- code/graphics/gropengltexture.cpp (revision 8105)
+++ code/graphics/gropengltexture.cpp (working copy)
@@ -1855,6 +1855,30 @@
return 1;
}
+/**
+ * @fn GLuint opengl_get_rtt_framebuffer()
+ *
+ * @brief Gets the current RTT framebuffer.
+ *
+ * Gets the OpenGL framebuffer ID of the currently in use RTT framebuffer.
+ * If there is currently none such framebuffer in use then this function returns
+ * 0 so it can be used in any place where the framebuffer should be reset to the
+ * default drawing surface.
+ *
+ * @author m!m
+ * @date 14.12.2011
+ *
+ * @return The current RTT FBO ID or 0 when not doing RTT.
+ */
+
+GLuint opengl_get_rtt_framebuffer()
+{
+ if (render_target == NULL || render_target->working_slot < 0)
+ return 0;
+ else
+ return render_target->framebuffer_id;
+}
+
//
// End of GL_EXT_framebuffer_object stuff
// -----------------------------------------------------------------------------
Index: code/graphics/gropengltexture.h
===================================================================
--- code/graphics/gropengltexture.h (revision 8105)
+++ code/graphics/gropengltexture.h (working copy)
@@ -78,6 +78,7 @@
int opengl_export_image(int slot, int width, int height, int alpha, int num_mipmaps, ubyte *image_data = NULL);
void opengl_set_texture_target(GLenum target = GL_TEXTURE_2D);
void opengl_set_texture_face(GLenum face = GL_TEXTURE_2D);
+GLuint opengl_get_rtt_framebuffer();
int gr_opengl_tcache_set(int bitmap_handle, int bitmap_type, float *u_scale, float *v_scale, int stage = 0);
int gr_opengl_preload(int bitmap_num, int is_aabitmap);
Index: code/parse/lua.cpp
===================================================================
--- code/parse/lua.cpp (revision 8105)
+++ code/parse/lua.cpp (working copy)
@@ -11955,7 +11955,7 @@
return ADE_RETURN_TRUE;
}
-ADE_FUNC(renderFrame, l_Mission, NULL, "Renders mission frame, but does not move anything", NULL, NULL)
+ADE_FUNC(renderFrame, l_Mission, NULL, "Renders mission frame, but does not move anything
Important:The maximal resolution this function is able to render is the currently configured screen size.", NULL, NULL)
{
camid cid = game_render_frame_setup();
game_render_frame( cid );