]> 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)
committervortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 13 May 2011 21:37:16 +0000 (21:37 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11147 d7cf8633-e32d-0410-b094-e92efae38249

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 4cc7527c0beb53af0b79698cca63a896afa7f7ba..a712fe734636bcdea2a84138914b3ea1cbcbaba2 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 fdd70caaa2c386827c795f4d90ade552b1e771d2..193739941d84acb2d91249dce7bd6729d3898ba7 100644 (file)
--- a/vid_sdl.c
+++ b/vid_sdl.c
@@ -2292,27 +2292,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 aad8446ee4d76714ff714ff6bc0db196dbb66cdf..6f79d4d19f0dd41043e147a3e413b57acc894a13 100644 (file)
@@ -1304,6 +1304,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;
@@ -1342,6 +1351,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