Skip to content

Commit

Permalink
Fixed sky fade color and glowing plane color and point light color an…
Browse files Browse the repository at this point in the history
…alyses when the source image was loaded from somewhere other than the default texture namespace for the associated texture usage context.

Fixed detail and shiny textures.
Further refactoring and cleanup.
  • Loading branch information
danij-deng committed Mar 20, 2011
1 parent 7c66690 commit 34600a4
Show file tree
Hide file tree
Showing 29 changed files with 435 additions and 310 deletions.
1 change: 1 addition & 0 deletions doomsday/build/codeblocks/doomsday.cbp
Expand Up @@ -366,6 +366,7 @@
<Unit filename="..\..\engine\portable\include\texture.h" />
<Unit filename="..\..\engine\portable\include\texturecontent.h" />
<Unit filename="..\..\engine\portable\include\texturevariant.h" />
<Unit filename="..\..\engine\portable\include\texturespecification.h" />
<Unit filename="..\..\engine\portable\include\ui_main.h" />
<Unit filename="..\..\engine\portable\include\ui_mpi.h" />
<Unit filename="..\..\engine\portable\include\ui_panel.h" />
Expand Down
4 changes: 4 additions & 0 deletions doomsday/build/win32/vs8/doomsday.vcproj
Expand Up @@ -3265,6 +3265,10 @@
RelativePath="..\..\..\engine\portable\include\texturevariant.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\texturevariantspecification.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\ui2_main.h"
>
Expand Down
21 changes: 11 additions & 10 deletions doomsday/engine/portable/include/gl_texmanager.h
Expand Up @@ -33,6 +33,7 @@
#include "r_model.h"
#include "gl_model.h"
#include "gl_defer.h"
#include "texturevariantspecification.h"

#define TEXQ_BEST 8
#define MINTEXWIDTH 8
Expand All @@ -42,7 +43,7 @@ struct image_s;
struct texturecontent_s;
struct texture_s;
struct texturevariant_s;
struct texturevariantspecification_s;
texturevariantspecification_t;

extern int ratioLimit;
extern int mipmapping, filterUI, texQuality, filterSprites;
Expand Down Expand Up @@ -242,7 +243,7 @@ boolean GL_OptimalTextureSize(int width, int height, boolean noStretch,
*
* @param spec Specification to echo.
*/
void GL_PrintTextureVariantSpecification(const struct texturevariantspecification_s* spec);
void GL_PrintTextureVariantSpecification(const texturevariantspecification_t* spec);

/**
* Prepare a TextureVariantSpecification according to usage context.
Expand All @@ -252,29 +253,29 @@ void GL_PrintTextureVariantSpecification(const struct texturevariantspecificatio
* @return Ptr to a rationalized and valid TextureVariantSpecification
* or @c NULL if out of memory.
*/
struct texturevariantspecification_s* GL_TextureVariantSpecificationForContext(
const struct texture_s* tex, void* context);
texturevariantspecification_t* GL_TextureVariantSpecificationForContext(
texturespecificationtype_t type, textureusagecontext_t tc, void* context);

struct texturevariant_s* GL_FindSuitableTextureVariant(struct texture_s* tex,
const struct texturevariantspecification_s* spec);
const texturevariantspecification_t* spec);

void GL_ReleaseGLTexturesForTexture(struct texture_s* tex);

struct texture_s* GL_ToTexture(textureid_t id);

/**
* Attempt to prepare (upload to GL) an instance of Texture which fulfills
* the variant specification defined by the usage context.
* Attempt to prepare a variant of Texture which fulfills the specification
* defined by the usage context.
*
* @param context Usage-specific context data (if any).
* @param spec Variant specification for the proposed usage context.
* @param result Result of this process:
* @c 0== Failed: No suitable variant could be found/prepared.
* @c 1== Success: Suitable variant prepared from an original resource.
* @c 2== Success: Suitable variant prepared from a replacement resource.
* @return Prepared variant if successful else @c NULL.
*/
const struct texturevariant_s* GL_PrepareTexture(textureid_t id, void* context,
byte* result);
const struct texturevariant_s* GL_PrepareTexture(textureid_t id,
texturevariantspecification_t* spec, byte* result);

