/* Copyright (C) 1997-2001 Id Software, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // r_misc.c #include "gl_local.h" /* ================== R_InitParticleTexture ================== */ byte dottexture[8][8] = { {0,0,0,0,0,0,0,0}, {0,0,1,1,0,0,0,0}, {0,1,1,1,1,0,0,0}, {0,1,1,1,1,0,0,0}, {0,0,1,1,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, {0,0,0,0,0,0,0,0}, }; int ScaleToPower2 (int number) { int powers_of_two[] = {8,16,32,64,128,256,512, 0}; int i; for (i=0;powers_of_two[i];i++) { if (number<=powers_of_two[i]) return powers_of_two[i]; } return 512; } void LoadJPG ( char *name, byte **pic, int *width, int *height ); void LoadTGA ( char *name, byte **pic, int *width, int *height ); //faster if scaled i guess :p image_t *LoadPartImg (char *name, float scale) { byte *pic; int width, height, sHeight, sWidth, len=strlen(name); void (*PicLoad) ( char *name, byte **pic, int *width, int *height ); if (!strcmp(name+len-4, ".jpg")) PicLoad = LoadJPG; else if (!strcmp(name+len-4, ".tga")) PicLoad = LoadTGA; else if (!strcmp(name+len-4, ".pcx")) //just in case someone wants old style pics :/ PicLoad = LoadPCX; PicLoad (name, &pic, &width, &height); if (!pic) { ri.Sys_Error (ERR_FATAL, "Missing Particle Picture: %s", name); } sWidth = ScaleToPower2(width*scale); sHeight = ScaleToPower2(height*scale); GL_ResampleTexture ((unsigned *)pic, width, height, (unsigned *)pic, sWidth, sHeight); return GL_LoadPic (name, pic, sWidth, sHeight, it_part, 32); } float partscale; void SetParticlePicture (int num, char *name) { r_particletextures[num] = LoadPartImg(name, partscale); } void R_InitParticleTexture (void) { int x,y; byte data[8][8][4]; partscale = (float)((int)gl_partscale->value)*0.01; if (partscale>1) partscale=1; else if (partscale<0.01) partscale=0.01; r_particlebeam = LoadPartImg("particles/beam.jpg", partscale); for (x=0 ; x>8; buffer[14] = vid.height&255; buffer[15] = vid.height>>8; buffer[16] = 24; // pixel size qglReadPixels (0, 0, vid.width, vid.height, GL_RGB, GL_UNSIGNED_BYTE, buffer+18 ); // swap rgb to bgr c = 18+vid.width*vid.height*3; for (i=18 ; istring ); GL_TextureAlphaMode( gl_texturealphamode->string ); GL_TextureSolidMode( gl_texturesolidmode->string ); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, gl_filter_min); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, gl_filter_max); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); qglBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); GL_TexEnv( GL_REPLACE ); GL_UpdateSwapInterval(); } void GL_UpdateSwapInterval( void ) { if ( gl_swapinterval->modified ) { gl_swapinterval->modified = false; if ( !gl_state.stereo_enabled ) { #ifdef _WIN32 if ( qwglSwapIntervalEXT ) qwglSwapIntervalEXT( gl_swapinterval->value ); #endif } } }