Commit 93464602 authored by Steven Fuller's avatar Steven Fuller

Minor cleanups.. Unsuccessful attempts to get vi_ogl to do more

parent 1b487c9d
......@@ -75,6 +75,7 @@ screen update
* GL_shared_texture_palette for opengl
* if window looses focus, should it clear the keys ?
* add DGA, clean up vi_xlib.c, fix vid mode changing
* fix broken opengl
Specific:
* memory/sound intro screen goes
......
......@@ -75,7 +75,8 @@ typedef struct {
#include "id_vh.h"
#include "id_us.h"
extern byte introscn[];
extern const byte introscn[];
extern const byte gamepal[];
int MS_CheckParm(char *string);
int WolfMain(int argc, char *argv[]);
......
......@@ -31,7 +31,6 @@ void VW_UpdateScreen (void);
void VWB_DrawTile8(int x, int y, int tile);
void VWB_DrawPic(int x, int y, int chunknum);
extern byte gamepal[];
extern boolean screenfaded;
#define VW_Startup VL_Startup
......
......@@ -6,7 +6,7 @@
/* SDM = 2 */
/* SOD = 3 */
#ifndef WMODE
#define WMODE 0
#define WMODE 1
#endif
#if WMODE == 0
......
......@@ -30,7 +30,7 @@ int attrib[] = {
GLX_GREEN_SIZE, 5,
GLX_BLUE_SIZE, 5,
GLX_DEPTH_SIZE, 16,
GLX_DOUBLEBUFFER,
// GLX_DOUBLEBUFFER,
None
};
......@@ -154,6 +154,8 @@ void VL_WaitVBL(int vbls)
void VW_UpdateScreen()
{
// glXSwapBuffers(dpy, win);
// glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
/*
......@@ -173,8 +175,11 @@ void VL_Startup()
XMapWindow(dpy, win);
glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
......
......@@ -6,7 +6,57 @@
byte *SprToLin(byte *source)
{
return source;
byte *buf = malloc(64 * 64);
t_compshape *ptr = (t_compshape *)source;
memset(buf, '\0', 64 * 64);
{
int srcx = 32;
int slinex = 31;
int stopx = ptr->leftpix;
word *cmdptr = &ptr->dataofs[31-stopx];
while ( --srcx >=stopx ) {
short *linecmds = (short *)((unsigned char *)ptr + *cmdptr--);
slinex--;
while (linecmds[0]) {
int y;
int y0 = linecmds[2] / 2;
int y1 = linecmds[0] / 2 - 1;
unsigned char *pixels = (unsigned char *)ptr + y0 + linecmds[1];
for (y = y0; y <= y1; y++) {
unsigned char color = *pixels++;
*(buf + slinex + (y*64)) = color;
}
linecmds += 3;
}
}
slinex = 31;
stopx = ptr->rightpix;
if (ptr->leftpix < 31) {
srcx = 31;
cmdptr = &ptr->dataofs[32 - ptr->leftpix];
} else {
srcx = ptr->leftpix - 1;
cmdptr = &ptr->dataofs[0];
}
while (++srcx <= stopx) {
short *linecmds = (short *)((unsigned char *)ptr + *cmdptr++);
while (linecmds[0]) {
int y;
int y0 = linecmds[2] / 2;
int y1 = linecmds[0] / 2 - 1;
unsigned char *pixels = (unsigned char *)ptr + y0 + linecmds[1];
for (y = y0; y <= y1; y++) {
unsigned char color = *pixels++;
*(buf + slinex + (y*64)) = color;
}
linecmds += 3;
}
slinex++;
}
}
return buf;
}
byte *Pal_256_RGB(byte *source)
......@@ -58,13 +108,23 @@ void Init3D()
glGenTextures(walcount, waltex);
glGenTextures(sprcount, sprtex);
for (i = 0; i < walcount; i++) {
for (i = 0; i < 2 /*walcount*/; i++) {
glBindTexture(GL_TEXTURE_2D, waltex[i]);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, Pal_256_RGB(PM_GetPage(i)));
}
for (i = 0; i < sprcount; i++) {
for (i = 0; i < 2 /*sprcount*/; i++) {
glBindTexture(GL_TEXTURE_2D, sprtex[i]);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 64, 64, 0, GL_RGBA, GL_UNSIGNED_BYTE, Pal_256_RGBA(SprToLin(PM_GetSpritePage(i))));
}
......@@ -75,13 +135,44 @@ void SetupScaling(int maxheight)
{
}
int weaponscale[NUMWEAPONS] = {SPR_KNIFEREADY,SPR_PISTOLREADY,SPR_MACHINEGUNREADY,SPR_CHAINREADY};
void DrawPlayerWeapon()
{
int shapenum;
if (gamestate.weapon != -1) {
shapenum = weaponscale[gamestate.weapon]+gamestate.weaponframe;
glBindTexture(GL_TEXTURE_2D, waltex[0]);
glBegin(GL_QUADS);
glTexCoord2d(0.0,1.0); glVertex2d(-1.0,-1.0);
glTexCoord2d(1.0,1.0); glVertex2d(+1.0,-1.0);
glTexCoord2d(1.0,0.0); glVertex2d(+1.0,+1.0);
glTexCoord2d(0.0,0.0); glVertex2d(-1.0,+1.0);
glEnd();
}
}
void ThreeDRefresh()
{
int error;
glViewport(xoffset, yoffset+viewheight, viewwidth, viewheight);
DrawPlayerWeapon();
VW_UpdateScreen();
error = glGetError();
if (error != GL_NO_ERROR) {
do {
fprintf(stderr, "GL Error: %d\n", error);
error = glGetError();
} while (error != GL_NO_ERROR);
exit(EXIT_FAILURE);
}
frameon++;
}
......@@ -705,6 +705,8 @@ extern int dirangle[9];
extern boolean startgame,loadedgame;
extern int mouseadjustment;
extern unsigned xoffset, yoffset;
//
// math tables
//
......
......@@ -39,8 +39,6 @@ int xtilestep,ytilestep;
long xintercept,yintercept;
long xstep,ystep;
extern unsigned xoffset, yoffset;
void AsmRefresh (void);
void xBuildCompScale(int height, byte *source, int x);
......
......@@ -10,8 +10,6 @@
=============================================================================
*/
extern unsigned xoffset, yoffset;
boolean ingame,fizzlein;
gametype gamestate;
......
......@@ -4,8 +4,6 @@
/* Originally from David Haslam -- dch@sirius.demon.co.uk */
extern unsigned xoffset, yoffset;
/*
=============================================================================
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment