}
}
+void GL_MultiSampling(qboolean state)
+{
+ switch(vid.renderpath)
+ {
+ case RENDERPATH_GL11:
+ case RENDERPATH_GL13:
+ case RENDERPATH_GLES1:
+ case RENDERPATH_GL20:
+ case RENDERPATH_GLES2:
+ if (vid.support.arb_multisample)
+ {
+ if (state)
+ qglEnable(GL_MULTISAMPLE_ARB);
+ else
+ qglDisable(GL_MULTISAMPLE_ARB);
+ CHECKGLERROR
+ }
+ break;
+ case RENDERPATH_D3D9:
+ break;
+ case RENDERPATH_D3D10:
+ break;
+ case RENDERPATH_D3D11:
+ break;
+ case RENDERPATH_SOFT:
+ break;
+ }
+}
+
void GL_AlphaTest(int state)
{
if (gl_state.alphatest != state)
void GL_PolygonOffset(float planeoffset, float depthoffset);
void GL_CullFace(int state);
void GL_AlphaTest(int state);
+void GL_MultiSampling(qboolean state);
void GL_ColorMask(int r, int g, int b, int a);
void GL_Color(float cr, float cg, float cb, float ca);
void GL_ActiveTexture(unsigned int num);
cubemapinfo_t;
int r_texture_numcubemaps;
-cubemapinfo_t r_texture_cubemaps[MAX_CUBEMAPS];
+cubemapinfo_t *r_texture_cubemaps[MAX_CUBEMAPS];
unsigned int r_queries[MAX_OCCLUSION_QUERIES];
unsigned int r_numqueries;
{
int i;
for (i = 0;i < r_texture_numcubemaps;i++)
- if (!strcasecmp(r_texture_cubemaps[i].basename, basename))
- return r_texture_cubemaps[i].texture ? r_texture_cubemaps[i].texture : r_texture_whitecube;
+ if (r_texture_cubemaps[i] != NULL)
+ if (!strcasecmp(r_texture_cubemaps[i]->basename, basename))
+ return r_texture_cubemaps[i]->texture ? r_texture_cubemaps[i]->texture : r_texture_whitecube;
if (i >= MAX_CUBEMAPS)
return r_texture_whitecube;
r_texture_numcubemaps++;
- strlcpy(r_texture_cubemaps[i].basename, basename, sizeof(r_texture_cubemaps[i].basename));
- r_texture_cubemaps[i].texture = R_LoadCubemap(r_texture_cubemaps[i].basename);
- return r_texture_cubemaps[i].texture;
+ r_texture_cubemaps[i] = (cubemapinfo_t *)Mem_Alloc(r_main_mempool, sizeof(cubemapinfo_t));
+ strlcpy(r_texture_cubemaps[i]->basename, basename, sizeof(r_texture_cubemaps[i]->basename));
+ r_texture_cubemaps[i]->texture = R_LoadCubemap(r_texture_cubemaps[i]->basename);
+ return r_texture_cubemaps[i]->texture;
+}
+
+void R_FreeCubemap(const char *basename)
+{
+ int i;
+
+ for (i = 0;i < r_texture_numcubemaps;i++)
+ {
+ if (r_texture_cubemaps[i] != NULL)
+ {
+ if (r_texture_cubemaps[i]->texture)
+ {
+ if (developer_loading.integer)
+ Con_DPrintf("unloading cubemap \"%s\"\n", r_texture_cubemaps[i]->basename);
+ R_FreeTexture(r_texture_cubemaps[i]->texture);
+ Mem_Free(r_texture_cubemaps[i]);
+ r_texture_cubemaps[i] = NULL;
+ }
+ }
+ }
}
void R_FreeCubemaps(void)
for (i = 0;i < r_texture_numcubemaps;i++)
{
if (developer_loading.integer)
- Con_DPrintf("unloading cubemap \"%s\"\n", r_texture_cubemaps[i].basename);
- if (r_texture_cubemaps[i].texture)
- R_FreeTexture(r_texture_cubemaps[i].texture);
+ Con_DPrintf("unloading cubemap \"%s\"\n", r_texture_cubemaps[i]->basename);
+ if (r_texture_cubemaps[i] != NULL)
+ {
+ if (r_texture_cubemaps[i]->texture)
+ R_FreeTexture(r_texture_cubemaps[i]->texture);
+ Mem_Free(r_texture_cubemaps[i]);
+ }
}
r_texture_numcubemaps = 0;
}
hlslshaderstring = NULL;
memset(&r_svbsp, 0, sizeof (r_svbsp));
+ memset(r_texture_cubemaps, 0, sizeof(r_texture_cubemaps));
+ r_texture_numcubemaps = 0;
+
r_refdef.fogmasktable_density = 0;
}
#define MAX_NETWM_ICON 1026 // one 32x32
#define MAX_WATERPLANES 2
-#define MAX_CUBEMAPS 64
+#define MAX_CUBEMAPS 1024
#define MAX_EXPLOSIONS 8
#define MAX_DLIGHTS 16
#define MAX_CACHED_PICS 1024 // this is 144 bytes each (or 152 on 64bit)
#define MAX_NETWM_ICON 352822 // 16x16, 22x22, 24x24, 32x32, 48x48, 64x64, 128x128, 256x256, 512x512
#define MAX_WATERPLANES 16 ///< max number of water planes visible (each one causes additional view renders)
-#define MAX_CUBEMAPS 256 ///< max number of cubemap textures loaded for light filters
+#define MAX_CUBEMAPS 1024 ///< max number of cubemap textures loaded for light filters
#define MAX_EXPLOSIONS 64 ///< max number of explosion shell effects active at once (not particle related)
#define MAX_DLIGHTS 256 ///< max number of dynamic lights (rocket flashes, etc) in scene at once
#define MAX_CACHED_PICS 1024 ///< max number of 2D pics loaded at once
vid_hasfocus = true;
vid_usingmouse = false;
vid_usinghidecursor = false;
-
- // enable multisampling
- if (vid_multisampling.integer)
- {
- if (vid.support.arb_multisample)
- {
- qglEnable(GL_MULTISAMPLE_ARB);
- // it seems that enabling GL_MULTISAMPLE_ARB forces antialiasing to always work, fix the cvar as well
- // make sure vid_sample is at least 2 to make things correct
- if (vid_samples.integer < 2)
- Cvar_SetValueQuick(&vid_samples, 0);
- }
- else
- {
- Cvar_SetValueQuick(&vid_multisampling, 0);
- qglDisable(GL_MULTISAMPLE_ARB);
- }
- }
- else
- qglDisable(GL_MULTISAMPLE_ARB);
- CHECKGLERROR
#if SETVIDEOMODE
SDL_WM_GrabInput(SDL_GRAB_OFF);
int VID_Mode(int fullscreen, int width, int height, int bpp, float refreshrate, int stereobuffer, int samples)
{
viddef_mode_t mode;
+
+ // multisampling should set at least 2 samples
+ if (vid.support.arb_multisample)
+ {
+ GL_MultiSampling(false);
+ if (vid_multisampling.integer)
+ samples = max(2, samples);
+ }
+
memset(&mode, 0, sizeof(mode));
mode.fullscreen = fullscreen != 0;
mode.width = width;
Cvar_SetValueQuick(&vid_refreshrate, vid.mode.refreshrate);
Cvar_SetValueQuick(&vid_stereobuffer, vid.mode.stereobuffer);
+ // activate multisampling
+ if (vid_multisampling.integer)
+ GL_MultiSampling(true);
+
return true;
}
else