Skip to content

Commit

Permalink
Completed preparatory refactoring of texture upload/processing for th…
Browse files Browse the repository at this point in the history
…e introduction of texture atlases.

There remains a few open issues (none new, I might add) however this feels like a natural place to stop and rest.
  • Loading branch information
danij-deng committed Mar 13, 2011
1 parent e0875c6 commit c916489
Show file tree
Hide file tree
Showing 56 changed files with 2,965 additions and 2,717 deletions.
4 changes: 4 additions & 0 deletions doomsday/build/codeblocks/doomsday.cbp
Expand Up @@ -257,6 +257,8 @@
<Unit filename="..\..\engine\portable\include\gl_tex.h" />
<Unit filename="..\..\engine\portable\include\gl_texmanager.h" />
<Unit filename="..\..\engine\portable\include\gl_tga.h" />
<Unit filename="..\..\engine\portable\include\gltexture.h" />
<Unit filename="..\..\engine\portable\include\gltexturevariant.h" />
<Unit filename="..\..\engine\portable\include\image.h" />
<Unit filename="..\..\engine\portable\include\m_args.h" />
<Unit filename="..\..\engine\portable\include\m_bams.h" />
Expand Down Expand Up @@ -363,6 +365,7 @@
<Unit filename="..\..\engine\portable\include\sys_timer.h" />
<Unit filename="..\..\engine\portable\include\sys_window.h" />
<Unit filename="..\..\engine\portable\include\tab_anorms.h" />
<Unit filename="..\..\engine\portable\include\texturecontent.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 Expand Up @@ -542,6 +545,7 @@
<Unit filename="..\..\engine\portable\src\gl_tga.c">
<Option compilerVar="CC" />
</Unit>
<Unit filename="..\..\engine\portable\src\gltexture.c" />
<Unit filename="..\..\engine\portable\src\image.c" />
<Unit filename="..\..\engine\portable\src\m_args.c">
<Option compilerVar="CC" />
Expand Down
1 change: 1 addition & 0 deletions doomsday/build/win32/doomsday_cl.rsp
Expand Up @@ -44,6 +44,7 @@
.\..\..\engine\portable\src\gl_font.c
.\..\..\engine\portable\src\gl_draw.c
.\..\..\engine\portable\src\gl_drawvectorgraphic.c
.\..\..\engine\portable\src\gltexture.c
.\..\..\engine\portable\src\image.c
.\..\..\engine\portable\src\pathdirectory.c
.\..\..\engine\portable\src\rend_console.c
Expand Down
18 changes: 17 additions & 1 deletion doomsday/build/win32/vs8/doomsday.vcproj
Expand Up @@ -1140,6 +1140,10 @@
RelativePath="..\..\..\engine\portable\src\gl_tga.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\gltexture.c"
>
</File>
<File
RelativePath="..\..\..\engine\portable\src\image.c"
>
Expand Down Expand Up @@ -2817,6 +2821,14 @@
RelativePath="..\..\..\engine\portable\include\gl_tga.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\gltexture.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\gltexturevariant.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\image.h"
>
Expand Down Expand Up @@ -3245,6 +3257,10 @@
RelativePath="..\..\..\engine\portable\include\template.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\texturecontent.h"
>
</File>
<File
RelativePath="..\..\..\engine\portable\include\ui2_main.h"
>
Expand Down Expand Up @@ -3854,4 +3870,4 @@
</Files>
<Globals>
</Globals>
</VisualStudioProject>
</VisualStudioProject>
5 changes: 4 additions & 1 deletion doomsday/engine/api/dd_gl.h
Expand Up @@ -107,7 +107,6 @@ typedef enum dgltexformat_e {
DGL_COLOR_INDEX_8,
DGL_COLOR_INDEX_8_PLUS_A8,
DGL_LUMINANCE,
DGL_DEPTH_COMPONENT,
DGL_LUMINANCE_PLUS_A8
} dgltexformat_t;

