Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
wolf3d
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PocketInsanity
wolf3d
Commits
33d9dccc
Commit
33d9dccc
authored
Jun 02, 2000
by
Steven Fuller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More work to prep for the OpenGL version
parent
9d9a85aa
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
533 additions
and
473 deletions
+533
-473
Burger.c
macsrc/Burger.c
+0
-116
GLDraw.c
macsrc/GLDraw.c
+45
-0
Makefile
macsrc/Makefile
+1
-1
RefBsp.c
macsrc/RefBsp.c
+1
-300
Refresh.c
macsrc/Refresh.c
+3
-0
SoftDraw.c
macsrc/SoftDraw.c
+418
-0
TODO
macsrc/TODO
+2
-3
vi_glx.c
macsrc/vi_glx.c
+63
-53
No files found.
macsrc/Burger.c
View file @
33d9dccc
...
@@ -27,18 +27,6 @@ LongWord YTable[480];
...
@@ -27,18 +27,6 @@ LongWord YTable[480];
#define BRGR 0x42524752
#define BRGR 0x42524752
/**********************************
Graphics subsystem
**********************************/
/**********************************
Draw a masked shape
**********************************/
void
InitYTable
(
void
)
void
InitYTable
(
void
)
{
{
Word
i
;
Word
i
;
...
@@ -52,110 +40,6 @@ void InitYTable(void)
...
@@ -52,110 +40,6 @@ void InitYTable(void)
}
while
(
++
i
<
480
);
}
while
(
++
i
<
480
);
}
}
/**********************************
Draw a shape
**********************************/
void
DrawShape
(
Word
x
,
Word
y
,
void
*
ShapePtr
)
{
unsigned
char
*
ScreenPtr
;
unsigned
char
*
Screenad
;
unsigned
char
*
ShapePtr2
;
unsigned
short
*
ShapePtr3
;
Word
Width
;
Word
Height
;
Word
Width2
;
ShapePtr3
=
ShapePtr
;
Width
=
sMSB
(
ShapePtr3
[
0
]);
/* 16 bit width */
Height
=
sMSB
(
ShapePtr3
[
1
]);
/* 16 bit height */
ShapePtr2
=
(
unsigned
char
*
)
&
ShapePtr3
[
2
];
ScreenPtr
=
(
unsigned
char
*
)
&
VideoPointer
[
YTable
[
y
]
+
x
];
do
{
Width2
=
Width
;
Screenad
=
ScreenPtr
;
do
{
*
Screenad
++
=
*
ShapePtr2
++
;
}
while
(
--
Width2
);
ScreenPtr
+=
VideoWidth
;
}
while
(
--
Height
);
}
/**********************************
Draw a masked shape
**********************************/
void
DrawMShape
(
Word
x
,
Word
y
,
void
*
ShapePtr
)
{
unsigned
char
*
ScreenPtr
;
unsigned
char
*
Screenad
;
unsigned
char
*
MaskPtr
;
unsigned
char
*
ShapePtr2
;
Word
Width
;
Word
Height
;
Word
Width2
;
ShapePtr2
=
ShapePtr
;
Width
=
ShapePtr2
[
1
];
Height
=
ShapePtr2
[
3
];
ShapePtr2
+=
4
;
MaskPtr
=
&
ShapePtr2
[
Width
*
Height
];
ScreenPtr
=
(
unsigned
char
*
)
&
VideoPointer
[
YTable
[
y
]
+
x
];
do
{
Width2
=
Width
;
Screenad
=
ScreenPtr
;
do
{
*
Screenad
=
(
*
Screenad
&
*
MaskPtr
++
)
|
*
ShapePtr2
++
;
++
Screenad
;
}
while
(
--
Width2
);
ScreenPtr
+=
VideoWidth
;
}
while
(
--
Height
);
}
/**********************************
Draw a masked shape with an offset
**********************************/
void
DrawXMShape
(
Word
x
,
Word
y
,
void
*
ShapePtr
)
{
unsigned
short
*
ShapePtr2
;
ShapePtr2
=
ShapePtr
;
x
+=
sMSB
(
ShapePtr2
[
0
]);
y
+=
sMSB
(
ShapePtr2
[
1
]);
DrawMShape
(
x
,
y
,
&
ShapePtr2
[
2
]);
}
/**********************************
Clear the screen to a specific color
**********************************/
void
ClearTheScreen
(
Word
Color
)
{
Word
x
,
y
;
unsigned
char
*
TempPtr
;
TempPtr
=
VideoPointer
;
y
=
SCREENHEIGHT
;
/* 200 lines high */
do
{
x
=
0
;
do
{
TempPtr
[
x
]
=
Color
;
/* Fill color */
}
while
(
++
x
<
SCREENWIDTH
);
TempPtr
+=
VideoWidth
;
/* Next line down */
}
while
(
--
y
);
}
/**********************************
/**********************************
Palette Manager
Palette Manager
...
...
macsrc/GLDraw.c
View file @
33d9dccc
...
@@ -17,3 +17,48 @@ along with this program; if not, write to the Free Software
...
@@ -17,3 +17,48 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
*/
#include <GL/gl.h>
#include <GL/glext.h>
#include "wolfdef.h"
extern
Byte
Pal
[
768
];
void
ClearTheScreen
(
Word
c
)
{
glClearColor
((
double
)
Pal
[
c
*
3
+
0
]
/
256
.
0
,
(
double
)
Pal
[
c
*
3
+
1
]
/
256
.
0
,
(
double
)
Pal
[
c
*
3
+
2
]
/
256
.
0
,
0
.
0
);
glClear
(
GL_COLOR_BUFFER_BIT
);
}
void
DrawShape
(
Word
x
,
Word
y
,
void
*
ShapePtr
)
{
}
void
DrawXMShape
(
Word
x
,
Word
y
,
void
*
ShapePtr
)
{
}
void
DrawSmall
(
Word
x
,
Word
y
,
Word
tile
)
{
}
void
MakeSmallFont
(
void
)
{
}
void
KillSmallFont
(
void
)
{
}
void
IO_ScaleMaskedColumn
(
Word
x
,
Word
scale
,
unsigned
short
*
sprite
,
Word
column
)
{
/* TODO: remove stuff from sprites */
}
void
StartRenderView
()
{
}
void
P_DrawSeg
(
saveseg_t
*
seg
)
{
}
macsrc/Makefile
View file @
33d9dccc
...
@@ -13,7 +13,7 @@ OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \
...
@@ -13,7 +13,7 @@ OBJS = Data.o Doors.o EnMove.o EnThink.o Intro.o Level.o \
RefBsp.o RefSprite.o Refresh.o Refresh2.o Sight.o Main.o
\
RefBsp.o RefSprite.o Refresh.o Refresh2.o Sight.o Main.o
\
StateDef.o WolfMain.o WolfIO.o InterMis.o Burger.o stub.o res.o
StateDef.o WolfMain.o WolfIO.o InterMis.o Burger.o stub.o res.o
SOFTOBJS
=
SoftDraw.o
SOFTOBJS
=
SoftDraw.o
OGLOBJS
=
SoftDraw.o
#
OGLOBJS
=
GLDraw.o
SOBJS
=
$(SOFTOBJS)
$(OBJS)
vi_svga.o
SOBJS
=
$(SOFTOBJS)
$(OBJS)
vi_svga.o
XOBJS
=
$(SOFTOBJS)
$(OBJS)
vi_xlib.o
XOBJS
=
$(SOFTOBJS)
$(OBJS)
vi_xlib.o
GOBJS
=
$(SOFTOBJS)
$(OBJS)
vi_gtk.o
GOBJS
=
$(SOFTOBJS)
$(OBJS)
vi_gtk.o
...
...
macsrc/RefBsp.c
View file @
33d9dccc
...
@@ -32,174 +32,13 @@ static Word checkcoord[11][4] = { /* Indexs to the bspcoord table */
...
@@ -32,174 +32,13 @@ static Word checkcoord[11][4] = { /* Indexs to the bspcoord table */
{
2
,
1
,
3
,
1
},
{
2
,
1
,
3
,
1
},
{
2
,
1
,
3
,
0
}};
{
2
,
1
,
3
,
0
}};
/**********************************
Draw a 3-D textured polygon, must be done FAST!
**********************************/
void
RenderWallLoop
(
Word
x1
,
Word
x2
,
Word
distance
)
{
fixed_t
texturecolumn
;
Word
tile
,
scaler
,
angle
;
/* calculate and draw each column */
if
(
rw_downside
)
{
while
(
x1
<
x2
)
{
/* Time to draw? */
scaler
=
rw_scale
>>
FRACBITS
;
/* Get the draw scale */
xscale
[
x1
]
=
scaler
;
/* Save the scale factor */
angle
=
(
xtoviewangle
[
x1
]
+
rw_centerangle
)
&
4095
;
/* TODO: for some reason i had to add this */
texturecolumn
=
rw_midpoint
-
SUFixedMul
(
finetangent
[
angle
],
distance
);
/* Which texture to use? */
if
((
Word
)
texturecolumn
<
rw_mintex
)
{
texturecolumn
=
rw_mintex
;
}
else
if
((
Word
)
texturecolumn
>=
rw_maxtex
)
{
texturecolumn
=
rw_maxtex
-
1
;
}
tile
=
rw_texture
[
texturecolumn
>>
8
];
/* Get the tile to use */
IO_ScaleWallColumn
(
x1
,
scaler
,
tile
,(
texturecolumn
>>
1
)
&
127
);
/* Draw the line */
++
x1
;
/* Next x */
rw_scale
+=
rw_scalestep
;
/* Step the scale factor for the wall */
}
return
;
}
while
(
x1
<
x2
)
{
/* Time to draw? */
scaler
=
rw_scale
>>
FRACBITS
;
/* Get the draw scale */
xscale
[
x1
]
=
scaler
;
/* Save the scale factor */
angle
=
(
xtoviewangle
[
x1
]
+
rw_centerangle
)
&
4095
;
/* TODO: same as above */
texturecolumn
=
SUFixedMul
(
finetangent
[
angle
],
distance
)
+
rw_midpoint
;
/* Which texture to use? */
if
((
Word
)
texturecolumn
<
rw_mintex
)
{
texturecolumn
=
rw_mintex
;
}
else
if
((
Word
)
texturecolumn
>=
rw_maxtex
)
{
texturecolumn
=
rw_maxtex
-
1
;
}
tile
=
rw_texture
[
texturecolumn
>>
8
];
/* Get the tile to use */
if
(
!
(
sMSB
(
WallListPtr
[
tile
+
1
])
&
0x4000
))
{
texturecolumn
^=
0xff
;
/* Reverse the tile for N,W walls */
}
IO_ScaleWallColumn
(
x1
,
scaler
,
tile
,(
texturecolumn
>>
1
)
&
127
);
/* Draw the line */
++
x1
;
/* Next x */
rw_scale
+=
rw_scalestep
;
/* Step the scale factor for the wall */
}
}
/*
=====================
=
= RenderWallRange
=
= Draw a wall segment between start and stop angles (inclusive) (short angles)
= No clipping is needed
=
======================
*/
void
RenderWallRange
(
Word
start
,
Word
stop
,
saveseg_t
*
seg
,
Word
distance
)
{
LongWord
scale2
;
Word
vangle
;
Word
x1
,
x2
;
/* mark the segment as visible for auto map*/
seg
->
dir
|=
DIR_SEENFLAG
;
/* for automap*/
areavis
[
seg
->
area
]
=
1
;
/* for sprite drawing*/
start
-=
ANGLE180
;
/* Adjust the start angle */
stop
-=
ANGLE180
;
/* Adjust the stop angle */
vangle
=
(
Word
)(
start
+
ANGLE90
)
>>
ANGLETOFINESHIFT
;
x1
=
viewangletox
[
vangle
];
vangle
=
(
Word
)(
stop
+
ANGLE90
-
1
)
>>
ANGLETOFINESHIFT
;
/* make non inclusive*/
x2
=
viewangletox
[
vangle
];
if
(
x2
==
x1
)
{
return
;
/* less than one column wide*/
}
rw_scale
=
(
long
)
ScaleFromGlobalAngle
(
start
+
centershort
,
distance
)
<<
FRACBITS
;
if
(
x2
>
x1
+
1
)
{
scale2
=
(
long
)
ScaleFromGlobalAngle
(
stop
+
centershort
,
distance
)
<<
FRACBITS
;
rw_scalestep
=
(
long
)(
scale2
-
rw_scale
)
/
(
long
)(
x2
-
x1
);
}
RenderWallLoop
(
x1
,
x2
,
distance
);
}
/*
===============================================================================
=
= ClipWallSegment
=
= Clips the given screenpost and includes it in newcolumn
===============================================================================
*/
/* a screenpost_t is a solid range of visangles, used to clip and detect*/
/* span exposures / hidings*/
typedef
struct
{
typedef
struct
{
Word
top
,
bottom
;
Word
top
,
bottom
;
}
screenpost_t
;
}
screenpost_t
;
#define MAXSEGS 16
#define MAXSEGS 16
screenpost_t
solidsegs
[
MAXSEGS
],
*
newend
;
/* newend is one past the last valid seg */
screenpost_t
solidsegs
[
MAXSEGS
],
*
newend
;
void
ClipWallSegment
(
Word
top
,
Word
bottom
,
saveseg_t
*
seg
,
Word
distance
)
{
screenpost_t
*
next
,
*
start
;
/* find the first clippost that touches the source post (adjacent pixels are touching)*/
start
=
solidsegs
;
while
(
start
->
bottom
>
top
+
1
)
{
start
++
;
}
if
(
top
>
start
->
top
)
{
if
(
bottom
>
start
->
top
+
1
)
{
/* post is entirely visible (above start), so insert a new clippost*/
RenderWallRange
(
top
,
bottom
,
seg
,
distance
);
next
=
newend
;
newend
++
;
while
(
next
!=
start
)
{
*
next
=
*
(
next
-
1
);
next
--
;
}
next
->
top
=
top
;
next
->
bottom
=
bottom
;
return
;
}
/* there is a fragment above *start*/
RenderWallRange
(
top
,
start
->
top
+
1
,
seg
,
distance
);
start
->
top
=
top
;
/* adjust the clip size*/
}
if
(
bottom
>=
start
->
bottom
)
return
;
/* bottom contained in start*/
next
=
start
;
while
(
bottom
<=
(
next
+
1
)
->
top
+
1
)
{
/* there is a fragment between two posts*/
RenderWallRange
(
next
->
bottom
-
1
,
(
next
+
1
)
->
top
+
1
,
seg
,
distance
);
next
++
;
if
(
bottom
>=
next
->
bottom
)
{
/* bottom is contained in next*/
start
->
bottom
=
next
->
bottom
;
/* adjust the clip size*/
goto
crunch
;
}
}
/* there is a fragment after *next*/
RenderWallRange
(
next
->
bottom
-
1
,
bottom
,
seg
,
distance
);
start
->
bottom
=
bottom
;
/* adjust the clip size*/
/* remove start+1 to next from the clip list, because start now covers their area*/
crunch:
if
(
next
==
start
)
{
return
;
/* post just extended past the bottom of one post*/
}
while
(
next
++
!=
newend
)
/* remove a post*/
*++
start
=
*
next
;
newend
=
start
+
1
;
}
/**********************************
/**********************************
...
@@ -217,143 +56,6 @@ void ClearClipSegs(void)
...
@@ -217,143 +56,6 @@ void ClearClipSegs(void)
newend
=
solidsegs
+
2
;
newend
=
solidsegs
+
2
;
}
}
/**********************************
Clip and draw a given wall segment
**********************************/
void
P_DrawSeg
(
saveseg_t
*
seg
)
{
Word
segplane
;
Word
door
;
door_t
*
door_p
;
unsigned
short
span
,
tspan
;
unsigned
short
angle1
,
angle2
;
int
texslide
;
int
distance
;
if
(
seg
->
dir
&
DIR_DISABLEDFLAG
)
{
/* Segment shut down? */
return
;
/* pushwall part*/
}
segplane
=
(
Word
)
seg
->
plane
<<
7
;
rw_mintex
=
(
Word
)
seg
->
min
<<
7
;
rw_maxtex
=
(
Word
)
seg
->
max
<<
7
;
/* adjust pushwall segs */
if
(
seg
==
pwallseg
)
{
/* Is this the active pushwall? */
if
(
seg
->
dir
&
1
)
{
/* east/west */
segplane
+=
PushWallRec
.
pwallychange
;
}
else
{
/* north/south */
segplane
+=
PushWallRec
.
pwallxchange
;
}
}
/* get texture*/
if
(
seg
->
texture
>=
129
)
{
/* segment is a door */
door
=
seg
->
texture
-
129
;
/* Which door is this? */
door_p
=
&
doors
[
door
];
rw_texture
=
&
textures
[
129
+
(
door_p
->
info
>>
1
)][
0
];
texslide
=
door_p
->
position
;
rw_mintex
+=
texslide
;
}
else
{
texslide
=
0
;
rw_texture
=
&
textures
[
seg
->
texture
][
0
];
}
switch
(
seg
->
dir
&
3
)
{
/* mask off the flags*/
case
di_north
:
distance
=
viewx
-
segplane
;
if
(
distance
<=
0
)
{
return
;
/* back side*/
}
rw_downside
=
FALSE
;
rw_midpoint
=
viewy
;
normalangle
=
2
*
FINEANGLES
/
4
;
angle1
=
PointToAngle
(
segplane
,
rw_maxtex
);
angle2
=
PointToAngle
(
segplane
,
rw_mintex
);
break
;
case
di_south
:
distance
=
segplane
-
viewx
;
if
(
distance
<=
0
)
{
return
;
/* back side*/
}
rw_downside
=
TRUE
;
rw_midpoint
=
viewy
;
normalangle
=
0
*
FINEANGLES
/
4
;
angle1
=
PointToAngle
(
segplane
,
rw_mintex
);
angle2
=
PointToAngle
(
segplane
,
rw_maxtex
);
break
;
case
di_east
:
distance
=
viewy
-
segplane
;
if
(
distance
<=
0
)
{
return
;
/* back side*/
}
rw_downside
=
TRUE
;
rw_midpoint
=
viewx
;
normalangle
=
1
*
FINEANGLES
/
4
;
angle1
=
PointToAngle
(
rw_mintex
,
segplane
);
angle2
=
PointToAngle
(
rw_maxtex
,
segplane
);
break
;
case
di_west
:
distance
=
segplane
-
viewy
;
if
(
distance
<=
0
)
{
return
;
/* back side*/
}
rw_downside
=
FALSE
;
rw_midpoint
=
viewx
;
normalangle
=
3
*
FINEANGLES
/
4
;
angle1
=
PointToAngle
(
rw_maxtex
,
segplane
);
angle2
=
PointToAngle
(
rw_mintex
,
segplane
);
break
;
}
/* clip to view edges*/
span
=
angle1
-
angle2
;
if
(
span
>=
0x8000
)
{
/* Test for negative (32 bit clean) */
return
;
}
angle1
-=
centershort
;
angle2
-=
centershort
;
++
angle2
;
/* make angle 2 non inclusive*/
tspan
=
angle1
+
clipshortangle
;
if
(
tspan
>
clipshortangle2
)
{
tspan
-=
clipshortangle2
;
if
(
tspan
>=
span
)
{
return
;
/* totally off the left edge*/
}
angle1
=
clipshortangle
;
}
tspan
=
clipshortangle
-
angle2
;
if
(
tspan
>
clipshortangle2
)
{
tspan
-=
clipshortangle2
;
if
(
tspan
>=
span
)
{
return
;
/* totally off the left edge*/
}
angle2
=
-
clipshortangle
;
}
/* calc center angle for texture mapping*/
rw_centerangle
=
(
centerangle
-
normalangle
)
&
FINEMASK
;
if
(
rw_centerangle
>
(
FINEANGLES
/
2
))
{
rw_centerangle
-=
FINEANGLES
;
}
rw_centerangle
+=
FINEANGLES
/
4
;
rw_midpoint
-=
texslide
;
rw_mintex
-=
texslide
;
angle1
+=
ANGLE180
;
/* adjust so angles are unsigned*/
angle2
+=
ANGLE180
;
ClipWallSegment
(
angle1
,
angle2
,
seg
,
distance
);
}
/**********************************
/**********************************
Returns True if some part of the BSP dividing line might be visible
Returns True if some part of the BSP dividing line might be visible
...
@@ -401,7 +103,6 @@ Boolean CheckBSPNode(Word boxpos)
...
@@ -401,7 +103,6 @@ Boolean CheckBSPNode(Word boxpos)
angle2
=
-
clipshortangle
;
angle2
=
-
clipshortangle
;
}
}
/* find the first clippost that touches the source post (adjacent pixels are touching)*/
/* find the first clippost that touches the source post (adjacent pixels are touching)*/
uangle1
=
angle1
+
ANGLE180
;
uangle1
=
angle1
+
ANGLE180
;
uangle2
=
angle2
+
ANGLE180
;
uangle2
=
angle2
+
ANGLE180
;
...
...
macsrc/Refresh.c
View file @
33d9dccc
...
@@ -449,6 +449,9 @@ void RenderView(void)
...
@@ -449,6 +449,9 @@ void RenderView(void)
viewsin
=
sintable
[
gamestate
.
viewangle
];
/* Get the basic sine */
viewsin
=
sintable
[
gamestate
.
viewangle
];
/* Get the basic sine */
viewcos
=
costable
[
gamestate
.
viewangle
];
/* Get the basic cosine */
viewcos
=
costable
[
gamestate
.
viewangle
];
/* Get the basic cosine */
memset
(
areavis
,
0
,
sizeof
(
areavis
));
/* No areas are visible */
memset
(
areavis
,
0
,
sizeof
(
areavis
));
/* No areas are visible */
StartRenderView
();
/* Marker to let GL code know */
ClearClipSegs
();
/* Clip first seg only to sides of screen */
ClearClipSegs
();
/* Clip first seg only to sides of screen */
IO_ClearViewBuffer
();
/* Erase to ceiling / floor colors*/
IO_ClearViewBuffer
();
/* Erase to ceiling / floor colors*/
...
...
macsrc/SoftDraw.c
View file @
33d9dccc
This diff is collapsed.
Click to expand it.
macsrc/TODO
View file @
33d9dccc
...
@@ -9,18 +9,17 @@ TODO:
...
@@ -9,18 +9,17 @@ TODO:
- If SVGAlib does not support 512x384x256, allow the user to pan around
- If SVGAlib does not support 512x384x256, allow the user to pan around
with the keypad arrow keys.
with the keypad arrow keys.
* Finish moving all 2D code to SoftDraw.c
* Finish moving all 2D code to SoftDraw.c
* Compile with -Wall -ansi -pedantic (shouldn't be much in the way)
BUGS:
BUGS:
* Drawing seems like its imprecise, stationary sprites move back and forth,
* Drawing seems like its imprecise, stationary sprites move back and forth,
and walls 'swim' when you move around, or sprites pop into different sizes
and walls 'swim' when you move around, or sprites pop into different sizes
when are far enough and get closer/farther away
when are far enough and get closer/farther away
- Possibly caused by 8.8
fixed
?
- Possibly caused by 8.8
imprecision
?
* it crashes somewhere, no reason why...
* it crashes somewhere, no reason why...
#0 0x804fa55 in DrawXMShape (x=128, y=96, ShapePtr=0x8c8c8c8c) at
#0 0x804fa55 in DrawXMShape (x=128, y=96, ShapePtr=0x8c8c8c8c) at
Burger.c:198
Burger.c:198
But what is trashing GameShapes's memory?
But what is trashing GameShapes's memory?
I don't think GameShapes itself is being ran over, just the memory allocated
to it...
* added an 'and' hack to lines 33 and 50 in RefBsp.c Not sure if this causes
* added an 'and' hack to lines 33 and 50 in RefBsp.c Not sure if this causes
any problems (value was overflowing finetangent...)
any problems (value was overflowing finetangent...)
...
...
macsrc/vi_glx.c
View file @
33d9dccc
...
@@ -19,9 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
...
@@ -19,9 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
*/
/*
/*
This is NOT the OpenGL version!
This is a NON-WORKING OpenGL version!
This is a COPY of vi_xlib.c as a placeholder!
A WORKING version will be ready once I write it!
(with minor changes)
*/
*/
#include <stdio.h>
#include <stdio.h>
...
@@ -42,14 +41,13 @@ Display *dpy;
...
@@ -42,14 +41,13 @@ Display *dpy;
int
screen
;
int
screen
;
Window
win
,
root
;
Window
win
,
root
;
XVisualInfo
*
vi
;
XVisualInfo
*
vi
;
GC
gc
;
GLXContext
ctx
;
XImage
*
img
;
Colormap
cmap
;
Atom
wmDeleteWindow
;
Atom
wmDeleteWindow
;
XColor
clr
[
256
];
XColor
clr
[
256
];
Byte
*
gfxbuf
;
Byte
*
gfxbuf
;
Byte
Pal
[
768
];
int
attrib
[]
=
{
int
attrib
[]
=
{
GLX_RGBA
,
GLX_RGBA
,
...
@@ -64,15 +62,14 @@ int attrib[] = {
...
@@ -64,15 +62,14 @@ int attrib[] = {
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
{
{
XSetWindowAttributes
attr
;
XSetWindowAttributes
attr
;
XVisualInfo
vitemp
;
Colormap
cmap
;
XGCValues
gcvalues
;
Pixmap
bitmap
;
Pixmap
bitmap
;
Cursor
cursor
;
Cursor
cursor
;
XColor
bg
=
{
0
};
XColor
bg
=
{
0
};
XColor
fg
=
{
0
};
XColor
fg
=
{
0
};
char
data
[
8
]
=
{
0x01
};
char
data
[
8
]
=
{
0x01
};
char
*
display
;
char
*
display
;
int
mask
,
i
;
int
mask
,
i
,
major
,
minor
,
verbose
=
0
;
if
(
argc
!=
2
)
{
if
(
argc
!=
2
)
{
fprintf
(
stderr
,
"usage: %s <mac wolf3d resource fork>
\n
"
,
argv
[
0
]);
fprintf
(
stderr
,
"usage: %s <mac wolf3d resource fork>
\n
"
,
argv
[
0
]);
...
@@ -95,23 +92,41 @@ int main(int argc, char *argv[])
...
@@ -95,23 +92,41 @@ int main(int argc, char *argv[])
root
=
RootWindow
(
dpy
,
screen
);
root
=
RootWindow
(
dpy
,
screen
);
vitemp
.
screen
=
screen
;
if
(
glXQueryExtension
(
dpy
,
NULL
,
NULL
)
==
False
)
{
vitemp
.
depth
=
8
;
fprintf
(
stderr
,
"Display %s does not support the GLX Extension
\n
"
,
XDisplayName
(
display
));
vitemp
.
class
=
PseudoColor
;
exit
(
EXIT_FAILURE
);
mask
=
VisualScreenMask
|
VisualDepthMask
|
VisualClassMask
;
}
vi
=
XGetVisualInfo
(
dpy
,
mask
,
&
vitemp
,
&
i
);
if
(
!
(
vi
&&
i
)
)
{
if
(
glXQueryVersion
(
dpy
,
&
major
,
&
minor
)
==
False
)
{
fprintf
(
stderr
,
"
Unable to get a depth 8 PseudoColor visual on screen %d
\n
"
,
screen
);
fprintf
(
stderr
,
"
glXQueryVersion returned False?
\n
"
);
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
else
if
(
verbose
)
{
printf
(
"GLX Version %d.%d
\n
"
,
major
,
minor
);
printf
(
"GLX Client:
\n
"
);
printf
(
"GLX_VENDOR: %s
\n
"
,
glXGetClientString
(
dpy
,
GLX_VENDOR
));
printf
(
"GLX_VERSION: %s
\n
"
,
glXGetClientString
(
dpy
,
GLX_VERSION
));
printf
(
"GLX_EXTENSIONS: %s
\n
"
,
glXGetClientString
(
dpy
,
GLX_EXTENSIONS
));
printf
(
"GLX Server:
\n
"
);
printf
(
"GLX_VENDOR: %s
\n
"
,
glXQueryServerString
(
dpy
,
screen
,
GLX_VENDOR
));
printf
(
"GLX_VERSION: %s
\n
"
,
glXQueryServerString
(
dpy
,
screen
,
GLX_VERSION
));
printf
(
"GLX_EXTENSIONS: %s
\n
"
,
glXQueryServerString
(
dpy
,
screen
,
GLX_EXTENSIONS
));
printf
(
"Both:
\n
"
);
printf
(
"GLX_EXTENSIONS: %s
\n
"
,
glXQueryExtensionsString
(
dpy
,
screen
));
}
}
cmap
=
XCreateColormap
(
dpy
,
root
,
vi
->
visual
,
AllocAll
);
vi
=
glXChooseVisual
(
dpy
,
screen
,
attrib
);
for
(
i
=
0
;
i
<
256
;
i
++
)
{
if
(
vi
==
NULL
)
{
clr
[
i
].
pixel
=
i
;
fprintf
(
stderr
,
"No usable GL visual found on %s:%d
\n
"
,
XDisplayName
(
display
),
screen
)
;
clr
[
i
].
flags
=
DoRed
|
DoGreen
|
DoBlue
;
exit
(
EXIT_FAILURE
)
;
}
}
ctx
=
glXCreateContext
(
dpy
,
vi
,
NULL
,
True
);
if
(
ctx
==
NULL
)
{
fprintf
(
stderr
,
"glx context create failed
\n
"
);
exit
(
EXIT_FAILURE
);
}
cmap
=
XCreateColormap
(
dpy
,
root
,
vi
->
visual
,
AllocNone
);
attr
.
colormap
=
cmap
;
attr
.
colormap
=
cmap
;
attr
.
event_mask
=
KeyPressMask
|
KeyReleaseMask
|
ExposureMask
;
attr
.
event_mask
=
KeyPressMask
|
KeyReleaseMask
|
ExposureMask
;
...
@@ -125,12 +140,6 @@ int main(int argc, char *argv[])
...
@@ -125,12 +140,6 @@ int main(int argc, char *argv[])
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
gcvalues
.
foreground
=
BlackPixel
(
dpy
,
screen
);
gcvalues
.
background
=
WhitePixel
(
dpy
,
screen
);
mask
=
GCForeground
|
GCBackground
;
gc
=
XCreateGC
(
dpy
,
win
,
mask
,
&
gcvalues
);
XSetWMProperties
(
dpy
,
win
,
NULL
,
NULL
,
argv
,
argc
,
None
,
None
,
None
);
XSetWMProperties
(
dpy
,
win
,
NULL
,
NULL
,
argv
,
argc
,
None
,
None
,
None
);
XStoreName
(
dpy
,
win
,
"Wolfenstein 3D"
);
XStoreName
(
dpy
,
win
,
"Wolfenstein 3D"
);
...
@@ -143,6 +152,16 @@ int main(int argc, char *argv[])
...
@@ -143,6 +152,16 @@ 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
);
glXMakeCurrent
(
dpy
,
win
,
ctx
);
if
(
verbose
)
{
printf
(
"GL Library:
\n
"
);
printf
(
"GL_VENDOR: %s
\n
"
,
glGetString
(
GL_VENDOR
));
printf
(
"GL_RENDERER: %s
\n
"
,
glGetString
(
GL_RENDERER
));
printf
(
"GL_VERSION: %s
\n
"
,
glGetString
(
GL_VERSION
));
printf
(
"GL_EXTENSIONS: %s
\n
"
,
glGetString
(
GL_EXTENSIONS
));
}
XMapWindow
(
dpy
,
win
);
XMapWindow
(
dpy
,
win
);
XFlush
(
dpy
);
XFlush
(
dpy
);
...
@@ -161,8 +180,7 @@ void Quit(char *str)
...
@@ -161,8 +180,7 @@ void Quit(char *str)
{
{
FreeResources
();
FreeResources
();
if
(
img
)
glXDestroyContext
(
dpy
,
ctx
);
XDestroyImage
(
img
);
if
(
str
&&
*
str
)
{
if
(
str
&&
*
str
)
{
fprintf
(
stderr
,
"%s
\n
"
,
str
);
fprintf
(
stderr
,
"%s
\n
"
,
str
);
...
@@ -174,14 +192,7 @@ void Quit(char *str)
...
@@ -174,14 +192,7 @@ void Quit(char *str)
void
SetPalette
(
Byte
*
pal
)
void
SetPalette
(
Byte
*
pal
)
{
{
int
i
;
memcpy
(
Pal
,
pal
,
768
);
for
(
i
=
0
;
i
<
256
;
i
++
)
{
clr
[
i
].
red
=
pal
[
i
*
3
+
0
]
<<
8
;
clr
[
i
].
green
=
pal
[
i
*
3
+
1
]
<<
8
;
clr
[
i
].
blue
=
pal
[
i
*
3
+
2
]
<<
8
;
}
XStoreColors
(
dpy
,
cmap
,
clr
,
256
);
}
}
void
BlastScreen2
(
Rect
*
BlastRect
)
void
BlastScreen2
(
Rect
*
BlastRect
)
...
@@ -196,7 +207,18 @@ int VidWidth, VidHeight, ViewHeight;
...
@@ -196,7 +207,18 @@ int VidWidth, VidHeight, ViewHeight;
void
BlastScreen
()
void
BlastScreen
()
{
{
XPutImage
(
dpy
,
win
,
gc
,
img
,
0
,
0
,
0
,
0
,
w
,
h
);
GLint
error
;
glXSwapBuffers
(
dpy
,
win
);
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
);
}
}
}
Word
VidXs
[]
=
{
320
,
512
,
640
,
640
};
/* Screen sizes to play with */
Word
VidXs
[]
=
{
320
,
512
,
640
,
640
};
/* Screen sizes to play with */
...
@@ -228,27 +250,15 @@ Word NewGameWindow(Word NewVidSize)
...
@@ -228,27 +250,15 @@ Word NewGameWindow(Word NewVidSize)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
img
)
{
XDestroyImage
(
img
);
/* free(gfxbuf); */
}
sizehints
.
min_width
=
sizehints
.
max_width
=
sizehints
.
base_width
=
w
;
sizehints
.
min_width
=
sizehints
.
max_width
=
sizehints
.
base_width
=
w
;
sizehints
.
min_height
=
sizehints
.
max_height
=
sizehints
.
base_height
=
h
;
sizehints
.
min_height
=
sizehints
.
max_height
=
sizehints
.
base_height
=
h
;
sizehints
.
flags
=
PMinSize
|
PMaxSize
|
PBaseSize
;
sizehints
.
flags
=
PMinSize
|
PMaxSize
|
PBaseSize
;
XSetWMNormalHints
(
dpy
,
win
,
&
sizehints
);
XSetWMNormalHints
(
dpy
,
win
,
&
sizehints
);
XResizeWindow
(
dpy
,
win
,
w
,
h
);
XResizeWindow
(
dpy
,
win
,
w
,
h
);
glViewport
(
0
,
0
,
w
,
h
);
gfxbuf
=
(
Byte
*
)
malloc
(
w
*
h
);
gfxbuf
=
(
Byte
*
)
malloc
(
w
*
h
);
img
=
XCreateImage
(
dpy
,
vi
->
visual
,
vi
->
depth
,
ZPixmap
,
0
,
(
char
*
)
gfxbuf
,
w
,
h
,
8
,
w
);
if
(
img
==
NULL
)
{
fprintf
(
stderr
,
"XCreateImage returned NULL, Unable to create an XImage
\n
"
);
exit
(
EXIT_FAILURE
);
}
VideoPointer
=
gfxbuf
;
VideoPointer
=
gfxbuf
;
VideoWidth
=
w
;
VideoWidth
=
w
;
InitYTable
();
InitYTable
();
...
@@ -256,7 +266,7 @@ Word NewGameWindow(Word NewVidSize)
...
@@ -256,7 +266,7 @@ Word NewGameWindow(Word NewVidSize)
ClearTheScreen
(
BLACK
);
ClearTheScreen
(
BLACK
);
BlastScreen
();
BlastScreen
();
LongPtr
=
(
LongWord
*
)
LoadAResource
(
VidPics
[
NewVidSize
]);
LongPtr
=
(
LongWord
*
)
LoadAResource
(
VidPics
[
NewVidSize
]);
if
(
GameShapes
)
if
(
GameShapes
)
FreeSomeMem
(
GameShapes
);
FreeSomeMem
(
GameShapes
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment