View Issue Details

IDProjectCategoryView StatusLast Update
0001563FSSCPcutscenespublic2008-02-22 07:36
ReporterTolwyn Assigned Totaylor  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionduplicate 
Product Version3.6.9 
Summary0001563: Clipping issues in cutscenes
DescriptionWhen ships come near a screen border, they vanish completely. As a result it is not possible to use cutscene bars, as they are causing this behavior.
Additional InformationDuplicate of 1282

The cause of the bug is the usage of zoom in case cutscene bars are applied. This fix simply removes the zooming (as far as I was told :-)).
TagsNo tags attached.

Relationships

duplicate of 0000563 resolvedtaylor FOV becomes warped for the death screen 

Activities

2008-01-05 15:49

 

cutscene_bars_diff.txt (4,620 bytes)   
Index: freespace.cpp
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/freespace2/freespace.cpp,v
retrieving revision 2.302
diff -u -r2.302 freespace.cpp
--- freespace.cpp	23 Nov 2007 23:49:32 -0000	2.302
+++ freespace.cpp	5 Jan 2008 04:35:32 -0000
@@ -4597,7 +4597,7 @@
 
 		//	Numeric constants encouraged by J "pig farmer" S, who shall remain semi-anonymous.
 		// J.S. I've changed my ways!! See the new "no constants" code!!!
-		gr_set_clip(0, yborder, gr_screen.max_w, gr_screen.max_h - yborder*2, false );	
+		gr_set_scissor(0, yborder, gr_screen.max_w, gr_screen.max_h - yborder*2);
 	}
 	else if((Cutscene_bar_flags & CUB_GRADUAL) && Cutscene_bars_progress < 1.0f)
 	{
@@ -4620,18 +4620,18 @@
 			yborder = gr_screen.max_h/6 - fl2i(Cutscene_bars_progress*(gr_screen.max_h/8));
 
 		//Set teh clipping
-		gr_set_clip(0, yborder, gr_screen.max_w, gr_screen.max_h - yborder*2, false );	
+		gr_set_scissor(0, yborder, gr_screen.max_w, gr_screen.max_h - yborder*2);	
 	}
 	else if(Cutscene_bar_flags & CUB_CUTSCENE)
 	{
 		int yborder = gr_screen.max_h/6;
 
-		gr_set_clip(0, yborder, gr_screen.max_w, gr_screen.max_h - yborder*2, false );	
+		gr_set_scissor(0, yborder, gr_screen.max_w, gr_screen.max_h - yborder*2);	
 	}
 	else {
 		// Set the clip region for normal view
 		if ( View_percent >= 100 )	{
-			gr_reset_clip();
+			gr_unset_scissor();
 		} else {
 			int xborder, yborder;
 
@@ -4646,7 +4646,7 @@
 			xborder = ( gr_screen.max_w*(100-fi) )/200;
 			yborder = ( gr_screen.max_h*(100-fi) )/200;
 
-			gr_set_clip(xborder, yborder, gr_screen.max_w-xborder*2,gr_screen.max_h-yborder*2, false );
+			gr_set_scissor(xborder, yborder, gr_screen.max_w-xborder*2,gr_screen.max_h-yborder*2);
 		}
 	}
 }
 
 
 Index: gropengl.cpp
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/graphics/gropengl.cpp,v
retrieving revision 2.203
diff -u -r2.203 gropengl.cpp
--- gropengl.cpp	23 Nov 2007 21:58:10 -0000	2.203
+++ gropengl.cpp	5 Jan 2008 04:29:27 -0000
@@ -1705,6 +1705,48 @@
 	// Not used.
 }
 
