Standard 3D init

This commit is contained in:
CTurt 2014-10-31 08:21:30 +00:00
parent 0125bc99d6
commit d97a43d8e8
3 changed files with 32 additions and 0 deletions

View File

@ -15,6 +15,8 @@ typedef struct {
vect3D up; vect3D up;
} DSGM_Camera; } DSGM_Camera;
void DSGM_InitStandard3D(void);
inline void DSGM_UseCamera(DSGM_Camera *camera); inline void DSGM_UseCamera(DSGM_Camera *camera);
inline u64 DSGM_Distance3D(s32 x1, s32 y1, s32 z1, s32 x2, s32 y2, s32 z2); inline u64 DSGM_Distance3D(s32 x1, s32 y1, s32 z1, s32 x2, s32 y2, s32 z2);

Binary file not shown.

View File

@ -1,5 +1,35 @@
#include "DSGM.h" #include "DSGM.h"
void DSGM_InitStandard3D(void) {
glInit();
glEnable(GL_BLEND);
glColor(RGB15(31, 31, 31));
glEnable(GL_ANTIALIAS);
glClearColor(0, 0, 0, 0);
glClearPolyID(63);
glClearDepth(0x7FFF);
// When 3D mode is not enabled, VRAM bank B is used for top screen sprites, bank G is unused
// When 3D mode is enabled, VRAM bank B is used for textures, and bank G is used for top screen sprites
// Since bank G is smaller, we will have less VRAM available for sprites on the top screen
glEnable(GL_TEXTURE_2D);
glViewport(0, 0, 255, 191);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(70, 256.0 / 192.0, 0.1, 512);
glMaterialf(GL_AMBIENT, RGB15(4, 4, 4));
glMaterialf(GL_DIFFUSE, RGB15(31, 31, 31));
glMaterialf(GL_SPECULAR, BIT(15) | RGB15(8, 8, 8));
glMaterialShinyness();
glMatrixMode(GL_POSITION);
glLoadIdentity();
}
inline void DSGM_UseCamera(DSGM_Camera *camera) { inline void DSGM_UseCamera(DSGM_Camera *camera) {
//glLoadIdentity(); //glLoadIdentity();
gluLookAtf32(camera->position.x, camera->position.y, camera->position.z, camera->lookAt.x, camera->lookAt.y, camera->lookAt.z, camera->up.x, camera->up.y, camera->up.z); gluLookAtf32(camera->position.x, camera->position.y, camera->position.z, camera->lookAt.x, camera->lookAt.y, camera->lookAt.z, camera->up.x, camera->up.y, camera->up.z);