fixed non-bilinear mode (no black line in that anymore; fixing the bilinear case will be challenging, at the least...); some cleanup

svn-id: r8561
This commit is contained in:
Max Horn 2003-06-19 16:33:46 +00:00
parent ed43323597
commit 7403492aea
2 changed files with 32 additions and 52 deletions

View File

@ -88,8 +88,22 @@ class FB2GL {
void setPalette(int first, int ncolors);
void blit16(SDL_Surface *fb, int num_rect, SDL_Rect *rectlist, int xskip, int yskip);
void display();
void setBilinearMode(bool bilinear);
};
void FB2GL::setBilinearMode(bool bilinear) {
GLuint mode = bilinear ? GL_LINEAR : GL_NEAREST;
glBindTexture(GL_TEXTURE_2D, texture1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mode);
if (flags & FB2GL_320) {
glBindTexture(GL_TEXTURE_2D, texture2);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, mode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, mode);
}
}
void FB2GL::makeTextures() {
glGenTextures(0,&texture1);
glBindTexture(GL_TEXTURE_2D,texture1);
@ -142,8 +156,13 @@ void FB2GL::makeDisplayList(int xf, int yf) {
double xfix = (double)xf / 128; // 128 = 256/2 (half texture => 0.0 to 1.0)
double yfix = (double)yf / 128;
// End of 256x256 (from -1.0 to 1.0)
double texend = (double)96 / 160; // 160=320/2 (== 0.0), 256-160=96.
double texend;
if (flags & FB2GL_320)
texend = 96.0 / 160.0; // 160=320/2 (== 0.0), 256-160=96.
else
texend = 1.0;
if (glIsList(displayList))
glDeleteLists(displayList, 1);
@ -154,31 +173,18 @@ void FB2GL::makeDisplayList(int xf, int yf) {
glBindTexture(GL_TEXTURE_2D, texture1);
if (!(flags & FB2GL_320)) { // Normal 256x256
glBegin(GL_QUADS);
// upper left
glTexCoord2f(0.0, 1.0); glVertex2f(-1.0, -1.0 - yfix);
// lower left
glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, 1.0);
// lower right
glTexCoord2f(1.0, 0.0); glVertex2f(1.0 + xfix, 1.0);
// upper right
glTexCoord2f(1.0, 1.0); glVertex2f(1.0 + xfix, -1.0 - yfix); glEnd();
}
else { // 320x256
// First, the 256x256 texture
glBegin(GL_QUADS);
// upper left
glTexCoord2f(0.0, 1.0); glVertex2f( -1.0, -1.0 - yfix);
// lower left
glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, 1.0);
// lower right
glTexCoord2f(1.0, 0.0); glVertex2f(texend + xfix, 1.0);
// upper right
glTexCoord2f(1.0, 1.0); glVertex2f(texend + xfix, -1.0 - yfix);
glEnd();
glBegin(GL_QUADS);
// upper left
glTexCoord2f(0.0, 1.0); glVertex2f(-1.0, -1.0 - yfix);
// lower left
glTexCoord2f(0.0, 0.0); glVertex2f(-1.0, 1.0);
// lower right
glTexCoord2f(1.0, 0.0); glVertex2f(texend + xfix, 1.0);
// upper right
glTexCoord2f(1.0, 1.0); glVertex2f(texend + xfix, -1.0 - yfix);
glEnd();
if (flags & FB2GL_320) {
// 64x256
glBindTexture(GL_TEXTURE_2D, texture2);

View File

@ -519,7 +519,6 @@ bool OSystem_SDL_OpenGL::poll_event(Event *event) {
*/
uint32 OSystem_SDL_OpenGL::property(int param, Property *value) {
int i;
if (param == PROP_TOGGLE_FULLSCREEN) {
if (!_usingOpenGL)
@ -561,32 +560,7 @@ uint32 OSystem_SDL_OpenGL::property(int param, Property *value) {
switch(value->gfx_mode) {
case GFX_BILINEAR: // Bilinear Filtering (on/off)
_glBilinearFilter ^= true;
for (i = 0; i < 2; i++) {
glBindTexture(GL_TEXTURE_2D, i);
if (_glBilinearFilter) {
glTexParameteri(
GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER,
GL_LINEAR
);
glTexParameteri(
GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER,
GL_LINEAR
);
} else {
glTexParameteri(
GL_TEXTURE_2D,
GL_TEXTURE_MAG_FILTER,
GL_NEAREST
);
glTexParameteri(
GL_TEXTURE_2D,
GL_TEXTURE_MIN_FILTER,
GL_NEAREST
);
}
}
fb2gl.setBilinearMode(_glBilinearFilter);
break;
case GFX_ASPECTRATIO:
_glAspectRatio ^= true;