Add settings to demo2
This commit is contained in:
parent
04b21153d5
commit
0cc8cbb2c5
1 changed files with 39 additions and 6 deletions
45
demo2.cpp
45
demo2.cpp
|
@ -1,8 +1,11 @@
|
||||||
/**
|
/**
|
||||||
Raycasting demo 2 for Pokitto.
|
Raycasting demo 2 for Pokitto.
|
||||||
|
|
||||||
This demo shows the simple version (only 1 intersection) of raycasting. Has
|
This demo shows a simple version (wolf3D-like) raycasting. It has a fairly
|
||||||
a fairly high FPS.
|
high FPS.
|
||||||
|
|
||||||
|
There is a number of compile-time settings you can try! Look at the defines
|
||||||
|
below.
|
||||||
|
|
||||||
Don't forget to compile with -O3!
|
Don't forget to compile with -O3!
|
||||||
|
|
||||||
|
@ -10,6 +13,31 @@
|
||||||
license: CC0 1.0
|
license: CC0 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
// settings:
|
||||||
|
|
||||||
|
//#define SUBSAMPLE 1
|
||||||
|
/* ^ Turns high resolution in X direction on, which means twice as many rays
|
||||||
|
that will be cast. The result looks beautiful but dramatically decreases
|
||||||
|
FPS. */
|
||||||
|
|
||||||
|
//#define RENDER_PRECISE
|
||||||
|
/* ^ Turns on rendering using a more precise but slower algorithm. This can
|
||||||
|
be seen at less shaky head bobbing when moving. */
|
||||||
|
|
||||||
|
//#define NO_TEXTURES
|
||||||
|
/* ^ Turns off textures and only uses colors, which increases FPS. */
|
||||||
|
|
||||||
|
//#define USE_DIST_APPROX 1
|
||||||
|
/* ^ Turns on distance approximation, which won't compute exact distances but
|
||||||
|
only approximations - this should increase performance a little, but
|
||||||
|
results in slightly distorted walls. */
|
||||||
|
|
||||||
|
//#define USE_COS_LUT 2
|
||||||
|
/* ^ Turns on cos look up tables (128 items, USE_COS_LUT 1 will use only 64
|
||||||
|
items), which should theoretically be faster, but will take additional
|
||||||
|
memory and turning can be less precise (can be seen a lot with 64 item
|
||||||
|
LUT). */
|
||||||
|
|
||||||
#define FPS 60
|
#define FPS 60
|
||||||
#define HEAD_BOB_HEIGHT 200
|
#define HEAD_BOB_HEIGHT 200
|
||||||
#define HEAD_BOB_STEP 20
|
#define HEAD_BOB_STEP 20
|
||||||
|
@ -781,9 +809,13 @@ inline void pixelFunc(PixelInfo *pixel)
|
||||||
{
|
{
|
||||||
Unit textureScroll = pixel->hit.type != 4 ? 0 : 16 * pokitto.frameCount;
|
Unit textureScroll = pixel->hit.type != 4 ? 0 : 16 * pokitto.frameCount;
|
||||||
|
|
||||||
|
#ifdef NO_TEXTURES
|
||||||
|
c = textureAverageColors[pixel->hit.type];
|
||||||
|
#else
|
||||||
c = pixel->depth < TEXTURE_MAX_DISTANCE ?
|
c = pixel->depth < TEXTURE_MAX_DISTANCE ?
|
||||||
sampleImage(textures[pixel->hit.type],pixel->hit.textureCoord + textureScroll,pixel->textureCoordY) :
|
sampleImage(textures[pixel->hit.type],pixel->hit.textureCoord + textureScroll,pixel->textureCoordY) :
|
||||||
textureAverageColors[pixel->hit.type];
|
textureAverageColors[pixel->hit.type];
|
||||||
|
#endif
|
||||||
|
|
||||||
if (previousColumn == pixel->position.x)
|
if (previousColumn == pixel->position.x)
|
||||||
{
|
{
|
||||||
|
@ -810,11 +842,12 @@ void draw()
|
||||||
c.computeTextureCoords = 1;
|
c.computeTextureCoords = 1;
|
||||||
|
|
||||||
player.mCamera.height += player.mHeadBob;
|
player.mCamera.height += player.mHeadBob;
|
||||||
renderSimple(player.mCamera,floorHeightAt,textureAt,pixelFunc,c);
|
|
||||||
|
|
||||||
/* this would achieve more or less the same (less shaky head bob),
|
#ifdef RENDER_PRECISE
|
||||||
for a cost of a few FPS: */
|
render(player.mCamera,floorHeightAt,0,textureAt,pixelFunc,c);
|
||||||
// render(player.mCamera,floorHeightAt,0,textureAt,pixelFunc,c);
|
#else
|
||||||
|
renderSimple(player.mCamera,floorHeightAt,textureAt,pixelFunc,c);
|
||||||
|
#endif
|
||||||
|
|
||||||
player.mCamera.height -= player.mHeadBob;
|
player.mCamera.height -= player.mHeadBob;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue