PDGL_API void pdglTexParameteri(GLenum target, GLenum pname, GLint param) { if(pglTexParameteri) { pglTexParameteri(target, pname, param); return; } pglTexParameteri=pdglGetProcAddress("glTexParameteri"); pglTexParameteri(target, pname, param); }
/* =============== R_ShowTextures Draw all the images to the screen, on top of whatever was there. This is used to test for texture thrashing. =============== */ void R_ShowTextures( void ) { gltexture_t *image; float x, y, w, h; int i, j, k, base_w, base_h; int total, start, end; rgba_t color = { 192, 192, 192, 255 }; int charHeight, numTries = 0; static qboolean showHelp = true; string shortname; if( !gl_showtextures->integer ) return; if( showHelp ) { CL_CenterPrint( "use '<-' and '->' keys to view all the textures", 0.25f ); showHelp = false; } pglClear( GL_COLOR_BUFFER_BIT ); pglFinish(); base_w = 8; base_h = 6; rebuild_page: total = base_w * base_h; start = total * (gl_showtextures->integer - 1); end = total * gl_showtextures->integer; if( end > MAX_TEXTURES ) end = MAX_TEXTURES; w = glState.width / (float)base_w; h = glState.height / (float)base_h; Con_DrawStringLen( NULL, NULL, &charHeight ); for( i = j = 0; i < MAX_TEXTURES; i++ ) { image = R_GetTexture( i ); if( j == start ) break; // found start if( pglIsTexture( image->texnum )) j++; } if( i == MAX_TEXTURES && gl_showtextures->integer != 1 ) { // bad case, rewind to one and try again Cvar_SetFloat( "r_showtextures", max( 1, gl_showtextures->integer - 1 )); if( ++numTries < 2 ) goto rebuild_page; // to prevent infinite loop } for( k = 0; i < MAX_TEXTURES; i++ ) { if( j == end ) break; // page is full image = R_GetTexture( i ); if( !pglIsTexture( image->texnum )) continue; x = k % base_w * w; y = k / base_w * h; pglColor4f( 1.0f, 1.0f, 1.0f, 1.0f ); GL_Bind( XASH_TEXTURE0, i ); // NOTE: don't use image->texnum here, because skybox has a 'wrong' indexes if(( image->flags & TF_DEPTHMAP ) && !( image->flags & TF_NOCOMPARE )) pglTexParameteri( image->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE ); pglBegin( GL_QUADS ); pglTexCoord2f( 0, 0 ); pglVertex2f( x, y ); if( image->flags & TF_TEXTURE_RECTANGLE ) pglTexCoord2f( image->width, 0 ); else pglTexCoord2f( 1, 0 ); pglVertex2f( x + w, y ); if( image->flags & TF_TEXTURE_RECTANGLE ) pglTexCoord2f( image->width, image->height ); else pglTexCoord2f( 1, 1 ); pglVertex2f( x + w, y + h ); if( image->flags & TF_TEXTURE_RECTANGLE ) pglTexCoord2f( 0, image->height ); else pglTexCoord2f( 0, 1 ); pglVertex2f( x, y + h ); pglEnd(); if(( image->flags & TF_DEPTHMAP ) && !( image->flags & TF_NOCOMPARE )) pglTexParameteri( image->target, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB ); FS_FileBase( image->name, shortname ); if( Q_strlen( shortname ) > 18 ) { // cutoff too long names, it looks ugly shortname[16] = '.'; shortname[17] = '.'; shortname[18] = '\0'; } Con_DrawString( x + 1, y + h - charHeight, shortname, color ); j++, k++; } CL_DrawCenterPrint (); pglFinish(); }
SDL_bool blitter_opengl_init() { Uint32 sdl_flags; Uint32 width = visible_area.w; Uint32 height = visible_area.h; if (load_glproc() == SDL_FALSE) return SDL_FALSE; sdl_flags = (fullscreen?SDL_FULLSCREEN:0)| SDL_DOUBLEBUF | SDL_HWSURFACE | SDL_HWPALETTE | SDL_OPENGL | SDL_RESIZABLE; SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); if ((effect[neffect].x_ratio!=2 || effect[neffect].y_ratio!=2) && (effect[neffect].x_ratio!=1 || effect[neffect].y_ratio!=1) ) { printf("Opengl support only effect with a ratio of 2x2 or 1x1\n"); return SDL_FALSE; } /* if (conf.res_x==304 && conf.res_y==224) { */ if (scale < 2) { width *=effect[neffect].x_ratio; height*=effect[neffect].y_ratio; } width *= scale; height *= scale; /* } else { width = conf.res_x; height=conf.res_y; } */ conf.res_x=width; conf.res_y=height; video_opengl = SDL_SetVideoMode(width, height, 16, sdl_flags); if ( video_opengl == NULL) return SDL_FALSE; pglClearColor(0, 0, 0, 0); pglClear(GL_COLOR_BUFFER_BIT); pglEnable(GL_TEXTURE_2D); pglViewport(0, 0, width, height); /* Linear Filter */ pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); /* pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); */ /* Texture Mode */ pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); pglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); if (neffect == 0) { /* Texture limits */ /* a = (240.0/304.0); b = (48.0/256.0); c = (240.0/256.0); */ #ifdef USE_GL2 tex_opengl= SDL_CreateRGBSurface(SDL_SWSURFACE, 512, 256, 16, 0xF800, 0x7E0, 0x1F, 0); #else pglPixelStorei(GL_UNPACK_ROW_LENGTH, 352); #endif } else { /* Texture limits */ a = ((256.0/(float)visible_area.w) - 1.0f)*effect[neffect].x_ratio/2.0; b = ((512.0/(float)visible_area.w) - 1.0f)*effect[neffect].x_ratio/2.0; c = (((float)visible_area.h/256.0))*effect[neffect].y_ratio/2.0; d = (((float)((visible_area.w<<1)-512)/256.0))*effect[neffect].y_ratio/2.0; screen = SDL_CreateRGBSurface(SDL_SWSURFACE, visible_area.w<<1, /*visible_area.h<<1*/512, 16, 0xF800, 0x7E0, 0x1F, 0); //printf("[opengl] create_screen %p\n",screen); #ifdef USE_GL2 tex_opengl= SDL_CreateRGBSurface(SDL_SWSURFACE, 1024, 512, 16, 0xF800, 0x7E0, 0x1F, 0); if (visible_area.w==320) { glrectef.x=0; glrectef.y=0; glrectef.w=320*2; glrectef.h=224*2; } else { glrectef.x=0; glrectef.y=0; glrectef.w=304*2; glrectef.h=224*2; } #else pglPixelStorei(GL_UNPACK_ROW_LENGTH, visible_area.w<<1); #endif } return SDL_TRUE; }