]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Multisampling initialisation moved from vid_sdl to gl_backend. Make cubemaps array...
authorvortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 13 May 2011 21:37:16 +0000 (21:37 +0000)
committerRudolf Polzer <divVerent@xonotic.org>
Mon, 23 May 2011 11:32:58 +0000 (13:32 +0200)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11147 d7cf8633-e32d-0410-b094-e92efae38249
::stable-branch::merge=e272f5efe910b09242dd42c4044aa85bfe9b1710

gl_backend.c
gl_backend.h
gl_rmain.c
quakedef.h
vid_sdl.c
vid_shared.c

index 5fbf7979fc6ef37406d8bdd491726e427e91acbf..0efde34477e223b1edeea21309d3e338abed1a79 100644 (file)
@@ -2120,6 +2120,35 @@ void GL_CullFace(int state)
        }
 }
 
+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)
index 82b9ed4f0a654eb6abd9f0b0e3aa6227708d6ad4..8f6e5ab1c90d2b77449f676b025f6ffc6dc10a16 100644 (file)
@@ -40,6 +40,7 @@ void R_SetStencil(qboolean enable, int writemask, int fail, int zfail, int zpass
 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);
index 354160da4166f594ee9e76c55591b359d6facd62..6c0b6505e35f681a4ca019ae2cbd9967f13b9b57 100644 (file)
@@ -282,7 +282,7 @@ typedef struct cubemapinfo_s
 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;
@@ -3741,14 +3741,36 @@ rtexture_t *R_GetCubemap(const char *basename)
 {
        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)
@@ -3757,9 +3779,13 @@ 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;
 }
@@ -3911,6 +3937,9 @@ void gl_main_start(void)
        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;
 }
 
index 3ab283a288458dbddbe4885415510f69ffd48dab..2310bc2062e0143336e2c0b1e60de3583d2e96f0 100644 (file)
@@ -86,7 +86,7 @@ extern char engineversion[128];
 #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)
@@ -153,7 +153,7 @@ extern char engineversion[128];
 #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
index 2f9bba72c36a7186009c714a89ef26812b68c3e4..4fb37539e4a4117ae4c95e8e0a69a6d93e61e2e7 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -2151,27 +2151,6 @@ qboolean VID_InitModeGL(viddef_mode_t *mode)
        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);
index 05a19eacac624496779b2765fcac0e119062842b..fd5cbc71bc5365d7a64769bea3f90ec851107141 100644 (file)
@@ -1742,6 +1742,15 @@ void VID_Shared_Init(void)
 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;
@@ -1780,6 +1789,10 @@ int VID_Mode(int fullscreen, int width, int height, int bpp, float refreshrate,
                        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