Skip to content

Commit

Permalink
Changed: Removed the splitting of large Patch and Raw format graphics…
Browse files Browse the repository at this point in the history
… into two textures. Back when this was implemented the maximum texture dimensions supported by many GL implementations was considerably smaller than is common today. So to preserve quality Doomsday would split "large" graphics up into two smaller parts. This resulted in several architectural issues as drawing these graphics necesitated the use of dedicated methods for the purpose. Today with maximum texture dimensions so much larger and support for non-power-of-two textures being common place, this splitting is no longer useful for 99% of systems and has now been removed.
  • Loading branch information
danij-deng committed May 10, 2010
1 parent d285054 commit b887b85
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 295 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/dd_gl.h
Expand Up @@ -212,7 +212,7 @@ void DGL_SetNoMaterial(void);
void DGL_SetPatch(lumpnum_t lump, int wrapS, int wrapT);
void DGL_SetPSprite(struct material_s* mat);
void DGL_SetTranslatedSprite(struct material_s* mat, int tclass, int tmap);
void DGL_SetRawImage(lumpnum_t lump, boolean part2, int wrapS, int wrapT);
void DGL_SetRawImage(lumpnum_t lump, int wrapS, int wrapT);

void DGL_BlendOp(int op);
void DGL_BlendFunc(int param1, int param2);
Expand Down
8 changes: 2 additions & 6 deletions doomsday/engine/portable/include/gl_texmanager.h
Expand Up @@ -195,22 +195,18 @@ DGLuint GL_PrepareLSTexture(lightingtexid_t which);
DGLuint GL_PrepareSysFlareTexture(flaretexid_t flare);

DGLuint GL_PreparePatch(patchtex_t* patch);
DGLuint GL_PreparePatchOtherPart(patchtex_t* patch);
DGLuint GL_PrepareRawTex(rawtex_t* rawTex);
DGLuint GL_PrepareRawTexOtherPart(rawtex_t* rawTex);

DGLuint GL_GetLightMapTexture(const char* name);
DGLuint GL_GetFlareTexture(const char* name, int oldIdx);

void GL_SetMaterial(material_t* mat);
void GL_SetPSprite(material_t* mat);
void GL_SetTranslatedSprite(material_t* mat, int tclass,
int tmap);
void GL_SetTranslatedSprite(material_t* mat, int tclass, int tmap);

void GL_SetPatch(lumpnum_t lump, int wrapS, int wrapT); // No mipmaps are generated.

void GL_SetRawImage(lumpnum_t lump, boolean part2, int wrapS,
int wrapT);
void GL_SetRawImage(lumpnum_t lump, int wrapS, int wrapT);


// Management of and access to gltextures (via the texmanager):
Expand Down
12 changes: 0 additions & 12 deletions doomsday/engine/portable/include/r_data.h
Expand Up @@ -165,14 +165,9 @@ typedef struct patchtex_s {
short extraOffset[2]; // Only used with upscaled and sharpened patches.
int flags; // Possible modifier filters to apply (monochrome, scale+sharp)

// Part 1
DGLuint tex; // Name of the associated DGL texture.
short width, height;

// Part 2 (only used with textures larger than the max texture size).
DGLuint tex2;
short width2, height2;

struct patchtex_s* next;
} patchtex_t;

Expand All @@ -187,17 +182,10 @@ typedef struct lumppatch_s {
// A rawtex is a lump raw graphic that has been prepared for render.
typedef struct rawtex_s {
lumpnum_t lump;

// Part 1
DGLuint tex; // Name of the associated DGL texture.
short width, height;
byte masked;

// Part 2 (only used with textures larger than the max texture size).
DGLuint tex2;
short width2, height2;
byte masked2;

struct rawtex_s* next;
} rawtex_t;

Expand Down
4 changes: 2 additions & 2 deletions doomsday/engine/portable/src/dgl_common.c
Expand Up @@ -705,9 +705,9 @@ void DGL_SetPSprite(material_t* mat)
GL_SetPSprite(mat);
}

