|
|
@@ -127,7 +127,6 @@ Render::Render()
|
|
127
|
127
|
#ifdef USING_EMITTER
|
|
128
|
128
|
mEmitter = 0x0;
|
|
129
|
129
|
#endif
|
|
130
|
|
- mCamera = 0x0;
|
|
131
|
130
|
mSkyMesh = -1;
|
|
132
|
131
|
mSkyMeshRotation = false;
|
|
133
|
132
|
mMode = Render::modeDisabled;
|
|
|
@@ -138,9 +137,6 @@ Render::Render()
|
|
138
|
137
|
|
|
139
|
138
|
mNextTextureId = NULL;
|
|
140
|
139
|
mNumTexturesLoaded = NULL;
|
|
141
|
|
-
|
|
142
|
|
- mWidth = 640;
|
|
143
|
|
- mHeight = 480;
|
|
144
|
140
|
}
|
|
145
|
141
|
|
|
146
|
142
|
|
|
|
@@ -156,7 +152,7 @@ Render::~Render()
|
|
156
|
152
|
|
|
157
|
153
|
void Render::screenShot(char *filenameBase)
|
|
158
|
154
|
{
|
|
159
|
|
- mTexture.glScreenShot(filenameBase, mWidth, mHeight);
|
|
|
155
|
+ mTexture.glScreenShot(filenameBase, gOpenRaider->mWindow->mWidth, gOpenRaider->mWindow->mHeight);
|
|
160
|
156
|
}
|
|
161
|
157
|
|
|
162
|
158
|
|
|
|
@@ -213,7 +209,7 @@ void Render::initTextures(char *textureDir, unsigned int *numLoaded,
|
|
213
|
209
|
++numTextures;
|
|
214
|
210
|
}
|
|
215
|
211
|
|
|
216
|
|
- snprintf(filename, 126, "%s%s", textureDir, "splash.tga");
|
|
|
212
|
+ snprintf(filename, 126, "%s/%s", textureDir, "splash.tga");
|
|
217
|
213
|
filename[127] = 0;
|
|
218
|
214
|
|
|
219
|
215
|
if ((bg_id = mTexture.loadTGA(filename)) > -1)
|
|
|
@@ -221,7 +217,7 @@ void Render::initTextures(char *textureDir, unsigned int *numLoaded,
|
|
221
|
217
|
++numTextures;
|
|
222
|
218
|
}
|
|
223
|
219
|
|
|
224
|
|
- snprintf(filename, 126, "%s%s", textureDir, "snow.tga");
|
|
|
220
|
+ snprintf(filename, 126, "%s/%s", textureDir, "snow.tga");
|
|
225
|
221
|
filename[127] = 0;
|
|
226
|
222
|
|
|
227
|
223
|
if ((snow1_id = mTexture.loadTGA(filename)) > -1)
|
|
|
@@ -229,7 +225,7 @@ void Render::initTextures(char *textureDir, unsigned int *numLoaded,
|
|
229
|
225
|
++numTextures;
|
|
230
|
226
|
}
|
|
231
|
227
|
|
|
232
|
|
- snprintf(filename, 126, "%s%s", textureDir, "snow2.tga");
|
|
|
228
|
+ snprintf(filename, 126, "%s/%s", textureDir, "snow2.tga");
|
|
233
|
229
|
filename[127] = 0;
|
|
234
|
230
|
|
|
235
|
231
|
if ((snow2_id = mTexture.loadTGA(filename)) > -1)
|
|
|
@@ -348,109 +344,6 @@ void renderTrace(int color, vec3_t start, vec3_t end)
|
|
348
|
344
|
}
|
|
349
|
345
|
|
|
350
|
346
|
|
|
351
|
|
-void Render::Init(int width, int height)
|
|
352
|
|
-{
|
|
353
|
|
- char *s;
|
|
354
|
|
-
|
|
355
|
|
- mWidth = width;
|
|
356
|
|
- mHeight = height;
|
|
357
|
|
-
|
|
358
|
|
- // Print driver support information
|
|
359
|
|
- printf("GL Vendor : %s\n", glGetString(GL_VENDOR));
|
|
360
|
|
- printf("GL Renderer : %s\n", glGetString(GL_RENDERER));
|
|
361
|
|
- printf("GL Version : %s\n", glGetString(GL_VERSION));
|
|
362
|
|
- //printf("Extensions : %s\n\n\n", (char*)glGetString(GL_EXTENSIONS));
|
|
363
|
|
-
|
|
364
|
|
- // Testing for goodies
|
|
365
|
|
- // Mongoose 2001.12.31, Fixed string use to check for bad strings
|
|
366
|
|
- s = (char*)glGetString(GL_EXTENSIONS);
|
|
367
|
|
-
|
|
368
|
|
- if (s && s[0])
|
|
369
|
|
- {
|
|
370
|
|
- //printf("\tGL_ARB_multitexture \t\t");
|
|
371
|
|
-
|
|
372
|
|
- if (strstr(s, "GL_ARB_multitexture"))
|
|
373
|
|
- {
|
|
374
|
|
- mFlags |= Render::fMultiTexture;
|
|
375
|
|
- //printf("YES\n");
|
|
376
|
|
- }
|
|
377
|
|
- /*
|
|
378
|
|
- else
|
|
379
|
|
- {
|
|
380
|
|
- printf("NO\n");
|
|
381
|
|
- }
|
|
382
|
|
-
|
|
383
|
|
- printf("\tGL_EXT_texture_env_combine\t\t");
|
|
384
|
|
-
|
|
385
|
|
- if (strstr(s, "GL_EXT_texture_env_combine"))
|
|
386
|
|
- {
|
|
387
|
|
- printf("YES\n");
|
|
388
|
|
- }
|
|
389
|
|
- else
|
|
390
|
|
- {
|
|
391
|
|
- printf("NO\n");
|
|
392
|
|
- }
|
|
393
|
|
- */
|
|
394
|
|
- }
|
|
395
|
|
-
|
|
396
|
|
- // Set up Z buffer
|
|
397
|
|
- glEnable(GL_DEPTH_TEST);
|
|
398
|
|
- glDepthFunc(GL_LESS);
|
|
399
|
|
-
|
|
400
|
|
- // Set up culling
|
|
401
|
|
- glEnable(GL_CULL_FACE);
|
|
402
|
|
- glFrontFace(GL_CW);
|
|
403
|
|
- //glFrontFace(GL_CCW);
|
|
404
|
|
- //glCullFace(GL_FRONT);
|
|
405
|
|
-
|
|
406
|
|
- // Set background to black
|
|
407
|
|
- glClearColor(BLACK[0], BLACK[1], BLACK[2], BLACK[3]);
|
|
408
|
|
-
|
|
409
|
|
- // Disable lighting
|
|
410
|
|
- glDisable(GL_LIGHTING);
|
|
411
|
|
-
|
|
412
|
|
- // Set up alpha blending
|
|
413
|
|
- glEnable(GL_BLEND);
|
|
414
|
|
- glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
|
415
|
|
-
|
|
416
|
|
- //glEnable(GL_ALPHA_TEST); // Disable per pixel alpha blending
|
|
417
|
|
- glAlphaFunc(GL_GREATER, 0);
|
|
418
|
|
-
|
|
419
|
|
- glPointSize(5.0);
|
|
420
|
|
-
|
|
421
|
|
- // Setup shading
|
|
422
|
|
- glShadeModel(GL_SMOOTH);
|
|
423
|
|
-
|
|
424
|
|
- glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
|
|
425
|
|
- glHint(GL_FOG_HINT, GL_NICEST);
|
|
426
|
|
- glEnable(GL_COLOR_MATERIAL);
|
|
427
|
|
- glEnable(GL_DITHER);
|
|
428
|
|
-
|
|
429
|
|
- // AA polygon edges
|
|
430
|
|
- glEnable(GL_POLYGON_SMOOTH);
|
|
431
|
|
- glHint(GL_POLYGON_SMOOTH_HINT, GL_NICEST);
|
|
432
|
|
-
|
|
433
|
|
- glDisable(GL_LINE_SMOOTH);
|
|
434
|
|
- glDisable(GL_POINT_SMOOTH);
|
|
435
|
|
- glDisable(GL_AUTO_NORMAL);
|
|
436
|
|
- glDisable(GL_LOGIC_OP);
|
|
437
|
|
- glDisable(GL_TEXTURE_1D);
|
|
438
|
|
- glDisable(GL_STENCIL_TEST);
|
|
439
|
|
- glDisable(GL_FOG);
|
|
440
|
|
-
|
|
441
|
|
- glDisable(GL_NORMALIZE);
|
|
442
|
|
-
|
|
443
|
|
- glEnableClientState(GL_VERTEX_ARRAY);
|
|
444
|
|
- glDisableClientState(GL_EDGE_FLAG_ARRAY);
|
|
445
|
|
- glDisableClientState(GL_COLOR_ARRAY);
|
|
446
|
|
- glDisableClientState(GL_NORMAL_ARRAY);
|
|
447
|
|
-
|
|
448
|
|
- glPolygonMode(GL_FRONT, GL_FILL);
|
|
449
|
|
-
|
|
450
|
|
- glMatrixMode(GL_MODELVIEW);
|
|
451
|
|
-}
|
|
452
|
|
-
|
|
453
|
|
-
|
|
454
|
347
|
void setLighting(bool on)
|
|
455
|
348
|
{
|
|
456
|
349
|
if (on)
|
|
|
@@ -548,13 +441,6 @@ void Render::setFlags(unsigned int flags)
|
|
548
|
441
|
}
|
|
549
|
442
|
|
|
550
|
443
|
|
|
551
|
|
-void Render::Update(int width, int height)
|
|
552
|
|
-{
|
|
553
|
|
- mWidth = width;
|
|
554
|
|
- mHeight = height;
|
|
555
|
|
-}
|
|
556
|
|
-
|
|
557
|
|
-
|
|
558
|
444
|
int Render::getMode()
|
|
559
|
445
|
{
|
|
560
|
446
|
return mMode;
|
|
|
@@ -638,13 +524,6 @@ void Render::Display()
|
|
638
|
524
|
gl_test_reset();
|
|
639
|
525
|
#endif
|
|
640
|
526
|
|
|
641
|
|
- // Assertion: Rendering is disabled without texture or camera
|
|
642
|
|
- if (!mCamera)
|
|
643
|
|
- {
|
|
644
|
|
- fprintf(stderr, "Render::Display> ERROR: No camera is registered\n");
|
|
645
|
|
- return;
|
|
646
|
|
- }
|
|
647
|
|
-
|
|
648
|
527
|
switch (mMode)
|
|
649
|
528
|
{
|
|
650
|
529
|
case Render::modeDisabled:
|
|
|
@@ -705,16 +584,16 @@ void Render::Display()
|
|
705
|
584
|
camPos[2] = curPos[2] + (64.0f * cosf(yaw));
|
|
706
|
585
|
}
|
|
707
|
586
|
|
|
708
|
|
- mCamera->setPosition(camPos);
|
|
|
587
|
+ gOpenRaider->mGame->mCamera->setPosition(camPos);
|
|
709
|
588
|
}
|
|
710
|
589
|
|
|
711
|
590
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
712
|
591
|
glLoadIdentity();
|
|
713
|
592
|
|
|
714
|
593
|
// Setup view in OpenGL with camera
|
|
715
|
|
- mCamera->update();
|
|
716
|
|
- mCamera->getPosition(camPos);
|
|
717
|
|
- mCamera->getTarget(atPos);
|
|
|
594
|
+ gOpenRaider->mGame->mCamera->update();
|
|
|
595
|
+ gOpenRaider->mGame->mCamera->getPosition(camPos);
|
|
|
596
|
+ gOpenRaider->mGame->mCamera->getTarget(atPos);
|
|
718
|
597
|
// Mongoose 2002.08.13, Quick fix to render OpenRaider upside down
|
|
719
|
598
|
// gluLookAt(camPos[0], camPos[1], camPos[2], atPos[0], atPos[1], atPos[2], 0.0, -1.0, 0.0);
|
|
720
|
599
|
|
|
|
@@ -1107,13 +986,13 @@ void Render::drawObjects()
|
|
1107
|
986
|
glPushMatrix();
|
|
1108
|
987
|
|
|
1109
|
988
|
#ifdef USING_FPS_CAMERA
|
|
1110
|
|
- mCamera->getPosition(curPos);
|
|
|
989
|
+ gOpenRaider->mGame->mCamera->getPosition(curPos);
|
|
1111
|
990
|
glTranslated(curPos[0], curPos[1], curPos[2]);
|
|
1112
|
|
- glRotated(mCamera->getYaw(), 0, 1, 0);
|
|
|
991
|
+ glRotated(gOpenRaider->mGame->mCamera->getYaw(), 0, 1, 0);
|
|
1113
|
992
|
glTranslated(0, 500, 1200);
|
|
1114
|
993
|
#else
|
|
1115
|
994
|
glTranslated(LARA->pos[0], LARA->pos[1], LARA->pos[2]);
|
|
1116
|
|
- glRotated(mCamera->getYaw(), 0, 1, 0);
|
|
|
995
|
+ glRotated(gOpenRaider->mGame->mCamera->getYaw(), 0, 1, 0);
|
|
1117
|
996
|
#endif
|
|
1118
|
997
|
|
|
1119
|
998
|
drawModel(static_cast<SkeletalModel *>(LARA->tmpHook));
|
|
|
@@ -1638,7 +1517,7 @@ void Render::drawSprite(sprite_t *sprite)
|
|
1638
|
1517
|
glTranslated(sprite->pos[0], sprite->pos[1], sprite->pos[2]);
|
|
1639
|
1518
|
|
|
1640
|
1519
|
// Sprites must always face camera, because they have no depth =)
|
|
1641
|
|
- glRotated(mCamera->getYaw(), 0, 1, 0);
|
|
|
1520
|
+ glRotated(gOpenRaider->mGame->mCamera->getYaw(), 0, 1, 0);
|
|
1642
|
1521
|
|
|
1643
|
1522
|
switch (mMode)
|
|
1644
|
1523
|
{
|
|
|
@@ -1956,15 +1835,6 @@ void Render::ViewModel(entity_t *ent, int index)
|
|
1956
|
1835
|
}
|
|
1957
|
1836
|
|
|
1958
|
1837
|
|
|
1959
|
|
-void Render::RegisterCamera(Camera *camera)
|
|
1960
|
|
-{
|
|
1961
|
|
- if (camera)
|
|
1962
|
|
- {
|
|
1963
|
|
- mCamera = camera;
|
|
1964
|
|
- }
|
|
1965
|
|
-}
|
|
1966
|
|
-
|
|
1967
|
|
-
|
|
1968
|
1838
|
void Render::addSkeletalModel(SkeletalModel *mdl)
|
|
1969
|
1839
|
{
|
|
1970
|
1840
|
mModels.push_back(mdl);
|