X-Git-Url: http://shamusworld.gotdns.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fgui%2Fglwidget.cpp;h=56fcd0ed824de8490a95cf8e3440b935310dbe8a;hb=26044acf8a4fe70772bd6e69afb8b8d20b5a6af5;hp=e32dde3682aa65c4b6d842e6d960313803e669ae;hpb=e6b7d61963423b7f9cb4c6c24d2befca50328d4f;p=virtualjaguar diff --git a/src/gui/glwidget.cpp b/src/gui/glwidget.cpp index e32dde3..56fcd0e 100644 --- a/src/gui/glwidget.cpp +++ b/src/gui/glwidget.cpp @@ -1,10 +1,10 @@ // OpenGL implementation in Qt // Parts of this are blantantly ripped off from BSNES (thanks Byuu!) // -// by James L. Hammons +// by James Hammons // (C) 2010 Underground Software // -// JLH = James L. Hammons +// JLH = James Hammons // // Who When What // --- ---------- ------------------------------------------------------------- @@ -13,15 +13,25 @@ #include "glwidget.h" +#include "jaguar.h" #include "settings.h" +#include "tom.h" + +#ifdef __GCCWIN32__ +// Apparently on win32, various OpenGL constants aren't pulled in. +#include +#endif GLWidget::GLWidget(QWidget * parent/*= 0*/): QGLWidget(parent), texture(0), - textureWidth(0), textureHeight(0), buffer(0), rasterWidth(320), rasterHeight(240) + textureWidth(0), textureHeight(0), buffer(0), rasterWidth(340), rasterHeight(240) { + // Screen pitch has to be the texture width (in 32-bit pixels)... + JaguarSetScreenPitch(1024); } GLWidget::~GLWidget() { +// free(backbuffer); } void GLWidget::initializeGL() @@ -42,7 +52,7 @@ void GLWidget::initializeGL() void GLWidget::paintGL() { //kludge -rasterHeight = (vjs.hardwareTypeNTSC ? 240 : 256); +rasterHeight = (vjs.hardwareTypeNTSC ? VIRTUAL_SCREEN_HEIGHT_NTSC : VIRTUAL_SCREEN_HEIGHT_PAL); unsigned outputWidth = width(); unsigned outputHeight = height(); @@ -58,9 +68,12 @@ rasterHeight = (vjs.hardwareTypeNTSC ? 240 : 256); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (vjs.glFilter ? GL_LINEAR : GL_NEAREST)); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (vjs.glFilter ? GL_LINEAR : GL_NEAREST)); // glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rasterWidth, rasterHeight, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, buffer); - glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rasterWidth, rasterHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, buffer); +//more kludge + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, TOMGetVideoModeWidth(), rasterHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, buffer); +// glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, rasterWidth, rasterHeight, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, buffer); - double w = (double)rasterWidth / (double)textureWidth; + double w = (double)TOMGetVideoModeWidth() / (double)textureWidth; +// double w = (double)rasterWidth / (double)textureWidth; double h = (double)rasterHeight / (double)textureHeight; unsigned u = outputWidth; unsigned v = outputHeight; @@ -77,13 +90,9 @@ void GLWidget::resizeGL(int width, int height) { if (width > textureWidth || height > textureHeight) { -// textureWidth = max(width, textureWidth); -// textureHeight = max(height, textureHeight); -// Seems that power of 2 sizes are still mandatory... - textureWidth = 1024;//(width > textureWidth ? width : textureWidth); - textureHeight = 512;//(height > textureHeight ? height : textureHeight); -// textureWidth = (width > textureWidth ? width : textureWidth); -// textureHeight = (height > textureHeight ? height : textureHeight); + // Seems that power of 2 sizes are still mandatory... + textureWidth = 1024; + textureHeight = 512; #if 0 printf("Resizing: new texture width/height = %i x %i\n", textureWidth, textureHeight); printf("Resizing: new raster width/height = %i x %i\n", rasterWidth, rasterHeight); @@ -96,12 +105,15 @@ printf("Resizing: new raster width/height = %i x %i\n", rasterWidth, rasterHeigh } buffer = new uint32_t[textureWidth * textureHeight]; + JaguarSetScreenBuffer(buffer); + +//??? +memset(buffer, 0xFF, textureWidth * textureHeight * sizeof(uint32_t)); glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glPixelStorei(GL_UNPACK_ROW_LENGTH, textureWidth); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); -// glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureWidth, textureHeight, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, textureWidth, textureHeight, 0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8, NULL); } }