Skip to content

Commit

Permalink
Continued texture upload refactoring:
Browse files Browse the repository at this point in the history
* Moved aquisition of a GL texture name for TextureVariant out of the prepare stage and into construction.
* Track the is_uploaded state for GL texture objects associated with TextureVariants separately to their GL texture name.
* Allow for re-preparing and uploading-of-replacement texture content without having to release and acquire a new GL texture name.
* R_InitColorPalettes should now be called from R_Init not GL_InitRefresh
  • Loading branch information
danij-deng committed Apr 5, 2011
1 parent a0cb741 commit 49c16e2
Show file tree
Hide file tree
Showing 8 changed files with 194 additions and 124 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/portable/include/gl_texmanager.h
Expand Up @@ -163,7 +163,7 @@ boolean GL_TexImageGrayMipmap(int glFormat, int loadFormat, const uint8_t* pixel
*
* @return The name of the texture.
*/
DGLuint GL_UploadTexture(const struct texturecontent_s* content);
DGLuint GL_UploadTextureContent(const struct texturecontent_s* content);

DGLuint GL_UploadTextureWithParams(const uint8_t* pixels, int width, int height,
dgltexformat_t texFormat, boolean flagGenerateMipmaps,
Expand Down
2 changes: 0 additions & 2 deletions doomsday/engine/portable/include/texturecontent.h
Expand Up @@ -67,6 +67,4 @@ texturecontent_t* GL_ConstructTextureContentCopy(const texturecontent_t* other);

void GL_DestroyTextureContent(texturecontent_t* content);

void GL_UploadTextureContent(const texturecontent_t* content);

#endif /* LIBDENG_TEXTURECONTENT_H */
46 changes: 34 additions & 12 deletions doomsday/engine/portable/include/texturevariant.h
Expand Up @@ -39,6 +39,14 @@ typedef enum {
#define VALID_TEXTUREVARIANT_ANALYSISID(id) (\
(id) >= TEXTUREVARIANT_ANALYSIS_FIRST && (id) < TEXTUREVARIANT_ANALYSIS_COUNT)

/**
* @defgroup textureVariantFlags Texture Variant Flags
* @{
*/
#define TVF_IS_MASKED 0x1 /// Texture contains alpha.
#define TVF_IS_UPLOADED 0x2 /// Texture has been uploaded to GL.
/**@}*/

typedef struct texturevariant_s {
/// Table of analyses object ptrs, used for various purposes depending
/// on the variant specification.
Expand All @@ -47,10 +55,10 @@ typedef struct texturevariant_s {
/// Superior Texture of which this is a derivative.
struct texture_s* _generalCase;

/// Set to @c true if the source image contains alpha.
boolean _isMasked;
/// @see textureVariantFlags
int _flags;

/// Name of the associated DGL texture.
/// Name of the associated GL texture object.
DGLuint _glName;

/// Prepared coordinates for the bottom right of the texture minus border.
Expand All @@ -61,32 +69,46 @@ typedef struct texturevariant_s {
} texturevariant_t;

/**
* @param generalCase Texture from which this variant is derived.
* @param glName GL-name of the associated texture object.
* @param spec Specification used to derive this variant. Ownership of
* specifcation is NOT given to the resultant TextureVariant
*/
texturevariant_t* TextureVariant_Construct(struct texture_s* generalCase,
texturevariantspecification_t* spec);
DGLuint glName, texturevariantspecification_t* spec);

void TextureVariant_Destruct(texturevariant_t* tex);

/// @return Superior Texture of which this is a derivative.
struct texture_s* TextureVariant_GeneralCase(const texturevariant_t* tex);

/// @return TextureVariantSpecification used to derive this variant.
texturevariantspecification_t* TextureVariant_Spec(const texturevariant_t* tex);

boolean TextureVariant_IsMasked(const texturevariant_t* tex);
void TextureVariant_SetMasked(texturevariant_t* tex, boolean yes);
void TextureVariant_FlagMasked(texturevariant_t* tex, boolean yes);

boolean TextureVariant_IsUploaded(const texturevariant_t* tex);
void TextureVariant_FlagUploaded(texturevariant_t* tex, boolean yes);

void TextureVariant_Coords(const texturevariant_t* tex, float* s, float* t);
void TextureVariant_SetCoords(texturevariant_t* tex, float s, float t);

texturevariantspecification_t* TextureVariant_Spec(const texturevariant_t* tex);
DGLuint TextureVariant_GLName(const texturevariant_t* tex);
void TextureVariant_SetGLName(texturevariant_t* tex, DGLuint glName);

/// @return Associated data for the specified analysis identifier.
void* TextureVariant_Analysis(const texturevariant_t* tex,
texturevariant_analysisid_t analysis);

void TextureVariant_AddAnalysis(texturevariant_t* tex, texturevariant_analysisid_t analysis,
void* data);

DGLuint TextureVariant_GLName(const texturevariant_t* tex);

void TextureVariant_SetGLName(texturevariant_t* tex, DGLuint glName);
/**
* Attach new analysis data to the variant. If data is already present
* it will be replaced.
*
* @param analysis Identifier of the data being attached.
* @param data Data to be attached. Ownership is given to the variant.
*/
void TextureVariant_AddAnalysis(texturevariant_t* tex,
texturevariant_analysisid_t analysis, void* data);

#endif /* LIBDENG_GL_TEXTUREVARIANT_H */
Expand Up @@ -87,8 +87,13 @@ typedef struct {
colorpalettetranslationspecification_t* translated;
} variantspecification_t;

/**
* Detail textures are faded to gray depending on the contrast
* factor. The texture is also progressively faded towards gray
* when each mipmap level is loaded.
*/
typedef struct {
uint8_t contrast; /// Fade-to-gray contrast factor.
uint8_t contrast;
} detailvariantspecification_t;

#define TS_NORMAL(ts) (&(ts)->data.variant)
Expand Down
1 change: 0 additions & 1 deletion doomsday/engine/portable/src/gl_main.c
Expand Up @@ -579,7 +579,6 @@ void GL_Init(void)
*/
void GL_InitRefresh(void)
{
R_InitColorPalettes();
GL_InitTextureManager();
GL_LoadSystemTextures();
}
Expand Down

0 comments on commit 49c16e2

Please sign in to comment.