View Issue Details

IDProjectCategoryView StatusLast Update
0003078FSSCPHUDpublic2014-07-31 10:09
Reporterzookeeper Assigned ToYarn  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product Version3.7.2 
Target Version3.7.2 
Summary0003078: Cockpit displays broken
DescriptionCockpit displays seem to have been broken since r10844.
Steps To ReproduceUse attached testmod; it adds a silly test cockpit to GTF Ulysses, and draws the player shields gauge at the center of it. Prior to r10844 everything works correctly: https://dl.dropboxusercontent.com/u/63964618/fs/cockpitdisplaystest.png

However, after r10844 the gauge won't show up on the model at all.
TagsNo tags attached.

Activities

zookeeper

2014-07-24 15:40

developer  

cockpittestmod.zip (27,140 bytes)

Yarn

2014-07-24 19:44

developer   ~0016124

All right, I'll have a look to see what exactly is causing this.

In the future, though, keep in mind that you should not specify minimum and maximum resolutions in HUD tables unless they're really necessary. Those fields are not required, and the game has no problem with scaling down gauges. Since my resolution is not at least 1280x1024 (I was running in 1024x768 in windowed mode), I had to remove those fields myself to make the gauge appear in revision 10843.

Yarn

2014-07-24 22:28

developer   ~0016125

The problem appears to be that the clip area for the gauge is being placed in the upper-left corner of the texture rather than where the gauge really is. The clip area at least seems to be the right size, though.

I still haven't figured out why this is happening.

Yarn

2014-07-27 02:34

developer   ~0016136

It turns out that the problem was caused by gr_set_screen_scale() setting the unscaled screen area, which didn't happen before revision 10844. This needs to be done to properly display main halls of any resolution, but it's not appropriate when rendering to a texture.

I have attached a patch that makes gr_set_screen_scale() and gr_reset_screen_scale() account for this. It also fixes a pre-10844 bug where scaling down a cockpit gauge would cause the gauge to be improperly clipped if it was close enough to the right or bottom edge of the texture.

Yarn

2014-07-27 02:38

developer  

mantis3078.patch (2,707 bytes)   
Index: code/graphics/2d.cpp
===================================================================
--- code/graphics/2d.cpp	(revision 10947)
+++ code/graphics/2d.cpp	(working copy)
@@ -151,21 +151,23 @@
 
 	gr_screen.custom_size = (w != max_w || h != max_h);
 
