Commit 7f0ddafd authored by Steven Fuller's avatar Steven Fuller

Added code to save to pcx (for testing and when the screenshot option is

added).  Unsuccessful attempts to fix glx.
parent 93464602
...@@ -3,11 +3,7 @@ ...@@ -3,11 +3,7 @@
* A key to change viewsize while playing (note: max == 20, min == 5 or so...) * A key to change viewsize while playing (note: max == 20, min == 5 or so...)
* Game able to cope at any virtual resolution in software mode. OpenGL * Game able to cope at any virtual resolution in software mode. OpenGL
handles this transparently handles this transparently
* Audio support using OpenAL * Audio support using OpenAL (somewhat decently supported at the moment)
- Problem is, that SDL and OpenAL would need pthread, which with SVGAlib is
a no-go... oh well. Using DGA (if possible at 320x200) would fulfill the
desire for full screen mode, and SVGAlib users can deal with some sort
hackish sound support.
* Add support for the Mac version, if possible * Add support for the Mac version, if possible
* Network support! * Network support!
* Fully compile with no warnings/errors using -Wall -ansi -pedantic and with * Fully compile with no warnings/errors using -Wall -ansi -pedantic and with
...@@ -22,7 +18,8 @@ ...@@ -22,7 +18,8 @@
code code
* Have some sort of way of playing both digital and adlib sounds on all * Have some sort of way of playing both digital and adlib sounds on all
platforms platforms
* Test with other (compatible) available mods * Test with other available mods (that were compatible with the original
game)
* Unified input handling * Unified input handling
* Configuration files and save games which work regardless of operating * Configuration files and save games which work regardless of operating
system/processor/binary build system/processor/binary build
...@@ -9,7 +9,7 @@ CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include ...@@ -9,7 +9,7 @@ CFLAGS = -g -Wall -I/home/relnev/cvs/oal/include
OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \ OBJS = objs.o misc.o id_ca.o id_vh.o id_us.o \
wl_act1.o wl_act2.o wl_agent.o wl_game.o \ wl_act1.o wl_act2.o wl_agent.o wl_game.o \
wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o \ wl_inter.o wl_menu.o wl_play.o wl_state.o wl_text.o wl_main.o \
wl_debug.o sd_oal.o # sd_null.o wl_debug.o gfxsave.o sd_oal.o # sd_null.o
ROBJS = wl_draw.o wl_scale.o ROBJS = wl_draw.o wl_scale.o
SOBJS = $(OBJS) $(ROBJS) vi_svga.o SOBJS = $(OBJS) $(ROBJS) vi_svga.o
XOBJS = $(OBJS) $(ROBJS) vi_xlib.o XOBJS = $(OBJS) $(ROBJS) vi_xlib.o
......
#include <stdio.h>
#include <stdlib.h>
#define PACKED __attribute__((packed))
typedef struct pcx_header_type
{
char manufacturer;
char version;
char encoding;
char bits_per_pixel;
short int x, y;
short int width, height;
short int horz_res;
short int virt_res;
char ega_palette[48];
char reserved;
char num_color_planes;
short int byte_per_line;
short int palette_type;
short int hscreen_size;
short int vscreen_size;
char padding[54];
} PACKED pcx_header, *pcx_header_ptr;
void SavePCX256ToFile(unsigned char *buf, int width, int height, unsigned char *pal, char *name)
{
FILE *fp;
pcx_header ph;
unsigned char *dat, *ptr, *ptrd, ch;
int x, y, z;
ph.manufacturer = 10;
ph.version = 5;
ph.encoding = 1;
ph.bits_per_pixel = 8;
ph.x = ph.y = 0;
ph.width = width - 1;
ph.height = height - 1;
ph.horz_res = ph.virt_res = 0;
for (x = 0; x < sizeof(ph.ega_palette); x++)
ph.ega_palette[x] = 0;
ph.reserved = 0;
ph.num_color_planes = 1;
ph.byte_per_line = width;
ph.palette_type = 1;
ph.hscreen_size = width;
ph.vscreen_size = height;
for (x = 0; x < sizeof(ph.padding); x++)
ph.padding[x] = 0;
#if 0
dat = malloc(width * height * 2);
for (x = 0; x < width * height; x++) {
*(dat + x*2) = 0xC1;
*(dat + x*2+1) = *(buf + x);
}
z = width * height * 2;
#else
dat = malloc(width * height * 2);
ptr = buf; ptrd = dat;
x = 0; z = 0;
while (x < width * height) {
ch = *ptr;
ptr++;
x++;
y = 0xC1;
while((x < width * height) && (*ptr == ch) && (y < 0xFF)) {
x++; y++; ptr++;
}
*ptrd = y;
ptrd++;
*ptrd = ch;
ptrd++;
z += 2;
}
#endif
fp = fopen(name, "w");
fwrite(&ph, sizeof(ph), 1, fp);
fwrite(dat, 1, z, fp);
fputc(12, fp);
fwrite(pal, 1, 768, fp);
fclose(fp);
free(dat);
}
void SavePCXRGBToFile(unsigned char *buf, int width, int height, char *name)
{
FILE *fp;
pcx_header ph;
unsigned char *dat;
int x, y, s;
memset(&ph, 0, sizeof(ph));
ph.manufacturer = 10;
ph.version = 5;
ph.encoding = 1;
ph.bits_per_pixel = 8;
ph.x = ph.y = 0;
ph.width = width - 1;
ph.height = height - 1;
ph.horz_res = ph.virt_res = 0;
ph.num_color_planes = 3;
ph.byte_per_line = width;
ph.palette_type = 1;
ph.hscreen_size = width;
ph.vscreen_size = height;
dat = malloc(width * height * 2 * 3);
for (y = 0; y < height; y++) {
for (s = 0; s < 3; s++) {
for (x = 0; x < width; x++) {
*(dat + (y*(width*3) + (width*s) + x)*2) = 0xC1;
*(dat + (y*(width*3) + (width*s) + x)*2+1) = *(buf + y*(width*3) + x*3 + s);
}
}
}
fp = fopen(name, "w");
fwrite(&ph, sizeof(ph), 1, fp);
fwrite(dat, 1, width * height * 2 * 3, fp);
fclose(fp);
free(dat);
}
...@@ -224,7 +224,7 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps) ...@@ -224,7 +224,7 @@ void VL_FadeOut(int start, int end, int red, int green, int blue, int steps)
================= =================
*/ */
void VL_FadeIn(int start, int end, byte *palette, int steps) void VL_FadeIn(int start, int end, const byte *palette, int steps)
{ {
int i,j,delta; int i,j,delta;
......
...@@ -49,7 +49,7 @@ void VW_DrawPropString(char *string); ...@@ -49,7 +49,7 @@ void VW_DrawPropString(char *string);
boolean FizzleFade(unsigned xoffset, unsigned yoffset, unsigned width,unsigned height, unsigned frames,boolean abortable); boolean FizzleFade(unsigned xoffset, unsigned yoffset, unsigned width,unsigned height, unsigned frames,boolean abortable);
void VL_FadeOut(int start, int end, int red, int green, int blue, int steps); void VL_FadeOut(int start, int end, int red, int green, int blue, int steps);
void VL_FadeIn(int start, int end, byte *palette, int steps); void VL_FadeIn(int start, int end, const byte *palette, int steps);
void LatchDrawPic(unsigned x, unsigned y, unsigned picnum); void LatchDrawPic(unsigned x, unsigned y, unsigned picnum);
void LoadLatchMem(void); void LoadLatchMem(void);
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
extern int _argc; extern int _argc;
extern char **_argv; extern char **_argv;
void SavePCX256ToFile(unsigned char *buf, int width, int height, unsigned char *pal, char *name);
void SavePCXRGBToFile(unsigned char *buf, int width, int height, char *name);
void set_TimeCount(unsigned long t); void set_TimeCount(unsigned long t);
unsigned long get_TimeCount(); unsigned long get_TimeCount();
......
...@@ -14,7 +14,7 @@ void VL_WaitVBL(int vbls); ...@@ -14,7 +14,7 @@ void VL_WaitVBL(int vbls);
void VW_UpdateScreen(); void VW_UpdateScreen();
void VL_FillPalette(int red, int green, int blue); void VL_FillPalette(int red, int green, int blue);
void VL_SetPalette(byte *palette); void VL_SetPalette(const byte *palette);
void VL_GetPalette(byte *palette); void VL_GetPalette(byte *palette);
void VL_Plot(int x, int y, int color); void VL_Plot(int x, int y, int color);
......
...@@ -29,8 +29,8 @@ int attrib[] = { ...@@ -29,8 +29,8 @@ int attrib[] = {
GLX_RED_SIZE, 5, GLX_RED_SIZE, 5,
GLX_GREEN_SIZE, 5, GLX_GREEN_SIZE, 5,
GLX_BLUE_SIZE, 5, GLX_BLUE_SIZE, 5,
GLX_DEPTH_SIZE, 16, // GLX_DEPTH_SIZE, 16,
// GLX_DOUBLEBUFFER, GLX_DOUBLEBUFFER,
None None
}; };
...@@ -84,7 +84,7 @@ int main(int argc, char *argv[]) ...@@ -84,7 +84,7 @@ int main(int argc, char *argv[])
printf("GLX_EXTENSIONS: %s\n", glXQueryExtensionsString(dpy, DefaultScreen(dpy))); printf("GLX_EXTENSIONS: %s\n", glXQueryExtensionsString(dpy, DefaultScreen(dpy)));
} }
vi = glXChooseVisual(dpy, DefaultScreen(dpy), attrib); vi = glXChooseVisual(dpy, screen, attrib);
if (vi == NULL) { if (vi == NULL) {
Quit("No suitable GL visual found!"); Quit("No suitable GL visual found!");
...@@ -99,10 +99,11 @@ int main(int argc, char *argv[]) ...@@ -99,10 +99,11 @@ int main(int argc, char *argv[])
cmap = XCreateColormap(dpy, root, vi->visual, AllocNone); cmap = XCreateColormap(dpy, root, vi->visual, AllocNone);
attr.colormap = cmap; attr.colormap = cmap;
attr.background_pixel = BlackPixel(dpy, screen);
attr.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask | attr.event_mask = KeyPressMask | KeyReleaseMask | ExposureMask |
StructureNotifyMask; StructureNotifyMask;
attrmask = CWColormap | CWEventMask; attrmask = CWColormap | CWEventMask | CWBackPixel;
win = XCreateWindow(dpy, root, 0, 0, 320, 200, 0, CopyFromParent, win = XCreateWindow(dpy, root, 0, 0, 320, 200, 0, vi->depth,
InputOutput, vi->visual, attrmask, &attr); InputOutput, vi->visual, attrmask, &attr);
if (win == None) { if (win == None) {
...@@ -132,16 +133,18 @@ int main(int argc, char *argv[]) ...@@ -132,16 +133,18 @@ int main(int argc, char *argv[])
cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &fg, &bg, 0, 0); cursor = XCreatePixmapCursor(dpy, bitmap, bitmap, &fg, &bg, 0, 0);
XDefineCursor(dpy, win, cursor); XDefineCursor(dpy, win, cursor);
XFlush(dpy);
glXMakeCurrent(dpy, win, ctx); glXMakeCurrent(dpy, win, ctx);
XMapWindow(dpy, win);
XFlush(dpy);
printf("GL Library:\n"); printf("GL Library:\n");
printf("GL_VENDOR: %s\n", glGetString(GL_VENDOR)); printf("GL_VENDOR: %s\n", glGetString(GL_VENDOR));
printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER)); printf("GL_RENDERER: %s\n", glGetString(GL_RENDERER));
printf("GL_VERSION: %s\n", glGetString(GL_VERSION)); printf("GL_VERSION: %s\n", glGetString(GL_VERSION));
printf("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS)); printf("GL_EXTENSIONS: %s\n", glGetString(GL_EXTENSIONS));
return WolfMain(argc, argv); return WolfMain(argc, argv);
} }
...@@ -173,7 +176,7 @@ void VL_Startup() ...@@ -173,7 +176,7 @@ void VL_Startup()
if (gfxbuf == NULL) if (gfxbuf == NULL)
gfxbuf = malloc(320 * 200 * 1); gfxbuf = malloc(320 * 200 * 1);
XMapWindow(dpy, win); // XMapWindow(dpy, win);
glColor4f(0.0f, 0.0f, 0.0f, 0.0f); glColor4f(0.0f, 0.0f, 0.0f, 0.0f);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
...@@ -184,7 +187,12 @@ void VL_Startup() ...@@ -184,7 +187,12 @@ void VL_Startup()
glLoadIdentity(); glLoadIdentity();
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glLoadIdentity();
glMatrixMode(GL_TEXTURE);
glLoadIdentity();
glDisable(GL_CULL_FACE);
glDisable(GL_DEPTH_TEST);
Init3D(); Init3D();
} }
...@@ -254,7 +262,7 @@ void VL_FillPalette(int red, int green, int blue) ...@@ -254,7 +262,7 @@ void VL_FillPalette(int red, int green, int blue)
================= =================
*/ */
void VL_SetPalette(byte *palette) void VL_SetPalette(const byte *palette)
{ {
} }
......
...@@ -91,8 +91,8 @@ byte *Pal_256_RGBA(byte *source) ...@@ -91,8 +91,8 @@ byte *Pal_256_RGBA(byte *source)
return dest; return dest;
} }
int *sprtex, sprcount; GLuint *sprtex, sprcount;
int *waltex, walcount; GLuint *waltex, walcount;
void Init3D() void Init3D()
{ {
...@@ -101,14 +101,18 @@ void Init3D() ...@@ -101,14 +101,18 @@ void Init3D()
printf("start init\n"); printf("start init\n");
walcount = PMSpriteStart; walcount = PMSpriteStart;
waltex = (int *)malloc(sizeof(int) * walcount); waltex = (int *)malloc(sizeof(GLuint) * walcount);
sprcount = PMSoundStart - PMSpriteStart; sprcount = PMSoundStart - PMSpriteStart;
sprtex = (int *)malloc(sizeof(int) * sprcount); sprtex = (int *)malloc(sizeof(GLuint) * sprcount);
printf("creating %d walls, %d sprites\n", walcount, sprcount);
walcount = 2;
sprcount = 2;
glGenTextures(walcount, waltex); glGenTextures(walcount, waltex);
glGenTextures(sprcount, sprtex); glGenTextures(sprcount, sprtex);
for (i = 0; i < 2 /*walcount*/; i++) { for (i = 0; i < walcount; i++) {
glBindTexture(GL_TEXTURE_2D, waltex[i]); glBindTexture(GL_TEXTURE_2D, waltex[i]);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 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_MIN_FILTER, GL_NEAREST);
...@@ -118,7 +122,7 @@ void Init3D() ...@@ -118,7 +122,7 @@ void Init3D()
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, Pal_256_RGB(PM_GetPage(i))); 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 < 2 /*sprcount*/; i++) { for (i = 0; i < sprcount; i++) {
glBindTexture(GL_TEXTURE_2D, sprtex[i]); glBindTexture(GL_TEXTURE_2D, sprtex[i]);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); 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_MIN_FILTER, GL_NEAREST);
...@@ -136,29 +140,33 @@ void SetupScaling(int maxheight) ...@@ -136,29 +140,33 @@ void SetupScaling(int maxheight)
} }
int weaponscale[NUMWEAPONS] = {SPR_KNIFEREADY,SPR_PISTOLREADY,SPR_MACHINEGUNREADY,SPR_CHAINREADY}; int weaponscale[NUMWEAPONS] = {SPR_KNIFEREADY,SPR_PISTOLREADY,SPR_MACHINEGUNREADY,SPR_CHAINREADY};
#include <X11/Xlib.h>
extern Display *dpy;
extern Window win;
void DrawPlayerWeapon() void DrawPlayerWeapon()
{ {
int shapenum; int shapenum;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_TEXTURE_2D);
if (gamestate.weapon != -1) { if (gamestate.weapon != -1) {
shapenum = weaponscale[gamestate.weapon]+gamestate.weaponframe; shapenum = weaponscale[gamestate.weapon]+gamestate.weaponframe;
glBindTexture(GL_TEXTURE_2D, waltex[0]); glBindTexture(GL_TEXTURE_2D, waltex[1]);
glBegin(GL_QUADS); glBegin(GL_QUADS);
glTexCoord2d(0.0,1.0); glVertex2d(-1.0,-1.0); glTexCoord2d(0.0,1.0); glVertex2d(-1.0,-1.0);
glTexCoord2d(1.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(1.0,0.0); glVertex2d(+1.0,+1.0);
glTexCoord2d(0.0,0.0); glVertex2d(-1.0,+1.0); glTexCoord2d(0.0,0.0); glVertex2d(-1.0,+1.0);
glEnd(); glEnd();
} }
glXSwapBuffers(dpy, win);
} }
void ThreeDRefresh() void ThreeDRefresh()
{ {
int error; int error;
glViewport(xoffset, yoffset+viewheight, viewwidth, viewheight); //glViewport(xoffset, yoffset+viewheight, viewwidth, viewheight);
DrawPlayerWeapon(); DrawPlayerWeapon();
......
...@@ -111,7 +111,7 @@ void VL_FillPalette(int red, int green, int blue) ...@@ -111,7 +111,7 @@ void VL_FillPalette(int red, int green, int blue)
================= =================
*/ */
void VL_SetPalette(byte *palette) void VL_SetPalette(const byte *palette)
{ {
int i; int i;
......
...@@ -458,7 +458,7 @@ void VL_FillPalette(int red, int green, int blue) ...@@ -458,7 +458,7 @@ void VL_FillPalette(int red, int green, int blue)
================= =================
*/ */
void VL_SetPalette(byte *palette) void VL_SetPalette(const byte *palette)
{ {
int i; int i;
......
...@@ -753,7 +753,7 @@ int MS_CheckParm(char *check) ...@@ -753,7 +753,7 @@ int MS_CheckParm(char *check)
if (!*parm++) if (!*parm++)
break; // hit end of string without an alphanum break; // hit end of string without an alphanum
if ( !strcasecmp(check,parm) ) if ( !stricmp(check,parm) )
return i; return i;
} }
......
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