const struct texture_s* GL_CreateTexture(const char* name, uint index, texturenamespaceid_t texNamespace);

Expand Down
10 changes: 0 additions & 10 deletions doomsday/engine/portable/include/p_material.h
Expand Up @@ -28,16 +28,6 @@

struct texturevariant_s;

typedef struct material_load_params_s {
boolean prepareForSkySphere;
int tmap, tclass;
boolean pSprite;
struct {
byte flags; /// @see textureFlags
byte border;
} tex;
} material_load_params_t;

// Material texture unit idents:
enum {
MTU_PRIMARY,
Expand Down
4 changes: 3 additions & 1 deletion doomsday/engine/portable/include/p_materialmanager.h
Expand Up @@ -28,6 +28,7 @@
#include "gl_texmanager.h"
#include "def_data.h"
#include "p_material.h"
#include "texturevariantspecification.h"

void P_MaterialsRegister(void);

Expand Down Expand Up @@ -88,7 +89,8 @@ const ded_reflection_t* Materials_Reflection(materialnum_t num);
const ded_decor_t* Materials_Decoration(materialnum_t num);
const ded_ptcgen_t* Materials_PtcGen(materialnum_t num);

byte Materials_Prepare(struct material_snapshot_s* snapshot, material_t* mat, boolean smoothed, struct material_load_params_s* params);
byte Materials_Prepare(struct material_snapshot_s* snapshot, material_t* mat,
boolean smoothed, texturevariantspecification_t* texSpec);

int Materials_AnimGroupCount(void);
void Materials_ResetAnimGroups(void);
Expand Down
1 change: 1 addition & 0 deletions doomsday/engine/portable/include/rend_main.h
Expand Up @@ -44,6 +44,7 @@ extern float rendLightDistanceAttentuation;
extern float lightModRange[255];
extern int devRendSkyMode;
extern float glowingTextures;
extern int useShinySurfaces;

void Rend_Register(void);
void Rend_Init(void);
Expand Down
55 changes: 4 additions & 51 deletions doomsday/engine/portable/include/texturevariant.h
Expand Up @@ -25,62 +25,15 @@
#ifndef LIBDENG_GL_TEXTUREVARIANT_H
#define LIBDENG_GL_TEXTUREVARIANT_H

struct texture_s;

/**
* @defGroup textureFlags Texture Flags
*/
/*@{*/
#define TF_ZEROMASK 0x1 // Zero the alpha of loaded textures.
#define TF_NO_COMPRESSION 0x2 // Do not compress the loaded textures.
#define TF_UPSCALE_AND_SHARPEN 0x4
#define TF_MONOCHROME 0x8
/*@}*/
#include "texturevariantspecification.h"

typedef enum {
TEXTURESPECIFICATIONTYPE_FIRST = 0,
TS_SYSTEM = TEXTURESPECIFICATIONTYPE_FIRST,
TS_FLAT,
TS_PATCHCOMPOSITE,
TS_PATCHSPRITE,
TS_PATCH,
TS_DETAIL,
TS_REFLECTION,
TS_MASK,
TS_MODELSKIN,
TS_MODELREFLECTIONSKIN,
TS_LIGHTMAP,
TS_FLAREMAP,
TEXTURESPECIFICATIONTYPE_LAST = TS_FLAREMAP
} texturespecificationtype_t;

#define TEXTURESPECIFICATIONTYPE_COUNT (\
TEXTURESPECIFICATIONTYPE_LAST + 1 - TEXTURESPECIFICATIONTYPE_FIRST )

#define VALID_TEXTURESPECIFICATIONTYPE(t) (\
(t) >= TEXTURESPECIFICATIONTYPE_FIRST && (t) <= TEXTURESPECIFICATIONTYPE_LAST)

typedef struct texturevariantspecification_s {
texturespecificationtype_t type;
byte flags; /// @see textureFlags
byte border; /// In pixels, added to all four edges of the texture.
boolean prepareForSkySphere;
union {
struct {
boolean pSprite; // @c true, iff this is for use as a psprite.
int tclass, tmap; // Color translation.
} sprite;
struct {
float contrast;
} detail;
} data; // type-specific data.
} texturevariantspecification_t;
struct texture_s;