void DGL_SetRawImage(lumpnum_t lump, boolean part2, int wrapS, int wrapT)
void DGL_SetRawImage(lumpnum_t lump, int wrapS, int wrapT)
{
GL_SetRawImage(lump, part2,
GL_SetRawImage(lump,
(wrapS == DGL_CLAMP? GL_CLAMP :
wrapS == DGL_CLAMP_TO_EDGE? GL_CLAMP_TO_EDGE : GL_REPEAT),
(wrapT == DGL_CLAMP? GL_CLAMP :
Expand Down
70 changes: 12 additions & 58 deletions doomsday/engine/portable/src/gl_draw.c
Expand Up @@ -63,13 +63,15 @@ void GL_UsePatchOffset(boolean enable)
usePatchOffset = enable;
}

/**
* \todo No need for this special method now. Refactor callers to use the
* normal DGL drawing methods.
*/
void GL_DrawRawScreen_CS(lumpnum_t lump, float offx, float offy,
float scalex, float scaley)
{
boolean isTwoPart;
float pixelBorder = 0;
float tcb = 0;
rawtex_t* raw;
float pixelBorder = 0;
rawtex_t* raw;

if(lump < 0 || lump >= numLumps)
return;
Expand All @@ -89,19 +91,9 @@ void GL_DrawRawScreen_CS(lumpnum_t lump, float offx, float offy,
glLoadIdentity();
glOrtho(0, theWindow->width, theWindow->height, 0, -1, 1);

GL_SetRawImage(lump, false, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
GL_SetRawImage(lump, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
raw = R_GetRawTex(lump);
isTwoPart = (raw->tex2 != 0);

if(isTwoPart)
{
tcb = raw->height / 256.0f;
}
else
{
// Bottom texture coordinate.
tcb = 1;
}
// Bottom texture coordinate.
pixelBorder = raw->width * theWindow->width / 320;

// The first part is rendered in any case.
Expand All @@ -110,28 +102,12 @@ void GL_DrawRawScreen_CS(lumpnum_t lump, float offx, float offy,
glVertex2f(0, 0);
glTexCoord2f(1, 0);
glVertex2f(pixelBorder, 0);
glTexCoord2f(1, tcb);
glTexCoord2f(1, 1);
glVertex2f(pixelBorder, theWindow->height);
glTexCoord2f(0, tcb);
glTexCoord2f(0, 1);
glVertex2f(0, theWindow->height);
glEnd();

if(isTwoPart)
{
// And the other part.
GL_SetRawImage(lump, true, GL_CLAMP_TO_EDGE, GL_CLAMP_TO_EDGE);
glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(pixelBorder, 0);
glTexCoord2f(1, 0);
glVertex2f(theWindow->width, 0);
glTexCoord2f(1, tcb);
glVertex2f(theWindow->width, theWindow->height);
glTexCoord2f(0, tcb);
glVertex2f(pixelBorder, theWindow->height);
glEnd();
}

// Restore the old projection matrix.
glMatrixMode(GL_PROJECTION);
glPopMatrix();
Expand All @@ -154,10 +130,8 @@ void GL_DrawRawScreen(lumpnum_t lump, float offx, float offy)
*/
void GL_DrawPatch_CS(int posX, int posY, lumpnum_t lump)
{
float x = posX;
float y = posY;
float w, h;
patchtex_t* p = R_GetPatchTex(lump);
float x = posX, y = posY, w, h;
patchtex_t* p = R_GetPatchTex(lump);

if(!p)
return;
Expand Down Expand Up @@ -195,26 +169,6 @@ void GL_DrawPatch_CS(int posX, int posY, lumpnum_t lump)
glTexCoord2f(0, 1);
glVertex2f(x, y + h);
glEnd();

// Is there a second part?
if(GL_PreparePatchOtherPart(p))
{
x += (float) p->width2;

GL_BindTexture(GL_PreparePatchOtherPart(p), glmode[texMagMode]);
w = (float) p->width2;

glBegin(GL_QUADS);
glTexCoord2f(0, 0);
glVertex2f(x, y);
glTexCoord2f(1, 0);
glVertex2f(x + w, y);
glTexCoord2f(1, 1);
glVertex2f(x + w, y + h);
glTexCoord2f(0, 1);
glVertex2f(x, y + h);
glEnd();
}
}

void GL_DrawPatchLitAlpha(int x, int y, float light, float alpha,
Expand Down

0 comments on commit b887b85

Please sign in to comment.