Skip to content

Commit

Permalink
Refactor|GL: Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danij-deng committed Nov 21, 2013
1 parent 6b42110 commit fbb2988
Show file tree
Hide file tree
Showing 7 changed files with 138 additions and 139 deletions.
4 changes: 4 additions & 0 deletions doomsday/client/include/gl/gl_main.h
Expand Up @@ -269,6 +269,10 @@ boolean GL_OptimalTextureSize(int width, int height, boolean noStretch, boolean
*/
int GL_ChooseSmartFilter(int width, int height, int flags);

GLuint GL_NewTextureWithParams(dgltexformat_t format, int width, int height, uint8_t const *pixels, int flags);
GLuint GL_NewTextureWithParams(dgltexformat_t format, int width, int height, uint8_t const *pixels, int flags,
int grayMipmap, int minFilter, int magFilter, int anisoFilter, int wrapS, int wrapT);

/**
* in/out format:
* 1 = palette indices
Expand Down
12 changes: 4 additions & 8 deletions doomsday/client/include/gl/gl_texmanager.h
Expand Up @@ -103,16 +103,16 @@ texturevariantspecification_t &GL_DetailTextureSpec(float contrast);
void GL_LoadLightingSystemTextures();
void GL_ReleaseAllLightingSystemTextures();

DGLuint GL_PrepareLSTexture(lightingtexid_t which);
GLuint GL_PrepareLSTexture(lightingtexid_t which);

void GL_LoadFlareTextures();
void GL_ReleaseAllFlareTextures();

DGLuint GL_PrepareFlaremap(de::Uri const &resourceUri);
DGLuint GL_PrepareSysFlaremap(flaretexid_t which);
GLuint GL_PrepareFlaremap(de::Uri const &resourceUri);
GLuint GL_PrepareSysFlaremap(flaretexid_t which);


DGLuint GL_PrepareRawTexture(rawtex_t &rawTex);
GLuint GL_PrepareRawTexture(rawtex_t &rawTex);

/// Release all textures used with 'Raw Images'.
void GL_ReleaseTexturesForRawImages();
Expand All @@ -123,8 +123,4 @@ void GL_ReleaseTexturesForRawImages();
void GL_SetRawTexturesMinFilter(int minFilter);


DGLuint GL_NewTextureWithParams(dgltexformat_t format, int width, int height, uint8_t const *pixels, int flags);
DGLuint GL_NewTextureWithParams(dgltexformat_t format, int width, int height, uint8_t const *pixels, int flags,
int grayMipmap, int minFilter, int magFilter, int anisoFilter, int wrapS, int wrapT);

#endif // DENG_CLIENT_GL_TEXMANAGER_H
4 changes: 2 additions & 2 deletions doomsday/client/include/gl/texturecontent.h
Expand Up @@ -46,7 +46,7 @@
*/
typedef struct texturecontent_s {
dgltexformat_t format;
DGLuint name;
GLuint name;
uint8_t const *pixels;
colorpaletteid_t paletteId;
int width;
Expand Down Expand Up @@ -81,7 +81,7 @@ void GL_DestroyTextureContent(texturecontent_t *content);
* @param textureManifest Manifest for the logical texture being prepared.
* (for informational purposes, i.e., logging)
*/
void GL_PrepareTextureContent(texturecontent_t &c, DGLuint glTexName,
void GL_PrepareTextureContent(texturecontent_t &c, GLuint glTexName,
image_t &image, texturevariantspecification_t const &spec,
de::TextureManifest const &textureManifest);

Expand Down
9 changes: 5 additions & 4 deletions doomsday/client/include/resource/texturevariantspec.h
Expand Up @@ -66,12 +66,13 @@ typedef enum {
/*@}*/

typedef enum {
TEXTUREVARIANTSPECIFICATIONTYPE_FIRST = 0,
TST_GENERAL = TEXTUREVARIANTSPECIFICATIONTYPE_FIRST,
TST_DETAIL,
TEXTUREVARIANTSPECIFICATIONTYPE_LAST = TST_DETAIL
TST_GENERAL = 0,
TST_DETAIL
} texturevariantspecificationtype_t;

#define TEXTUREVARIANTSPECIFICATIONTYPE_FIRST TST_GENERAL
#define TEXTUREVARIANTSPECIFICATIONTYPE_LAST TST_DETAIL

#define TEXTUREVARIANTSPECIFICATIONTYPE_COUNT (\
TEXTUREVARIANTSPECIFICATIONTYPE_LAST + 1 - TEXTUREVARIANTSPECIFICATIONTYPE_FIRST )

Expand Down
56 changes: 56 additions & 0 deletions doomsday/client/src/gl/gl_main.cpp
Expand Up @@ -878,6 +878,62 @@ int GL_GetTexAnisoMul(int level)
return mul;
}

static void uploadContentUnmanaged(texturecontent_t const &content)
{
LOG_AS("uploadContentUnmanaged");
if(novideo) return;

gl::UploadMethod uploadMethod = GL_ChooseUploadMethod(&content);
if(uploadMethod == gl::Immediate)
{
LOG_DEBUG("Uploading texture (%i:%ix%i) while not busy! Should be precached in busy mode?")
<< content.name << content.width << content.height;
}

GL_UploadTextureContent(content, uploadMethod);
}

GLuint GL_NewTextureWithParams(dgltexformat_t format, int width, int height,
uint8_t const *pixels, int flags)
{
texturecontent_t c;

GL_InitTextureContent(&c);
c.name = GL_GetReservedTextureName();
c.format = format;
c.width = width;
c.height = height;
c.pixels = pixels;
c.flags = flags;

uploadContentUnmanaged(c);
return c.name;
}

GLuint GL_NewTextureWithParams(dgltexformat_t format, int width, int height,
uint8_t const *pixels, int flags, int grayMipmap, int minFilter, int magFilter,
int anisoFilter, int wrapS, int wrapT)
{
texturecontent_t c;

GL_InitTextureContent(&c);
c.name = GL_GetReservedTextureName();
c.format = format;
c.width = width;
c.height = height;
c.pixels = pixels;
c.flags = flags;
c.grayMipmap = grayMipmap;
c.minFilter = minFilter;
c.magFilter = magFilter;
c.anisoFilter = anisoFilter;
c.wrap[0] = wrapS;
c.wrap[1] = wrapT;

uploadContentUnmanaged(c);
return c.name;
}

void GL_SetMaterialUI2(Material *mat, gl::Wrapping wrapS, gl::Wrapping wrapT)
{
if(!mat) return; // @todo we need a "NULL material".
Expand Down

0 comments on commit fbb2988

Please sign in to comment.