typedef enum {
TEXTUREVARIANT_ANALYSIS_FIRST = 0,
TA_SPRITE_AUTOLIGHT = TEXTUREVARIANT_ANALYSIS_FIRST,
TA_WORLD_AMBIENTLIGHT,
TA_SKY_TOPCOLOR,
TA_MAP_AMBIENTLIGHT,
TA_SKY_SPHEREFADECOLOR,
TEXTUREVARIANT_ANALYSIS_COUNT
} texturevariant_analysisid_t;

Expand Down
99 changes: 99 additions & 0 deletions doomsday/engine/portable/include/texturevariantspecification.h
@@ -0,0 +1,99 @@
/**\file image.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2005-2011 Daniel Swanson <danij@dengine.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*/

#ifndef LIBDENG_GL_TEXTUREVARIANTSPECIFICATION_H
#define LIBDENG_GL_TEXTUREVARIANTSPECIFICATION_H

typedef struct material_load_params_s {
int tmap, tclass;
struct {
byte flags; /// @see textureFlags
byte border;
} tex;
} material_load_params_t;

typedef enum {
TC_UNKNOWN = -1,
TEXTUREUSAGECONTEXT_FIRST = 0,
TC_UI = TEXTUREUSAGECONTEXT_FIRST,
TC_MAPSURFACE_DIFFUSE,
TC_MAPSURFACE_REFLECTION,
TC_MAPSURFACE_REFLECTIONMASK,
TC_MAPSURFACE_LIGHTMAP,
TC_MAPSURFACE_DETAIL,
TC_SPRITE_DIFFUSE,
TC_MODELSKIN_DIFFUSE,
TC_MODELSKIN_REFLECTION,
TC_HALO_LUMINANCE,
TC_PSPRITE_DIFFUSE,
TC_SKYSPHERE_DIFFUSE,
TEXTUREUSAGECONTEXT_LAST = TC_SKYSPHERE_DIFFUSE
} textureusagecontext_t;

#define TEXTUREUSAGECONTEXT_COUNT (\
TEXTUREUSAGECONTEXT_LAST + 1 - TEXTUREUSAGECONTEXT_FIRST )

#define VALID_TEXTUREUSAGECONTEXT(tc) (\
(tc) >= TEXTUREUSAGECONTEXT_FIRST && (tc) <= TEXTUREUSAGECONTEXT_LAST)

/**
* @defGroup textureFlags Texture Flags
*/
/*@{*/
#define TF_ZEROMASK 0x1 // Zero the alpha of loaded textures.
#define TF_NO_COMPRESSION 0x2 // Do not compress the loaded textures.
#define TF_UPSCALE_AND_SHARPEN 0x4
#define TF_MONOCHROME 0x8
/*@}*/

typedef enum {
TEXTURESPECIFICATIONTYPE_FIRST = 0,
TS_DEFAULT = TEXTURESPECIFICATIONTYPE_FIRST,
TS_TRANSLATED,
TS_DETAIL,
TEXTURESPECIFICATIONTYPE_LAST = TS_DETAIL
} texturespecificationtype_t;

#define TEXTURESPECIFICATIONTYPE_COUNT (\
TEXTURESPECIFICATIONTYPE_LAST + 1 - TEXTURESPECIFICATIONTYPE_FIRST )

#define VALID_TEXTURESPECIFICATIONTYPE(t) (\
(t) >= TEXTURESPECIFICATIONTYPE_FIRST && (t) <= TEXTURESPECIFICATIONTYPE_LAST)

typedef struct texturevariantspecification_s {
textureusagecontext_t context;
texturespecificationtype_t type;
byte flags; /// @see textureFlags
byte border; /// In pixels, added to all four edges of the texture.
union {
struct {
int tclass, tmap; // Color translation.
} translated;
struct {
float contrast;
} detail;
} data; // type-specific data.
} texturevariantspecification_t;

