]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - gl_textures.c
Add gl_debug cvar, if enabled the GL context will have GL_ARB_debug_output enabled...
[xonotic/darkplaces.git] / gl_textures.c
index 9c1f5f171431ff6d0605be33935ff360c74a96dd..bae61044d54b531229b3d79dc7bcc1ca2e5066aa 100644 (file)
@@ -205,7 +205,6 @@ typedef struct gltexture_s
        // palette if the texture is TEXTYPE_PALETTE
        const unsigned int *palette;
        // actual stored texture size after gl_picmip and gl_max_size are applied
-       // (power of 2 if vid.support.arb_texture_non_power_of_two is not supported)
        int tilewidth, tileheight, tiledepth;
        // 1 or 6 depending on texturetype
        int sides;
@@ -352,7 +351,7 @@ void R_FreeTexture(rtexture_t *rt)
 
        switch(vid.renderpath)
        {
-       case RENDERPATH_GL20:
+       case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
                if (glt->texnum)
                {
@@ -462,7 +461,7 @@ static void GL_TextureMode_f (void)
 
        switch(vid.renderpath)
        {
-       case RENDERPATH_GL20:
+       case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
                // change all the existing mipmap texture objects
                // FIXME: force renderer(/client/something?) restart instead?
@@ -517,21 +516,9 @@ static void GL_Texture_CalcImageSize(int texturetype, int flags, int miplevel, i
                break;
        }
 
-       if (vid.support.arb_texture_non_power_of_two)
-       {
-               width2 = min(inwidth >> picmip, maxsize);
-               height2 = min(inheight >> picmip, maxsize);
-               depth2 = min(indepth >> picmip, maxsize);
-       }
-       else
-       {
-               for (width2 = 1;width2 < inwidth;width2 <<= 1);
-               for (width2 >>= picmip;width2 > maxsize;width2 >>= 1);
-               for (height2 = 1;height2 < inheight;height2 <<= 1);
-               for (height2 >>= picmip;height2 > maxsize;height2 >>= 1);
-               for (depth2 = 1;depth2 < indepth;depth2 <<= 1);
-               for (depth2 >>= picmip;depth2 > maxsize;depth2 >>= 1);
-       }
+       width2 = min(inwidth >> picmip, maxsize);
+       height2 = min(inheight >> picmip, maxsize);
+       depth2 = min(indepth >> picmip, maxsize);
 
        miplevels = 1;
        if (flags & TEXF_MIPMAP)
@@ -633,7 +620,7 @@ static void r_textures_start(void)
 {
        switch(vid.renderpath)
        {
-       case RENDERPATH_GL20:
+       case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
                // LordHavoc: allow any alignment
                CHECKGLERROR
@@ -688,7 +675,7 @@ static void r_textures_devicelost(void)
                        continue;
                switch(vid.renderpath)
                {
-               case RENDERPATH_GL20:
+               case RENDERPATH_GL32:
                case RENDERPATH_GLES2:
                        break;
                }
@@ -707,7 +694,7 @@ static void r_textures_devicerestored(void)
                        continue;
                switch(vid.renderpath)
                {
-               case RENDERPATH_GL20:
+               case RENDERPATH_GL32:
                case RENDERPATH_GLES2:
                        break;
                }
@@ -785,7 +772,7 @@ void R_Textures_Frame (void)
 
                switch(vid.renderpath)
                {
-               case RENDERPATH_GL20:
+               case RENDERPATH_GL32:
                case RENDERPATH_GLES2:
                        // ignore the first difference, any textures loaded by now probably had the same aniso value
                        if (first_time_aniso)
@@ -910,13 +897,11 @@ static void GL_SetupTextureParameters(int flags, textype_t textype, int texturet
        case TEXTYPE_SHADOWMAP24_COMP:
                qglTexParameteri(textureenum, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);CHECKGLERROR
                qglTexParameteri(textureenum, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);CHECKGLERROR
-               qglTexParameteri(textureenum, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);CHECKGLERROR
                break;
        case TEXTYPE_SHADOWMAP16_RAW:
        case TEXTYPE_SHADOWMAP24_RAW:
                qglTexParameteri(textureenum, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);CHECKGLERROR
                qglTexParameteri(textureenum, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);CHECKGLERROR
-               qglTexParameteri(textureenum, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);CHECKGLERROR
                break;
        default:
                break;
@@ -947,7 +932,7 @@ static void R_UploadPartialTexture(gltexture_t *glt, const unsigned char *data,
 
        switch(vid.renderpath)
        {
-       case RENDERPATH_GL20:
+       case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
                {
                        int oldbindtexnum;
@@ -1033,7 +1018,7 @@ static void R_UploadFullTexture(gltexture_t *glt, const unsigned char *data)
        // do the appropriate upload type...
        switch(vid.renderpath)
        {
-       case RENDERPATH_GL20:
+       case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
                if (glt->texnum) // not renderbuffers
                {
@@ -1212,17 +1197,6 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
                }
        }
 
-       if (texturetype == GLTEXTURETYPE_CUBEMAP && !vid.support.arb_texture_cube_map)
-       {
-               Con_Printf ("R_LoadTexture: cubemap texture not supported by driver\n");
-               return NULL;
-       }
-       if (texturetype == GLTEXTURETYPE_3D && !vid.support.ext_texture_3d)
-       {
-               Con_Printf ("R_LoadTexture: 3d texture not supported by driver\n");
-               return NULL;
-       }
-
        texinfo = R_GetTexTypeInfo(textype, flags);
        size = width * height * depth * sides * texinfo->inputbytesperpixel;
        if (size < 1)
@@ -1340,7 +1314,7 @@ static rtexture_t *R_SetupTexture(rtexturepool_t *rtexturepool, const char *iden
        // data may be NULL (blank texture for dynamic rendering)
        switch(vid.renderpath)
        {
-       case RENDERPATH_GL20:
+       case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
                CHECKGLERROR
                qglGenTextures(1, (GLuint *)&glt->texnum);CHECKGLERROR
@@ -1427,7 +1401,7 @@ rtexture_t *R_LoadTextureRenderBuffer(rtexturepool_t *rtexturepool, const char *
        // data may be NULL (blank texture for dynamic rendering)
        switch(vid.renderpath)
        {
-       case RENDERPATH_GL20:
+       case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
                CHECKGLERROR
                qglGenRenderbuffers(1, (GLuint *)&glt->renderbuffernum);CHECKGLERROR
@@ -1598,7 +1572,7 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
        unsigned char *dds;
        fs_offset_t ddsfilesize;
        unsigned int ddssize;
-       qboolean force_swdecode, npothack;
+       qboolean force_swdecode;
 #ifdef __ANDROID__
        // ELUAN: FIXME: separate this code
        char vabuf[1024];
@@ -1919,17 +1893,9 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
        }
 
        force_swdecode = false;
-       npothack = 
-               (!vid.support.arb_texture_non_power_of_two &&
-                       (
-                               (dds_width & (dds_width - 1))
-                               ||
-                               (dds_height & (dds_height - 1))
-                       )
-               );
        if(bytesperblock)
        {
-               if(vid.support.arb_texture_compression && vid.support.ext_texture_compression_s3tc && !npothack)
+               if(vid.support.arb_texture_compression && vid.support.ext_texture_compression_s3tc)
                {
                        if(r_texture_dds_swdecode.integer > 1)
                                force_swdecode = true;
@@ -2207,19 +2173,13 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
        glt->tiledepth = 1;
        glt->miplevels = dds_miplevels;
 
-       if(npothack)
-       {
-               for (glt->tilewidth = 1;glt->tilewidth < mipwidth;glt->tilewidth <<= 1);
-               for (glt->tileheight = 1;glt->tileheight < mipheight;glt->tileheight <<= 1);
-       }
-
        // texture uploading can take a while, so make sure we're sending keepalives
        CL_KeepaliveMessage(false);
 
        // create the texture object
        switch(vid.renderpath)
        {
-       case RENDERPATH_GL20:
+       case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
                CHECKGLERROR
                GL_ActiveTexture(0);
@@ -2241,22 +2201,9 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
                mipsize = bytesperblock ? ((mipwidth+3)/4)*((mipheight+3)/4)*bytesperblock : mipwidth*mipheight*bytesperpixel;
                if (mippixels + mipsize > mippixels_start + mipsize_total)
                        break;
-               if(npothack)
-               {
-                       upload_mipwidth = (glt->tilewidth >> mip);
-                       upload_mipheight = (glt->tileheight >> mip);
-                       if(upload_mipwidth != mipwidth || upload_mipheight != mipheight)
-                       // I _think_ they always mismatch, but I was too lazy
-                       // to properly check, and this test here is really
-                       // harmless
-                       {
-                               upload_mippixels = (unsigned char *) Mem_Alloc(tempmempool, 4 * upload_mipwidth * upload_mipheight);
-                               Image_Resample32(mippixels, mipwidth, mipheight, 1, upload_mippixels, upload_mipwidth, upload_mipheight, 1, r_lerpimages.integer);
-                       }
-               }
                switch(vid.renderpath)
                {
-               case RENDERPATH_GL20:
+               case RENDERPATH_GL32:
                case RENDERPATH_GLES2:
                        if (bytesperblock)
                        {
@@ -2285,7 +2232,7 @@ rtexture_t *R_LoadTextureDDSFile(rtexturepool_t *rtexturepool, const char *filen
        // after upload we have to set some parameters...
        switch(vid.renderpath)
        {
-       case RENDERPATH_GL20:
+       case RENDERPATH_GL32:
        case RENDERPATH_GLES2:
 #ifdef GL_TEXTURE_MAX_LEVEL
                if (dds_miplevels >= 1 && !mipcomplete)