Commit 3e9c0037 authored by Steven Fuller's avatar Steven Fuller

* Moved IO_AttackShape to SoftDraw and implemented an OpenGL counterpart.

parent 8ecd574b
......@@ -68,10 +68,6 @@ void DrawShape(Word x, Word y, void *ShapePtr)
{
}
void DrawXMShape(Word x, Word y, void *ShapePtr)
{
}
GLuint LastTexture;
GLuint smltex[65];
......@@ -249,6 +245,42 @@ Byte *DeSprite(Byte *data, Byte *pal)
return buf;
}
Byte *DeXMShape(Byte *data, Byte *pal)
{
Byte *buf, *mask, *ptr;
int x, y, w, h;
buf = (Byte *)malloc(128 * 128 * 4);
memset(buf, 0, 128 * 128 * 4);
x = data[0] << 8 | data[1];
y = data[2] << 8 | data[3];
w = data[4] << 8 | data[5];
h = data[6] << 8 | data[7];
data += 8;
mask = data + w*h;
ptr = buf + 512*y + x*4;
do {
int w2 = w;
do {
if (*mask == 0) {
ptr[0] = pal[data[0]*3+0];
ptr[1] = pal[data[0]*3+1];
ptr[2] = pal[data[0]*3+2];
ptr[3] = 255;
}
ptr += 4;
data++;
mask++;
} while (--w2);
ptr += 4*(128 - w);
} while (--h);
return buf;
}
void IO_ClearViewBuffer()
{
LastTexture = 0;
......@@ -257,11 +289,11 @@ void IO_ClearViewBuffer()
/* glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); */
glClear(GL_DEPTH_BUFFER_BIT);
/* IO_AttackShape disables depth */
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
......@@ -281,6 +313,7 @@ void IO_ClearViewBuffer()
GLuint waltex[64];
GLuint sprtex[S_LASTONE];
GLuint weptex[NUMWEAPONS*4];
void InitRenderView()
{
......@@ -360,6 +393,27 @@ void InitRenderView()
free(buf);
}
if (weptex[0] == 0) {
glGenTextures(NUMWEAPONS*4, weptex);
for (i = 0; i < NUMWEAPONS*4; i++) {
Byte *buf = DeXMShape(GameShapes[12+i], pal);
glBindTexture(GL_TEXTURE_2D, weptex[i]);
/*
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_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
free(buf);
}
}
ReleaseAResource(rGamePal);
glEnable(GL_DEPTH_TEST);
......@@ -382,6 +436,38 @@ void InitRenderView()
*/
}
void IO_AttackShape(Word shape)
{
LastTexture = weptex[shape];
if (weptex[shape] == 0) {
fprintf(stderr, "Weapon shape %d is zero texture!\n", shape);
}
glDisable(GL_DEPTH_TEST);
glBindTexture(GL_TEXTURE_2D, weptex[shape]);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glBegin(GL_QUADS);
glTexCoord2f(1.0, 0.0); glVertex2f( 0.2, -0.36);
glTexCoord2f(1.0, 1.0); glVertex2f( 0.2, -1.00);
glTexCoord2f(0.0, 1.0); glVertex2f(-0.2, -1.00);
glTexCoord2f(0.0, 0.0); glVertex2f(-0.2, -0.36);
glEnd();
glPopMatrix();
glMatrixMode(GL_PROJECTION);
glPopMatrix();
}
void StartRenderView()
{
......
......@@ -2,7 +2,16 @@ This is not yet finished, but:
Wolfenstein 3D is an id Software game. This is a port of the Macintosh
version that was released by MacPlay in 1994. You can find information about
the source release at: http://www.maccentral.com/news/0001/24.wolf3d.shtml
the source release at: http://www.maccentral.com/news/0001/24.wolf3d.shtml
WolfReadMe.txt, from that Mac Wolf3d source release, is also included with
this port.
Goals of this Project (Just what am I trying to do?): Like the PC verison,
this game (I consider the PC and Mac versions as different games) was only
available on a certain platform, The Macintosh. I had ported the PC version
to Linux before, so when I found the source to the Macintosh version, I
thought "Why not?" So here it is. My goal is to implement everything the
Macintosh version had, and then somehow improve on that.
To use this, you need the resource fork from the First Encounter (the two
level shareware version) or the Second Encounter (the for-sell version).
......@@ -63,6 +72,9 @@ Any suggestions?
glwolf3d: The OpenGL Version (written using Xlib w/ GLX). I like it. Not
all graphics are currently shown.
Note: The available targets (binaries) may change over time as I decide
which APIs work the best, etc.
To build these binaries, type 'make' in the directory with the source... If
you don't want to build a certain binary, edit the Makefile. On the line
"all: swolf3d xwolf3d gwolf3d glwolf3d" in the Makefile, you can remove the
......@@ -74,10 +86,12 @@ and off you go!
Thanks to id Software for allowing me to release this source under the GNU
GPL (see LICENSE) and Bill Heineman (Programmer and Project Lead of the
Macintosh version) for answering my inquiries. WolfReadMe.txt is included
from the original Mac Wolf3d source release.
Macintosh version) for answering my inquiries.
Steven Fuller <relnev@users.sourceforge.net>
----------------------------
TODO (Stuff to Write About):
Contents:
......@@ -85,6 +99,7 @@ Contents:
* How to Compile
* How to Use
* About (More Specific, document how this source is different than original)
* Thanks
* License
* Contact
......
......@@ -19,6 +19,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "wolfdef.h"
/**********************************
Draw the gun in the foreground
**********************************/
void IO_AttackShape(Word shape)
{
DrawXMShape(ScaleX(128),ScaleY(96),GameShapes[shape+12]);
}
void DisplayScreen(Word res)
{
LongWord *PackPtr;
......
......@@ -11,19 +11,21 @@ TODO:
640x400 or 480 is supported?)
* Finish moving all 2D code to SoftDraw.c
* Finish OpenGL
- Check if top sprite drawing is correct
+ Status bars, Introscreens, etc. [Draw(XM)Shape]
- Not sure exactly yet how I will implement this.
- Check if topsprite drawing is correct
+ Status bars, Introscreens [DrawShape]
- Not sure exactly yet how I will implement this yet.
- Correct viewing frustum
+ Allow window resizing
- Not sure what to about the currently loaded GameShapes (keep or load
most appropiate for the new video mode).
- Only bother with 640x480 versions of GameShapes. Minimum for GLQuake
was 640x480, and you could get lower resolutions with software.
- Could use the LastTexture to have less glBegin/Ends (would need to know
where to stop though (try IO_DisplayViewBuffer).
* Save/Load Games
* Documentation
* Sound!
- Waiting for information about music.
- Need to write sound playing code (probably access /dev/dsp directly
since this source does not have any code for determining sound position).
- Music is planned.
* Interface
+ Menus and dialog boxes
- Command line (temporary workaround for no menus).
......
......@@ -189,17 +189,6 @@ void IO_DrawKeys(Word keys)
}
}
/**********************************
Draw the gun in the foreground
**********************************/
void IO_AttackShape(Word shape)
{
DrawXMShape(ScaleX(128),ScaleY(96),GameShapes[shape+12]);
}
/**********************************
Draw the BJ's face
......
......@@ -175,7 +175,7 @@ int main(int argc, char *argv[])
InitData();
GameViewSize = 2;
GameViewSize = 3;
NewGameWindow(GameViewSize);
ClearTheScreen(BLACK);
......
......@@ -128,7 +128,7 @@ int main(int argc, char *argv[])
InitData();
GameViewSize = 2;
GameViewSize = 3;
NewGameWindow(GameViewSize);
ClearTheScreen(BLACK);
......
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