Expand Down Expand Up @@ -248,6 +247,10 @@ void DGL_DrawCutRectTiled(float x, float y, float w, float h, int tw,

void DGL_DrawRawScreen(lumpnum_t lump, int x, int y);

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

/**
* \todo The following routines should not be necessary once materials can
* be created dynamically.
Expand Down
2 changes: 2 additions & 0 deletions doomsday/engine/api/dd_share.h
Expand Up @@ -948,6 +948,8 @@ typedef enum {
NUM_GLTEXTURE_TYPES
} gltexture_type_t;

#define VALID_GLTEXTURE_TYPE(t) ((t) >= GLT_FIRST && (t) < NUM_GLTEXTURE_TYPES)

/**
* Processing modes for GL_LoadGraphics.
*/
Expand Down
2 changes: 1 addition & 1 deletion doomsday/engine/api/doomsday.def
Expand Up @@ -429,6 +429,7 @@ EXPORTS
DGL_DrawRect @128 NONAME
DGL_DrawRectTiled @129 NONAME
DGL_DrawCutRectTiled @130 NONAME
DGL_NewTextureWithParams @329 NONAME

; Depreciated:
DGL_DrawRawScreen @126 NONAME
Expand Down Expand Up @@ -460,7 +461,6 @@ EXPORTS

; Graphics.
GL_GrabScreen @109 NONAME
GL_NewTextureWithParams3 @329 NONAME
GL_SetFilter @132 NONAME
GL_SetFilterColor @441 NONAME
GL_TextureNumForName @437 NONAME
Expand Down
1 change: 0 additions & 1 deletion doomsday/engine/api/doomsday.h
Expand Up @@ -478,7 +478,6 @@ void Con_SetString(const char* name, char* text);

void GL_UseFog(int yes);
byte* GL_GrabScreen(void);
DGLuint GL_NewTextureWithParams3(int format, int width, int height, const void* pixels, int flags, int minFilter, int magFilter, int anisoFilter, int wrapS, int wrapT);
void GL_SetFilter(boolean enable);
void GL_SetFilterColor(float r, float g, float b, float a);
uint GL_TextureNumForName(const char* name, gltexture_type_t type);
Expand Down
12 changes: 6 additions & 6 deletions doomsday/engine/defs/materials.ded
Expand Up @@ -12,8 +12,8 @@ Material {
Width = 64;
Height = 64;
Layer {
Stage { System = "DDT_UNKN"; Tics = 16; Glow = 0; }
Stage { System = "DDT_UNKN"; Tics = 24; Glow = 1; }
Stage { System = "unknown"; Tics = 16; Glow = 0; }
Stage { System = "unknown"; Tics = 24; Glow = 1; }
}
}

Expand All @@ -26,8 +26,8 @@ Material {
Width = 64;
Height = 64;
Layer {
Stage { System = "DDT_MISS"; Tics = 16; Glow = 0; }
Stage { System = "DDT_MISS"; Tics = 24; Glow = 1; }
Stage { System = "missing"; Tics = 16; Glow = 0; }
Stage { System = "missing"; Tics = 24; Glow = 1; }
}
}

Expand All @@ -39,7 +39,7 @@ Material {
Width = 64;
Height = 64;
Layer {
Stage { System = "DDT_BBOX"; Glow = 1; }
Stage { System = "bbox"; Glow = 1; }
}
}

Expand All @@ -51,6 +51,6 @@ Material {
Width = 64;
Height = 64;
Layer {
Stage { System = "DDT_GRAY"; }
Stage { System = "gray"; }
}
}
4 changes: 2 additions & 2 deletions doomsday/engine/portable/include/bitmapfont.h
Expand Up @@ -69,7 +69,7 @@ typedef struct bitmapfont_s {
int _ascent;
int _descent;

/// dj: Do fonts have margins? Is this a texel border in the composited
/// dj: Do fonts have margins? Is this a pixel border in the composited
/// character map texture (perhaps per-glyph)?
int _marginWidth, _marginHeight;

Expand All @@ -79,7 +79,7 @@ typedef struct bitmapfont_s {
/// GL-texture name.
DGLuint _tex;

/// Width and height of the texture in texels.
/// Width and height of the texture in pixels.
int _texWidth, _texHeight;
} bitmapfont_t;

Expand Down
96 changes: 34 additions & 62 deletions doomsday/engine/portable/include/gl_defer.h
@@ -1,10 +1,10 @@
/**\file
/**\file gl_defer.h
*\section License
* License: GPL
* Online License Link: http://www.gnu.org/licenses/gpl.html
*
*\author Copyright © 2003-2009 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-2009 Daniel Swanson <danij@dengine.net>
*\author Copyright © 2003-2011 Jaakko Keränen <jaakko.keranen@iki.fi>
*\author Copyright © 2006-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
Expand All @@ -23,70 +23,42 @@
*/

/**
* gl_defer.h: Deferred GL Tasks
* Deferred GL Tasks.
*/

#ifndef __DOOMSDAY_GRAPHICS_DEREF_H__
#define __DOOMSDAY_GRAPHICS_DEREF_H__
#ifndef LIBDENG_GL_DEFERRED_H
#define LIBDENG_GL_DEFERRED_H

typedef enum {
DEFERREDTASK_TYPES_FIRST = 0,
DTT_UPLOAD_TEXTURECONTENT = DEFERREDTASK_TYPES_FIRST,
DEFERREDTASK_TYPES_COUNT
} deferredtask_type_t;

#define VALID_DEFERREDTASK_TYPE(t) ((t) >= DEFERREDTASK_TYPES_FIRST || (t) < DEFERREDTASK_TYPES_COUNT)

/// Initialize this module.
void GL_InitDeferredTask(void);

/// Shutdown this module.
void GL_ShutdownDeferredTask(void);

/// @return Number of waiting tasks else @c 0
int GL_GetDeferredTaskCount(void);

/**
* Defines the content of a GL texture. Used when creating textures either
* immediately or in deferred mode (when busy).
* @param timeOutMilliSeconds Zero for no timeout.
*/
typedef struct texturecontent_s {
DGLuint name;
void* buffer;
size_t bufferSize;
dgltexformat_t format;
colorpaletteid_t palette;
int width;
int height;
int minFilter;
int magFilter;
int anisoFilter;
int wrap[2];
int grayMipmap;
int flags;
} texturecontent_t;

// Flags for texture content.
#define TXCF_NO_COMPRESSION 0x1
#define TXCF_MIPMAP 0x2
#define TXCF_GRAY_MIPMAP 0x4
#define TXCF_CONVERT_8BIT_TO_ALPHA 0x8
#define TXCF_APPLY_GAMMACORRECTION 0x10
#define TXCF_EASY_UPLOAD 0x20
#define TXCF_UPLOAD_ARG_ALPHACHANNEL 0x40
#define TXCF_UPLOAD_ARG_RGBDATA 0x80
#define TXCF_UPLOAD_ARG_NOSTRETCH 0x100
#define TXCF_UPLOAD_ARG_NOSMARTFILTER 0x200
#define TXCF_NEVER_DEFER 0x400
#define TXCF_GRAY_MIPMAP_LEVEL_SHIFT 24
#define TXCF_GRAY_MIPMAP_LEVEL_MASK 0xff000000
void GL_RunDeferredTasks(uint timeOutMilliSeconds);

void GL_InitDeferred(void);
void GL_ShutdownDeferred(void);
void GL_UploadDeferredContent(uint timeOutMilliSeconds);
int GL_GetDeferredCount(void);
void GL_InitTextureContent(texturecontent_t* content);
DGLuint GL_NewTexture(texturecontent_t* content, boolean* result);
DGLuint GL_NewTextureWithParams(dgltexformat_t format, int width,
int height, void* pixels,
int flags);
DGLuint GL_NewTextureWithParams2(dgltexformat_t format, int width,
int height, void* pixels,
int flags, int minFilter,
int magFilter, int anisoFilter,
int wrapS, int wrapT);
DGLuint GL_NewTextureWithParams3(dgltexformat_t format, int width,
int height, const void* pixels,
int flags, int minFilter,
int magFilter, int anisoFilter,
int wrapS, int wrapT);
/**
* @param type Type of task to add.
* @param data Caller-supplied additional data ptr, linked with the task.
*/
void GL_EnqueueDeferredTask(deferredtask_type_t type, void* data);

DGLuint GL_GetReservedName(void);
DGLuint GL_GetReservedTextureName(void);
void GL_ReserveNames(void);
void GL_ReleaseReservedNames(void);

/// \todo should these be public?
void GL_ReserveNames(void);
void GL_ReleaseReservedNames(void);
#endif
#endif /* LIBDENG_GL_DEFERRED_H */

0 comments on commit c916489

Please sign in to comment.