PDGL_API void pdglTexImage2D(GLenum target, GLint level, GLint internalFormat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels) { if(pglTexImage2D) { pglTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); return; } pglTexImage2D=pdglGetProcAddress("glTexImage2D"); pglTexImage2D(target, level, internalFormat, width, height, border, format, type, pixels); }
/* ============= R_UploadStretchRaw ============= */ void R_UploadStretchRaw( int texture, int cols, int rows, int width, int height, const byte *data ) { byte *raw = NULL; gltexture_t *tex; if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT )) { // check the dimensions width = NearestPOW( width, true ); height = NearestPOW( height, false ); } else { width = bound( 128, width, glConfig.max_2d_texture_size ); height = bound( 128, height, glConfig.max_2d_texture_size ); } if( cols != width || rows != height ) { raw = GL_ResampleTexture( data, cols, rows, width, height, false ); cols = width; rows = height; } else { raw = (byte *)data; } if( cols > glConfig.max_2d_texture_size ) Host_Error( "R_UploadStretchRaw: size %i exceeds hardware limits\n", cols ); if( rows > glConfig.max_2d_texture_size ) Host_Error( "R_UploadStretchRaw: size %i exceeds hardware limits\n", rows ); tex = R_GetTexture( texture ); GL_Bind( GL_TEXTURE0, texture ); tex->width = cols; tex->height = rows; pglTexImage2D( GL_TEXTURE_2D, 0, tex->format, cols, rows, 0, GL_BGRA, GL_UNSIGNED_BYTE, raw ); GL_TexFilter( tex, false ); }
/* ============= R_DrawStretchRaw ============= */ void R_DrawStretchRaw( float x, float y, float w, float h, int cols, int rows, const byte *data, qboolean dirty ) { byte *raw = NULL; gltexture_t *tex; if( !GL_Support( GL_ARB_TEXTURE_NPOT_EXT )) { int width = 1, height = 1; // check the dimensions width = NearestPOW( cols, true ); height = NearestPOW( rows, false ); if( cols != width || rows != height ) { raw = GL_ResampleTexture( data, cols, rows, width, height, false ); cols = width; rows = height; } } else { raw = (byte *)data; } if( cols > glConfig.max_2d_texture_size ) Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", cols ); if( rows > glConfig.max_2d_texture_size ) Host_Error( "R_DrawStretchRaw: size %i exceeds hardware limits\n", rows ); pglDisable( GL_BLEND ); pglDisable( GL_ALPHA_TEST ); pglTexEnvi( GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE ); tex = R_GetTexture( tr.cinTexture ); GL_Bind( GL_TEXTURE0, tr.cinTexture ); if( cols == tex->width && rows == tex->height ) { if( dirty ) { pglTexSubImage2D( GL_TEXTURE_2D, 0, 0, 0, cols, rows, GL_BGRA, GL_UNSIGNED_BYTE, raw ); } } else { tex->width = cols; tex->height = rows; if( dirty ) { pglTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA, cols, rows, 0, GL_BGRA, GL_UNSIGNED_BYTE, raw ); } } pglBegin( GL_QUADS ); pglTexCoord2f( 0, 0 ); pglVertex2f( x, y ); pglTexCoord2f( 1, 0 ); pglVertex2f( x + w, y ); pglTexCoord2f( 1, 1 ); pglVertex2f( x + w, y + h ); pglTexCoord2f( 0, 1 ); pglVertex2f( x, y + h ); pglEnd(); }
void blitter_opengl_update() { float VALA=512/(float)visible_area.w-1.0; /* 240.0f*2.0f/304.0f - 1.0f */ int VALB=.0625; /* 16.0f/256.0f */ int VALC=.9375; /* 240.0f/256.0f */ //int VALD .25 /* 64.0f/256.0f */ int VALD=1.0; if (neffect == 0) { #ifndef USE_GL2 pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer->pixels + (visible_area.x<<1)); pglBegin(GL_QUADS); //pglTexCoord2f(16.0f/256.0f, 16.0f/256.0f); //pglVertex2f (-1.0f, 1.0f); pglTexCoord2f(0.0f, 16.0f/256.0f); pglVertex2f (-1.0f, 1.0f); pglTexCoord2f(1.0f, 16.0f/256.0f); pglVertex2f (VALA, 1.0f); pglTexCoord2f(1.0f, 1.0f-16.0f/256.0f); pglVertex2f (VALA, -1.0f); pglTexCoord2f(0.0f, 1.0f-16.0f/256.0f); pglVertex2f (-1.0f, -1.0f); pglEnd(); pglTexImage2D(GL_TEXTURE_2D, 0, 3, 64, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, buffer->pixels + 512+ (visible_area.x<<1)); pglBegin(GL_QUADS); pglTexCoord2f(0.0f, 16.0f/256.0f); pglVertex2f (VALA, 1.0f); pglTexCoord2f(1.0, 16.0f/256.0f); pglVertex2f (1.0f, 1.0f); pglTexCoord2f(1.0, 1.0f-16.0f/256.0f); pglVertex2f (1.0f, -1.0f); pglTexCoord2f(0.0f, 1.0f-16.0f/256.0f); pglVertex2f (VALA, -1.0f); pglEnd(); #else SDL_BlitSurface(buffer, &visible_area, tex_opengl, NULL); pglTexImage2D(GL_TEXTURE_2D, 0, 3, 512, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, tex_opengl->pixels); pglBegin(GL_QUADS); pglTexCoord2f(0.0f, 0.0f); pglVertex2f (-1.0f, 1.0f); pglTexCoord2f((float)visible_area.w/512.0f, 0.0f); pglVertex2f (1.0f, 1.0f); pglTexCoord2f((float)visible_area.w/512.0f, 1.0f-32.0f/256.0f); pglVertex2f (1.0f, -1.0f); pglTexCoord2f(0.0f, 1.0f-32.0f/256.0f); pglVertex2f (-1.0f, -1.0f); pglEnd(); #endif } else { #ifndef USE_GL2 pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels ); pglBegin(GL_QUADS); pglTexCoord2f(0.0f, 0.0f); pglVertex2f (-1.0f, 1.0f); pglTexCoord2f(1.0f, 0.0f); pglVertex2f (a, 1.0f); pglTexCoord2f(1.0f, c); pglVertex2f (a, 0.0f); pglTexCoord2f(0.0f, c); pglVertex2f (-1.0f, 0.0f); pglEnd(); pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + 512 ); pglBegin(GL_QUADS); pglTexCoord2f(0.0f, 0.0f); pglVertex2f (a, 1.0f); pglTexCoord2f(1.0f, 0.0f); pglVertex2f (b, 1.0f); pglTexCoord2f(1.0f, c); pglVertex2f (b, 0.0f); pglTexCoord2f(0.0f, c); pglVertex2f (a, 0.0f); pglEnd(); pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + 1024 ); pglBegin(GL_QUADS); pglTexCoord2f(0.0f, 0.0f); pglVertex2f (b, 1.0f); pglTexCoord2f(d, 0.0f); pglVertex2f (1.0f, 1.0f); pglTexCoord2f(d, c); pglVertex2f (1.0f, 0.0f); pglTexCoord2f(0.0f, c); pglVertex2f (b, 0.0f); pglEnd(); pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + (visible_area.w<<2) * 224 ); pglBegin(GL_QUADS); pglTexCoord2f(0.0f, 0.0f); pglVertex2f (-1.0f, 0.0f); pglTexCoord2f(1.0f, 0.0f); pglVertex2f (a, 0.0f); pglTexCoord2f(1.0f, c); pglVertex2f (a, -1.0f); pglTexCoord2f(0.0f, c); pglVertex2f (-1.0f, -1.0f); pglEnd(); pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + (visible_area.w<<2) * 224 + 512 ); pglBegin(GL_QUADS); pglTexCoord2f(0.0f, 0.0f); pglVertex2f (a, 0.0f); pglTexCoord2f(1.0f, 0.0f); pglVertex2f (b, 0.0f); pglTexCoord2f(1.0f, c); pglVertex2f (b, -1.0f); pglTexCoord2f(0.0f, c); pglVertex2f (a, -1.0f); pglEnd(); pglTexImage2D(GL_TEXTURE_2D, 0, 3, 256, 256, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, screen->pixels + (visible_area.w<<2) * 224 + 1024 ); pglBegin(GL_QUADS); pglTexCoord2f(0.0f, 0.0f); pglVertex2f (b, 0.0f); pglTexCoord2f(d, 0.0f); pglVertex2f (1.0f, 0.0f); pglTexCoord2f(d, c); pglVertex2f (1.0f, -1.0f); pglTexCoord2f(0.0f, c); pglVertex2f (b, -1.0f); pglEnd(); #else SDL_BlitSurface(screen, &glrectef, tex_opengl, NULL); pglTexImage2D(GL_TEXTURE_2D, 0, 3, 1024, 512, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, tex_opengl->pixels); pglBegin(GL_QUADS); pglTexCoord2f(0.0f, 0.0f); pglVertex2f (-1.0f, 1.0f); pglTexCoord2f((float)visible_area.w*2/1024.0f, 0.0f); pglVertex2f (1.0f, 1.0f); pglTexCoord2f((float)visible_area.w*2/1024.0f, 448.0f/512.0f); pglVertex2f (1.0f, -1.0f); pglTexCoord2f(0.0f, 448.0f/512.0f); pglVertex2f (-1.0f, -1.0f); pglEnd(); #endif } SDL_GL_SwapBuffers(); }