Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
image_t added, extres for raw screens
  • Loading branch information
skyjake committed May 30, 2003
1 parent 6e2f2c2 commit 7e8185e
Show file tree
Hide file tree
Showing 9 changed files with 393 additions and 299 deletions.
5 changes: 3 additions & 2 deletions doomsday/Include/doomsday.h
Expand Up @@ -179,7 +179,7 @@ void GL_SetPatch(int lump);
void GL_SetSprite(int pnum);
void GL_SetFlat(int idx);
void GL_SetTexture(int idx);
void GL_SetRawImage(int lump, int part);
unsigned int GL_SetRawImage(int lump, int part);

// Graphics: 2D drawing.
void GL_DrawPatch(int x, int y, int lumpnum);
Expand All @@ -188,7 +188,8 @@ void GL_DrawPatchLitAlpha(int x, int y, float light, float alpha, int lumpnum);
void GL_DrawFuzzPatch(int x, int y, int lumpnum);
void GL_DrawAltFuzzPatch(int x, int y, int lumpnum);
void GL_DrawShadowedPatch(int x, int y, int lumpnum);
void GL_DrawRawScreen(int lump);
void GL_DrawRawScreen(int lump, float offx, float offy);
void GL_DrawRawScreen_CS(int lump, float offx, float offy, float scalex, float scaley);
void GL_DrawLine(float x1, float y1, float x2, float y2, float r, float g, float b, float a);
void GL_DrawRect(float x, float y, float w, float h, float r, float g, float b, float a);
void GL_DrawRectTiled(int x, int y, int w, int h, int tw, int th);
Expand Down
3 changes: 2 additions & 1 deletion doomsday/Include/gl_draw.h
Expand Up @@ -14,7 +14,8 @@ void GL_DrawPatchLitAlpha(int x, int y, float light, float alpha,
void GL_DrawFuzzPatch(int x, int y, int lumpnum);
void GL_DrawAltFuzzPatch(int x, int y, int lumpnum);
void GL_DrawShadowedPatch(int x, int y, int lumpnum);
void GL_DrawRawScreen(int lump); // Raw screens are 320 x 200.
void GL_DrawRawScreen(int lump, float offx, float offy);
void GL_DrawRawScreen_CS(int lump, float offx, float offy, float scalex, float scaley);
void GL_DrawLine(float x1, float y1, float x2, float y2,
float r, float g, float b, float a);
void GL_DrawRect(float x, float y, float w, float h, float r,
Expand Down
25 changes: 18 additions & 7 deletions doomsday/Include/gl_tex.h
Expand Up @@ -7,6 +7,19 @@
#include "r_data.h"
#include "con_decl.h"

/*
* This structure is used with GL_LoadImage. When it is no longer needed
* it must be discarded with GL_DestroyImage.
*/
typedef struct image_s {
char fileName[256];
int width;
int height;
int pixelSize;
boolean isMasked;
byte *pixels;
} image_t;

extern int mipmapping, linearRaw, texQuality, filterSprites;
extern float texw, texh;
extern int texmask;
Expand Down Expand Up @@ -38,12 +51,10 @@ void GL_DoColorKeying(byte *rgbaBuf, int width);
void GL_LowRes();
void PalIdxToRGB(byte *pal, int idx, byte *rgb);
void TranslatePatch(struct patch_s *patch, byte *transTable);
byte * GL_LoadImage(const char *imagefn, int *width, int *height,
int *pixsize, boolean *masked, boolean usemodelpath);
byte * GL_LoadImageCK(const char *imagefn, int *width, int *height,
int *pixsize, boolean *masked, boolean usemodelpath);
byte * GL_LoadTexture(char *name, int *width, int *height, int *pixsize,
boolean *masked);
byte * GL_LoadImage(image_t *img, const char *imagefn, boolean useModelPath);
byte * GL_LoadImageCK(image_t *img, const char *imagefn, boolean useModelPath);
byte * GL_LoadTexture(image_t *img, char *name);
void GL_DestroyImage(image_t *img);
DGLuint GL_PrepareTexture(int idx);
DGLuint GL_PrepareFlat(int idx);
DGLuint GL_PrepareLightTexture(void); // The dynamic light map.
Expand Down Expand Up @@ -74,7 +85,7 @@ int GL_GetSkinTexIndex(const char *skin);
// No splittex is created in that case. Once a raw image is loaded
// as part 0 it must be deleted before the other part is loaded at the
// next loading.
void GL_SetRawImage(int lump, int part);
unsigned int GL_SetRawImage(int lump, int part);

// Returns the real DGL texture, if such exists
unsigned int GL_GetTextureName(int texidx);
Expand Down
3 changes: 2 additions & 1 deletion doomsday/Src/Doomsday.def
Expand Up @@ -2,7 +2,7 @@ NAME "DOOMSDAY"
DESCRIPTION "The Doomsday Engine"

; Highest ordinal is currently
; --> 234 <--
; --> 235 <--

; Other available ordinals: -

Expand Down Expand Up @@ -184,6 +184,7 @@ EXPORTS
GL_DrawAltFuzzPatch @124 NONAME
GL_DrawShadowedPatch @125 NONAME
GL_DrawRawScreen @126 NONAME
GL_DrawRawScreen_CS @235 NONAME
GL_DrawLine @127 NONAME
GL_DrawRect @128 NONAME
GL_DrawRectTiled @129 NONAME
Expand Down
71 changes: 49 additions & 22 deletions doomsday/Src/gl_draw.c
Expand Up @@ -42,30 +42,44 @@ void GL_UsePatchOffset(boolean enable)
usePatchOffset = enable;
}

//===========================================================================
// GL_DrawRawScreen
// Raw screens are 320 x 200.
//===========================================================================
void GL_DrawRawScreen(int lump)
void GL_DrawRawScreen_CS
(int lump, float offx, float offy, float scalex, float scaley)
{
int pixelBorder;
float tcb;
boolean isTwoPart;
int pixelBorder = 0;
float tcb = 0;

if(lump < 0) return;
if(lump < 0 || lump >= numlumps) return;

gl.MatrixMode(DGL_MODELVIEW);
gl.PushMatrix();
gl.LoadIdentity();

// Setup offset and scale.
// Scale the offsets to match the resolution.
gl.Translatef(offx * screenWidth/320.0f, offy * screenHeight/200.0f, 0);
gl.Scalef(scalex, scaley, 1);

gl.MatrixMode(DGL_PROJECTION);
gl.PushMatrix();
gl.LoadIdentity();
gl.Ortho(0, 0, screenWidth, screenHeight, -1, 1);

GL_SetRawImage(lump, 1);
isTwoPart = (lumptexinfo[lump].tex[1] != 0);

if(isTwoPart)
{
tcb = lumptexinfo[lump].height / 256.0f;
}
else
{
// Bottom texture coordinate.
tcb = 1;
}
pixelBorder = lumptexinfo[lump].width[0] * screenWidth / 320;
tcb = lumptexinfo[lump].height / 256.0f;

gl.Color3f(1, 1, 1);
// The first part is rendered in any case.
gl.Begin(DGL_QUADS);
gl.TexCoord2f(0, 0);
gl.Vertex2f(0, 0);
Expand All @@ -77,18 +91,21 @@ void GL_DrawRawScreen(int lump)
gl.Vertex2f(0, screenHeight);
gl.End();

// And the other part.
GL_SetRawImage(lump,2);
gl.Begin(DGL_QUADS);
gl.TexCoord2f(0, 0);
gl.Vertex2f(pixelBorder-1, 0);
gl.TexCoord2f(1, 0);
gl.Vertex2f(screenWidth, 0);
gl.TexCoord2f(1, tcb);
gl.Vertex2f(screenWidth, screenHeight);
gl.TexCoord2f(0, tcb);
gl.Vertex2f(pixelBorder-1, screenHeight);
gl.End();
if(isTwoPart)
{
// And the other part.
GL_SetRawImage(lump, 2);
gl.Begin(DGL_QUADS);
gl.TexCoord2f(0, 0);
gl.Vertex2f(pixelBorder - 1, 0);
gl.TexCoord2f(1, 0);
gl.Vertex2f(screenWidth, 0);
gl.TexCoord2f(1, tcb);
gl.Vertex2f(screenWidth, screenHeight);
gl.TexCoord2f(0, tcb);
gl.Vertex2f(pixelBorder - 1, screenHeight);
gl.End();
}

// Restore the old projection matrix.
gl.PopMatrix();
Expand All @@ -97,6 +114,16 @@ void GL_DrawRawScreen(int lump)
gl.PopMatrix();
}

//===========================================================================
// GL_DrawRawScreen
// Raw screens are 320 x 200.
//===========================================================================
void GL_DrawRawScreen(int lump, float offx, float offy)
{
gl.Color3f(1, 1, 1);
GL_DrawRawScreen_CS(lump, offx, offy, 1, 1);
}

//===========================================================================
// GL_DrawPatch_CS
// Drawing with the Current State.
Expand Down

0 comments on commit 7e8185e

Please sign in to comment.