-	gr_screen.max_w_unscaled = w;
-	gr_screen.max_h_unscaled = h;
+	if (gr_screen.rendering_to_texture == -1) {
+		gr_screen.max_w_unscaled = w;
+		gr_screen.max_h_unscaled = h;
 
-	if (do_zoom) {
-		gr_screen.max_w_unscaled_zoomed = gr_screen.max_w_unscaled + fl2i(Gr_menu_offset_X * 2.0f / Gr_resize_X);
-		gr_screen.max_h_unscaled_zoomed = gr_screen.max_h_unscaled + fl2i(Gr_menu_offset_Y * 2.0f / Gr_resize_Y);
-		if (gr_screen.max_w_unscaled_zoomed > gr_screen.max_w_unscaled) {
+		if (do_zoom) {
+			gr_screen.max_w_unscaled_zoomed = gr_screen.max_w_unscaled + fl2i(Gr_menu_offset_X * 2.0f / Gr_resize_X);
+			gr_screen.max_h_unscaled_zoomed = gr_screen.max_h_unscaled + fl2i(Gr_menu_offset_Y * 2.0f / Gr_resize_Y);
+			if (gr_screen.max_w_unscaled_zoomed > gr_screen.max_w_unscaled) {
+				gr_screen.max_w_unscaled_zoomed = gr_screen.max_w_unscaled;
+			}
+			if (gr_screen.max_h_unscaled_zoomed > gr_screen.max_h_unscaled) {
+				gr_screen.max_h_unscaled_zoomed = gr_screen.max_h_unscaled;
+			}
+		} else {
 			gr_screen.max_w_unscaled_zoomed = gr_screen.max_w_unscaled;
-		}
-		if (gr_screen.max_h_unscaled_zoomed > gr_screen.max_h_unscaled) {
 			gr_screen.max_h_unscaled_zoomed = gr_screen.max_h_unscaled;
 		}
-	} else {
-		gr_screen.max_w_unscaled_zoomed = gr_screen.max_w_unscaled;
-		gr_screen.max_h_unscaled_zoomed = gr_screen.max_h_unscaled;
 	}
 }
 
@@ -185,8 +187,10 @@
 
 	gr_screen.custom_size = Save_custom_screen_size;
 
-	gr_screen.max_w_unscaled = gr_screen.max_w_unscaled_zoomed = (gr_screen.res == GR_1024) ? 1024 : 640;
-	gr_screen.max_h_unscaled = gr_screen.max_h_unscaled_zoomed = (gr_screen.res == GR_1024) ?  768 : 480;
+	if (gr_screen.rendering_to_texture == -1) {
+		gr_screen.max_w_unscaled = gr_screen.max_w_unscaled_zoomed = (gr_screen.res == GR_1024) ? 1024 : 640;
+		gr_screen.max_h_unscaled = gr_screen.max_h_unscaled_zoomed = (gr_screen.res == GR_1024) ?  768 : 480;
+	}
 }
 
 /**
Index: code/graphics/gropengl.cpp
===================================================================
--- code/graphics/gropengl.cpp	(revision 10947)
+++ code/graphics/gropengl.cpp	(working copy)
@@ -384,6 +384,10 @@
 	int max_w = ((to_resize) ? gr_screen.max_w_unscaled : gr_screen.max_w);
 	int max_h = ((to_resize) ? gr_screen.max_h_unscaled : gr_screen.max_h);
 
+	if ((gr_screen.rendering_to_texture != -1) && to_resize) {
+		gr_unsize_screen_pos(&max_w, &max_h);
+	}
+
 	if (x >= max_w) {
 		x = max_w - 1;
 	}
mantis3078.patch (2,707 bytes)   

MageKing17

2014-07-30 19:24

developer   ~0016160

Downloaded test mod; couldn't reproduce issue at 1080p, so I set res to 1024x960 to match the screenshot and it showed up immediately. Applied patch, rebuilt, and... problem fails to go away. http://deviance.duckish.net/pictures/fs2_open_3_7_1_AVX-DEBUG%202014-07-30%2012-48-01-58.png

Yarn

2014-07-30 20:31

developer   ~0016161

Did you open the HUD table and remove the minimum resolution? The HUD in this particular mod has that set to 1280x1024, so if you don't change or remove the minimum from the table, then the HUD won't appear at any resolution lower than that.

MageKing17

2014-07-30 20:45

developer   ~0016162

Okay, well, that makes the screenshot demonstrating the issue at 1024x960 a bit silly, but yeah, it works now.

Code changes are simple and patch does what it's supposed to do.

niffiwan

2014-07-31 01:55

developer   ~0016163

ok, I'll see about committing this tonight

niffiwan

2014-07-31 10:09

developer   ~0016165

Fix committed to trunk@10965.

Related Changesets

fs2open: trunk r10965

2014-07-31 06:35

niffiwan


Ported: N/A

Details Diff
Fix mantis 3078 (From Yarn)

Don't set / reset unscaled screen area when rendering to texture
Also fix a pre-10844 bug where scaling down a cockpit gauge would
cause the gauge to be improperly clipped if it was close enough to the
right or bottom edge of the texture.
Affected Issues
0003078
mod - /trunk/fs2_open/code/graphics/gropengl.cpp Diff File
mod - /trunk/fs2_open/code/graphics/2d.cpp Diff File

Issue History

Date Modified Username Field Change
2014-07-24 15:40 zookeeper New Issue
2014-07-24 15:40 zookeeper Status new => assigned
2014-07-24 15:40 zookeeper Assigned To => Yarn
2014-07-24 15:40 zookeeper File Added: cockpittestmod.zip
2014-07-24 19:44 Yarn Note Added: 0016124
2014-07-24 22:28 Yarn Note Added: 0016125
2014-07-27 02:34 Yarn File Added: mantis3078.patch
2014-07-27 02:34 Yarn Note Added: 0016136
2014-07-27 02:34 Yarn Status assigned => code review
2014-07-27 02:38 Yarn File Deleted: mantis3078.patch
2014-07-27 02:38 Yarn File Added: mantis3078.patch
2014-07-30 19:24 MageKing17 Note Added: 0016160
2014-07-30 20:31 Yarn Note Added: 0016161
2014-07-30 20:45 MageKing17 Note Added: 0016162
2014-07-31 01:55 niffiwan Note Added: 0016163
2014-07-31 10:09 niffiwan Changeset attached => fs2open trunk r10965
2014-07-31 10:09 niffiwan Note Added: 0016165
2014-07-31 10:09 niffiwan Status code review => resolved
2014-07-31 10:09 niffiwan Resolution open => fixed