get rid of leftover opengl code

This commit is contained in:
Tim Felgentreff 2020-06-27 12:45:24 +02:00
parent 70389df39a
commit eb2b23749d

View file

@ -102,26 +102,6 @@ static mng_bool MNG_DECL my_processheader(mng_handle handle, mng_uint32 width,
Mng *mng = (Mng *)mng_get_userdata(handle);
#if defined(USE_OPENGL) || defined(USE_GLES)
if (UseOpenGL) {
unsigned w;
unsigned h;
for (w = 1; w < width; w <<= 1) {
}
for (h = 1; h < height; h <<= 1) {
}
mng->texture_width = (float)width / w;
mng->texture_height = (float)height / h;
glGenTextures(1, &mng->texture_name);
glBindTexture(GL_TEXTURE_2D, mng->texture_name);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
}
#endif
// Allocate the SDL surface to hold the image
#if SDL_BYTEORDER == SDL_LIL_ENDIAN
const Uint32 Rmask = 0x000000FF;
@ -163,13 +143,6 @@ static mng_bool MNG_DECL my_refresh(mng_handle handle, mng_uint32, mng_uint32,
memcpy((char *)mng->surface->pixels + i * mng->surface->pitch,
mng->buffer + i * mng->surface->w * 3, mng->surface->w * 3);
}
#if defined(USE_OPENGL) || defined(USE_GLES)
if (UseOpenGL) {
glBindTexture(GL_TEXTURE_2D, mng->texture_name);
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, mng->surface->w, mng->surface->h,
GL_RGB, GL_UNSIGNED_BYTE, mng->surface->pixels);
}
#endif
SDL_UnlockSurface(mng->surface);
return MNG_TRUE;
@ -213,11 +186,6 @@ Mng::Mng() :
name(NULL), fd(NULL), handle(NULL), surface(NULL), buffer(NULL),
ticks(0), iteration(0)
{
#if defined(USE_OPENGL) || defined(USE_GLES)
if (UseOpenGL) {
texture_width = texture_height = texture_name = 0;
}
#endif
}
@ -231,11 +199,6 @@ Mng::~Mng()
SDL_FreeSurface(surface);
}
delete[] buffer;
#if defined(USE_OPENGL) || defined(USE_GLES)
if (UseOpenGL && texture_width) {
glDeleteTextures(1, &texture_name);
}
#endif
}
@ -251,56 +214,8 @@ void Mng::Draw(int x, int y)
mng_display_resume(handle);
}
#if defined(USE_OPENGL) || defined(USE_GLES)
if (UseOpenGL) {
GLint sx = x;
GLint ex = sx + surface->w;
GLint sy = y;
GLint ey = sy + surface->h;
#ifdef USE_GLES
float texCoord[] = {
0.0f, 0.0f,
texture_width, 0.0f,
0.0f, texture_height,
texture_width, texture_height
};
float vertex[] = {
2.0f / (GLfloat)Video.Width *sx - 1.0f, -2.0f / (GLfloat)Video.Height *sy + 1.0f,
2.0f / (GLfloat)Video.Width *ex - 1.0f, -2.0f / (GLfloat)Video.Height *sy + 1.0f,
2.0f / (GLfloat)Video.Width *sx - 1.0f, -2.0f / (GLfloat)Video.Height *ey + 1.0f,
2.0f / (GLfloat)Video.Width *ex - 1.0f, -2.0f / (GLfloat)Video.Height *ey + 1.0f
};
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);
glTexCoordPointer(2, GL_FLOAT, 0, texCoord);
glVertexPointer(2, GL_FLOAT, 0, vertex);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
#endif
#ifdef USE_OPENGL
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f);
glVertex2i(sx, sy);
glTexCoord2f(0.0f, texture_height);
glVertex2i(sx, ey);
glTexCoord2f(texture_width, texture_height);
glVertex2i(ex, ey);
glTexCoord2f(texture_width, 0.0f);
glVertex2i(ex, sy);
glEnd();
#endif
} else
#endif
{
SDL_Rect rect = {(short int)x, (short int)y, (short unsigned int)(surface->w), (short unsigned int)(surface->h)};
SDL_BlitSurface(surface, NULL, TheScreen, &rect);
}
SDL_Rect rect = {(short int)x, (short int)y, (short unsigned int)(surface->w), (short unsigned int)(surface->h)};
SDL_BlitSurface(surface, NULL, TheScreen, &rect);
}
/**