|
@@ -25,7 +25,8 @@ namespace bbiwarg.Graphics
|
|
|
private Stopwatch watch;
|
|
|
|
|
|
public OutputWindow(VideoHandle videoHandle)
|
|
|
- : base((int) (1.5 * videoHandle.OutputImages.Length * videoHandle.Width), (int) (1.5 * videoHandle.Height))
|
|
|
+ : base((int) (Constants.WindwoSizeFactor * HelperFunctions.thresholdRange<int>(1, Constants.NumImagesPerRow, videoHandle.OutputImages.Length) * videoHandle.Width),
|
|
|
+ (int) (Constants.WindwoSizeFactor * (1 + (videoHandle.OutputImages.Length - 1) / Constants.NumImagesPerRow) * videoHandle.Height))
|
|
|
{
|
|
|
this.videoHandle = videoHandle;
|
|
|
watch = new Stopwatch();
|
|
@@ -65,12 +66,15 @@ namespace bbiwarg.Graphics
|
|
|
int imageHeight = videoHandle.Height;
|
|
|
float imageAspectRatio = (float)imageWidth / (float)imageHeight;
|
|
|
|
|
|
- int heightForWidth = (int) ((float) screenWidth / ((float) videoHandle.OutputImages.Length * imageAspectRatio));
|
|
|
-
|
|
|
+ int numImages = videoHandle.OutputImages.Length;
|
|
|
+ int numRows = 1 + (numImages - 1) / Constants.NumImagesPerRow;
|
|
|
+ int numCols = Math.Min(videoHandle.OutputImages.Length, Constants.NumImagesPerRow);
|
|
|
+ int heightForWidth = (int)((float)screenWidth / ((float)numCols * imageAspectRatio) * (float)numRows);
|
|
|
+
|
|
|
GL.Viewport(0, (screenHeight - heightForWidth) / 2, screenWidth, heightForWidth);
|
|
|
|
|
|
// top left at (0,0) every image from (i, j) to (i + 1, j + 1)
|
|
|
- Matrix4 projection = Matrix4.CreateOrthographicOffCenter(0, videoHandle.OutputImages.Length, 1, 0, 0.001f, 10f);
|
|
|
+ Matrix4 projection = Matrix4.CreateOrthographicOffCenter(0, numCols, numRows, 0, 0.001f, 10f);
|
|
|
GL.MatrixMode(MatrixMode.Projection);
|
|
|
GL.LoadMatrix(ref projection);
|
|
|
}
|
|
@@ -139,14 +143,16 @@ namespace bbiwarg.Graphics
|
|
|
int imageIndex = 0;
|
|
|
foreach (OutputImage image in videoHandle.OutputImages)
|
|
|
{
|
|
|
+ int x = imageIndex % Constants.NumImagesPerRow;
|
|
|
+ int y = imageIndex / Constants.NumImagesPerRow;
|
|
|
GL.BindTexture(TextureTarget.Texture2D, textureId);
|
|
|
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgb, videoHandle.Width, videoHandle.Height, 0, PixelFormat.Rgb, PixelType.UnsignedByte, image.Image.MIplImage.imageData);
|
|
|
GL.Begin(PrimitiveType.Quads);
|
|
|
GL.Color3(1.0, 1.0, 1.0);
|
|
|
- GL.TexCoord2(0, 0); GL.Vertex3(0 + imageIndex, 0, -1);
|
|
|
- GL.TexCoord2(1, 0); GL.Vertex3(1 + imageIndex, 0, -1);
|
|
|
- GL.TexCoord2(1, 1); GL.Vertex3(1 + imageIndex, 1, -1);
|
|
|
- GL.TexCoord2(0, 1); GL.Vertex3(0 + imageIndex, 1, -1);
|
|
|
+ GL.TexCoord2(0, 0); GL.Vertex3(0 + x, 0 + y, -1);
|
|
|
+ GL.TexCoord2(1, 0); GL.Vertex3(1 + x, 0 + y, -1);
|
|
|
+ GL.TexCoord2(1, 1); GL.Vertex3(1 + x, 1 + y, -1);
|
|
|
+ GL.TexCoord2(0, 1); GL.Vertex3(0 + x, 1 + y, -1);
|
|
|
GL.End();
|
|
|
++imageIndex;
|
|
|
}
|