+void gr_opengl_set_scissor(int x, int y, int w, int h)
+{
+	// check for sanity of parameters
+	if (x < 0)
+		x = 0;
+	if (y < 0)
+		y = 0;
+
+	int max_w = gr_screen.max_w;
+	int max_h = gr_screen.max_h;
+
+	if (x >= max_w)
+		x = max_w - 1;
+	if (y >= max_h)
+		y = max_h - 1;
+
+	if (x + w > max_w)
+		w = max_w - x;
+	if (y + h > max_h)
+		h = max_h - y;
+	
+	if (w > max_w)
+		w = max_w;
+	if (h > max_h)
+		h = max_h;
+
+	// just return early if we aren't actually going to need the scissor test
+	if ( (x == 0) && (y == 0) && (w == max_w) && (h == max_h) ) {
+		glDisable(GL_SCISSOR_TEST);
+		return;
+	}
+	
+	glEnable(GL_SCISSOR_TEST);
+	glScissor(x, gr_screen.max_h - y - h, w, h);
+}
+
+void gr_opengl_unset_scissor()
+{
+    glDisable(GL_SCISSOR_TEST);
+}
+
+
 void gr_opengl_set_clip(int x, int y, int w, int h, bool resize)
 {
 	// check for sanity of parameters
@@ -4584,6 +4626,8 @@
 
 	gr_screen.gf_flip				= gr_opengl_flip;
 	gr_screen.gf_flip_window		= gr_opengl_flip_window;
+    gr_screen.gf_set_scissor        = gr_opengl_set_scissor;
+    gr_screen.gf_unset_scissor      = gr_opengl_unset_scissor;
 	gr_screen.gf_set_clip			= gr_opengl_set_clip;
 	gr_screen.gf_reset_clip			= gr_opengl_reset_clip;



Index: 2d.h
===================================================================
RCS file: /home/fs2source/cvsroot/fs2_open/code/graphics/2d.h,v
retrieving revision 2.85
diff -u -r2.85 2d.h
--- 2d.h	11 Feb 2007 18:18:52 -0000	2.85
+++ 2d.h	5 Jan 2008 04:33:55 -0000
@@ -921,6 +921,12 @@
 	// resets the clipping region to entire screen
 	void (*gf_reset_clip)();
 
+    // sets the scissor region
+	void (*gf_set_scissor)(int x, int y, int w, int h);
+
+	// resets the scissor region to entire screen
+	void (*gf_unset_scissor)();
+
 	//void (*gf_set_color)( int r, int g, int b );
 	//void (*gf_get_color)( int * r, int * g, int * b );
 	//void (*gf_init_color)( color * dst, int r, int g, int b );
@@ -1236,6 +1242,12 @@
 	(*gr_screen.gf_set_clip)(x,y,w,h,resize);
 }
 #define gr_reset_clip		GR_CALL(gr_screen.gf_reset_clip)
+
+__inline void gr_set_scissor(int x, int y, int w, int h)
+{
+	(*gr_screen.gf_set_scissor)(x,y,w,h);
+}
+#define gr_unset_scissor		GR_CALL(gr_screen.gf_unset_scissor)
 //#define gr_set_font			GR_CALL(gr_screen.gf_set_font)
 
 //#define gr_init_color		GR_CALL(gr_screen.gf_init_color)
cutscene_bars_diff.txt (4,620 bytes)   

Backslash

2008-01-08 12:39

developer   ~0008793

Fix works great! Even fixes the issue during death view!

taylor

2008-01-08 19:04

administrator   ~0008796

It doesn't fix anything really, it just hacks around it. :) The issue with this patch is that a call to gr_(re)set_clip() will screw it up. If you are careful then that won't be an issue, but it's problematic regardless. As an interim fix though, I suppose it's about the best that could be done.

This won't have a proper fix until I redo the rendering code to handle projection views properly (ie, this problem is the same basic thing that causes the HUD targeting brackets to be offset on widescreen resolutions).

Kazan

2008-01-08 22:26

developer   ~0008798

does that mean this patch is approved by you taylor? i was going to check with you before applying it since graphics are more up your alley

taylor

2008-01-08 22:57

administrator   ~0008799

I'll just say that I don't disapprove. ;) If you want to go ahead and apply it then I'm not going to stand in the way. So long as there are no issues with other clip() calls (which might only occur with certain cutscene setups) then I don't really have a problem with it.

When an actual fix shows up this code will need to be reverted, which means extra work for me, but it is enough of a problem that I'm not about to make everyone wait for this to be properly fixed. The HUD alignment issue can be worked around or dealt with by individual users for the time being, but this particular problem requires a coder to fix. And this patch is small enough that ripping it out later on isn't going to be that big of a deal.

taylor

2008-02-22 02:35

administrator   ~0008888

I'm going to remove this patch and use Murleen's instead, as that one actually qualifies as a fix. :)

I'll mark as fixed once Murleen's patch is in SVN.

Issue History

Date Modified Username Field Change
2008-01-05 15:49 Tolwyn New Issue
2008-01-05 15:49 Tolwyn File Added: cutscene_bars_diff.txt
2008-01-07 01:11 Goober5000 Status new => assigned
2008-01-07 01:11 Goober5000 Assigned To => Goober5000
2008-01-08 12:39 Backslash Note Added: 0008793
2008-01-08 19:04 taylor Note Added: 0008796
2008-01-08 22:26 Kazan Note Added: 0008798
2008-01-08 22:57 taylor Note Added: 0008799
2008-02-22 02:35 taylor Note Added: 0008888
2008-02-22 02:35 taylor Assigned To Goober5000 => taylor
2008-02-22 07:36 taylor Relationship added duplicate of 0000563
2008-02-22 07:36 taylor Duplicate ID 0 => 563
2008-02-22 07:36 taylor Status assigned => resolved
2008-02-22 07:36 taylor Resolution open => duplicate