summaryrefslogtreecommitdiff
path: root/drivers/gles2/rasterizer_gles2.cpp
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2014-04-10 00:18:27 -0300
committerJuan Linietsky <reduzio@gmail.com>2014-04-10 00:18:27 -0300
commit7ea3e8267afaf626256c84a9a3dc61e2954fc6a2 (patch)
tree0aa7588918b814d1781fc94e8b518c7095a0bab7 /drivers/gles2/rasterizer_gles2.cpp
parentb4969373b3475799d6b24cdffeda4659c37f0b8a (diff)
-Fixed a few bugs in Viewport
-Made a few demos using Viewport to show it's true power! -Fixed some start-up error messages.
Diffstat (limited to 'drivers/gles2/rasterizer_gles2.cpp')
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp33
1 files changed, 29 insertions, 4 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 5be6045d50..20505875ea 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -3320,6 +3320,7 @@ void RasterizerGLES2::render_target_set_size(RID p_render_target,int p_width,int
if (p_width==0 || p_height==0)
return;
+
rt->width=p_width;
rt->height=p_height;
@@ -3560,11 +3561,14 @@ void RasterizerGLES2::clear_viewport(const Color& p_color) {
};
-void RasterizerGLES2::set_render_target(RID p_render_target) {
+void RasterizerGLES2::set_render_target(RID p_render_target, bool p_transparent_bg, bool p_vflip) {
+
+
if (!p_render_target.is_valid()) {
glBindFramebuffer(GL_FRAMEBUFFER,base_framebuffer);
current_rt=NULL;
+ current_rt_vflip=false;
} else {
RenderTarget *rt = render_target_owner.get(p_render_target);
@@ -3572,6 +3576,8 @@ void RasterizerGLES2::set_render_target(RID p_render_target) {
ERR_FAIL_COND(rt->fbo==0);
glBindFramebuffer(GL_FRAMEBUFFER,rt->fbo);
current_rt=rt;
+ current_rt_transparent=p_transparent_bg;
+ current_rt_vflip=!p_vflip;
}
}
@@ -3637,6 +3643,9 @@ void RasterizerGLES2::begin_shadow_map( RID p_light_instance, int p_shadow_pass
void RasterizerGLES2::set_camera(const Transform& p_world,const CameraMatrix& p_projection) {
camera_transform=p_world;
+ if (current_rt && current_rt_vflip) {
+ camera_transform.basis.set_axis(1,-camera_transform.basis.get_axis(1));
+ }
camera_transform_inverse=camera_transform.inverse();
camera_projection=p_projection;
camera_plane = Plane( camera_transform.origin, camera_transform.basis.get_axis(2) );
@@ -3741,7 +3750,7 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
}
//print_line("compiled fragment: "+fragment_code);
- //print_line("compiled fragment globals: "+fragment_globals);
+ // ("compiled fragment globals: "+fragment_globals);
//print_line("UCF: "+itos(p_shader->uniforms.size()));
@@ -5090,6 +5099,12 @@ void RasterizerGLES2::_setup_skeleton(const Skeleton *p_skeleton) {
void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Transform& p_view_transform, const Transform& p_view_transform_inverse,const CameraMatrix& p_projection,bool p_reverse_cull,bool p_fragment_light,bool p_alpha_pass) {
+ if (current_rt && current_rt_vflip) {
+ p_reverse_cull=!p_reverse_cull;
+ glFrontFace(GL_CCW);
+
+ }
+
const Material *prev_material=NULL;
uint16_t prev_light=0x777E;
const Geometry *prev_geometry_cmp=NULL;
@@ -5349,6 +5364,9 @@ void RasterizerGLES2::_render_list_forward(RenderList *p_render_list,const Trans
//print_line("shaderchanges: "+itos(p_alpha_pass)+": "+itos(_rinfo.shader_change_count));
+ if (current_rt && current_rt_vflip) {
+ glFrontFace(GL_CW);
+ }
};
@@ -5755,6 +5773,10 @@ void RasterizerGLES2::end_scene() {
glClearColor(0,0,0,1);
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
+ } else if (current_rt && current_rt_transparent) {
+
+ glClearColor(0,0,0,0);
+ glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
} else if (current_env) {
@@ -6266,13 +6288,16 @@ void RasterizerGLES2::canvas_begin() {
_set_color_attrib(Color(1,1,1));
Transform canvas_transform;
canvas_transform.translate(-(viewport.width / 2.0f), -(viewport.height / 2.0f), 0.0f);
- canvas_transform.scale( Vector3( 2.0f / viewport.width, -2.0f / viewport.height, 1.0f ) );
+ float csy = 1.0;
+ if (current_rt && current_rt_vflip)
+ csy = -1.0;
+
+ canvas_transform.scale( Vector3( 2.0f / viewport.width, csy * -2.0f / viewport.height, 1.0f ) );
canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX,canvas_transform);
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,Matrix32());
canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Matrix32());
canvas_opacity=1.0;
-
canvas_blend_mode=VS::MATERIAL_BLEND_MODE_MIX;