#endif /* LIBDENG_GL_TEXTUREVARIANTSPECIFICATION_H */
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/def_read.c
Expand Up @@ -1779,8 +1779,8 @@ static int DED_ReadData(ded_t* ded, const char* buffer, const char* sourceFile)
RV_FLT("Shininess", ref->shininess)
RV_VEC("Min color", ref->minColor, 3)
RV_BLENDMODE("Blending mode", ref->blendMode)
RV_URI("Shiny map", &ref->shinyMap, 0)
RV_URI("Mask map", &ref->maskMap, 0)
RV_URI("Shiny map", &ref->shinyMap, LIGHTMAPS_RESOURCE_NAMESPACE_NAME)
RV_URI("Mask map", &ref->maskMap, LIGHTMAPS_RESOURCE_NAMESPACE_NAME)
RV_FLT("Mask width", ref->maskWidth)
RV_FLT("Mask height", ref->maskHeight)
if(ISLABEL("Material"))
Expand Down
8 changes: 4 additions & 4 deletions doomsday/engine/portable/src/filedirectory.c
Expand Up @@ -604,8 +604,8 @@ boolean FileDirectoryNode_MatchDirectory(const filedirectory_node_t* node,
while((pos = strrchr(dir, delimiter)) != 0)
{
// Does this match?
if(Str_Length(&node->path) < Str_Length(searchPath) ||
strnicmp(Str_Text(&node->path), Str_Text(searchPath),
if(Str_Length(&node->path) < (strlen(pos)-1) ||
strnicmp(Str_Text(&node->path), pos + 1,
Str_Length(&node->path) - (node->type == FDT_DIRECTORY? 1:0)))
return false;

Expand All @@ -620,8 +620,8 @@ boolean FileDirectoryNode_MatchDirectory(const filedirectory_node_t* node,
}}

// Anything remaining is the root directory or file; but does it match?
if(Str_Length(&node->path) < Str_Length(searchPath) ||
strnicmp(Str_Text(&node->path), Str_Text(searchPath),
if(Str_Length(&node->path) < strlen(dir) ||
strnicmp(Str_Text(&node->path), dir,
Str_Length(&node->path) - (node->type == FDT_DIRECTORY? 1:0)))
return false;

Expand Down
7 changes: 3 additions & 4 deletions doomsday/engine/portable/src/gl_main.c
Expand Up @@ -1035,7 +1035,7 @@ void GL_SetMaterial(material_t* mat)
return; // \fixme we need a "NULL material".

Con_Error("GL_SetMaterial: No usage context specified.");
Materials_Prepare(&ms, mat, true, NULL);
Materials_Prepare(&ms, mat, true, GL_TextureVariantSpecificationForContext(TS_DEFAULT, TC_UNKNOWN, NULL));
GL_BindTexture(TextureVariant_GLName(ms.units[MTU_PRIMARY].tex), ms.units[MTU_PRIMARY].magMode);
}

Expand All @@ -1045,10 +1045,9 @@ void GL_SetPSprite(material_t* mat)
material_snapshot_t ms;

memset(&params, 0, sizeof(params));
params.pSprite = true;
params.tex.border = 1;

Materials_Prepare(&ms, mat, true, &params);
Materials_Prepare(&ms, mat, true, GL_TextureVariantSpecificationForContext(TS_DEFAULT, TC_PSPRITE_DIFFUSE, &params));

GL_BindTexture(TextureVariant_GLName(ms.units[MTU_PRIMARY].tex), ms.units[MTU_PRIMARY].magMode);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
Expand All @@ -1065,7 +1064,7 @@ void GL_SetTranslatedSprite(material_t* mat, int tclass, int tmap)
params.tclass = tclass;
params.tex.border = 1;

Materials_Prepare(&ms, mat, true, &params);
Materials_Prepare(&ms, mat, true, GL_TextureVariantSpecificationForContext(TS_TRANSLATED, TC_SPRITE_DIFFUSE, &params));
GL_BindTexture(TextureVariant_GLName(ms.units[MTU_PRIMARY].tex), ms.units[MTU_PRIMARY].magMode);
}

Expand Down

0 comments on commit 34600a4

Please sign in to comment.