Merge branch 'refactor_nehe08' into 'master'
refactor nehe08 slightly See merge request simulant/GLdc!94
This commit is contained in:
commit
774a956012
|
@ -39,6 +39,9 @@ static GLfloat yrot; /* Y Rotation */
|
||||||
static GLfloat xspeed; /* X Rotation Speed */
|
static GLfloat xspeed; /* X Rotation Speed */
|
||||||
static GLfloat yspeed; /* Y Rotation Speed */
|
static GLfloat yspeed; /* Y Rotation Speed */
|
||||||
static GLfloat z = -5.0f; /* Depth Into The Screen */
|
static GLfloat z = -5.0f; /* Depth Into The Screen */
|
||||||
|
GLboolean xp = GL_FALSE;
|
||||||
|
GLboolean yp = GL_FALSE;
|
||||||
|
GLboolean blend = GL_FALSE;
|
||||||
|
|
||||||
static GLuint filter; /* Which Filter To Use */
|
static GLuint filter; /* Which Filter To Use */
|
||||||
static GLuint texture[2]; /* Storage For Two Textures */
|
static GLuint texture[2]; /* Storage For Two Textures */
|
||||||
|
@ -46,7 +49,40 @@ static GLuint texture[2]; /* Storage For Two Textures */
|
||||||
/* Load a PVR texture - located in pvr-texture.c */
|
/* Load a PVR texture - located in pvr-texture.c */
|
||||||
extern GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap);
|
extern GLuint glTextureLoadPVR(char *fname, unsigned char isMipMapped, unsigned char glMipMap);
|
||||||
|
|
||||||
void draw_gl(void) {
|
/* A general OpenGL initialization function. Sets all of the initial parameters. */
|
||||||
|
void InitGL(int Width, int Height) // We call this right after our OpenGL window is created.
|
||||||
|
{
|
||||||
|
glMatrixMode(GL_PROJECTION);
|
||||||
|
glLoadIdentity();
|
||||||
|
gluPerspective(45.0f, (GLfloat)Width/(GLfloat)Height, 0.1f, 100.0f);
|
||||||
|
glMatrixMode(GL_MODELVIEW);
|
||||||
|
glLoadIdentity();
|
||||||
|
|
||||||
|
glEnable(GL_TEXTURE_2D);
|
||||||
|
glShadeModel(GL_SMOOTH);
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
|
||||||
|
glClearDepth(1.0f);
|
||||||
|
glEnable(GL_DEPTH_TEST);
|
||||||
|
glDepthFunc(GL_LEQUAL);
|
||||||
|
|
||||||
|
glColor4f(1.0f, 1.0f, 1.0f, 0.5);
|
||||||
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
||||||
|
|
||||||
|
/* Enable Lighting and GL_LIGHT0 */
|
||||||
|
glEnable(GL_LIGHTING);
|
||||||
|
glEnable(GL_LIGHT0);
|
||||||
|
|
||||||
|
/* Set up the textures */
|
||||||
|
texture[0] = glTextureLoadPVR(IMG_PATH, 0, 0);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||||
|
|
||||||
|
texture[1] = glTextureLoadPVR(IMG_PATH, 0, 0);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DrawGLScene(void) {
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glTranslatef(0.0f, 0.0f, z);
|
glTranslatef(0.0f, 0.0f, z);
|
||||||
|
@ -121,66 +157,27 @@ void draw_gl(void) {
|
||||||
|
|
||||||
xrot += xspeed;
|
xrot += xspeed;
|
||||||
yrot += yspeed;
|
yrot += yspeed;
|
||||||
|
|
||||||
|
/* Finish the frame */
|
||||||
|
glKosSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int ReadController(void) {
|
||||||
#ifdef __DREAMCAST__
|
#ifdef __DREAMCAST__
|
||||||
maple_device_t *cont;
|
maple_device_t *cont;
|
||||||
cont_state_t *state;
|
cont_state_t *state;
|
||||||
#endif
|
|
||||||
|
|
||||||
GLboolean xp = GL_FALSE;
|
|
||||||
GLboolean yp = GL_FALSE;
|
|
||||||
GLboolean blend = GL_FALSE;
|
|
||||||
|
|
||||||
printf("nehe08 beginning\n");
|
|
||||||
|
|
||||||
/* Get basic stuff initialized */
|
|
||||||
glKosInit();
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
|
||||||
glLoadIdentity();
|
|
||||||
gluPerspective(45.0f, 640.0f / 480.0f, 0.1f, 100.0f);
|
|
||||||
glMatrixMode(GL_MODELVIEW);
|
|
||||||
glLoadIdentity();
|
|
||||||
|
|
||||||
glEnable(GL_TEXTURE_2D);
|
|
||||||
glShadeModel(GL_SMOOTH);
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 0.5f);
|
|
||||||
glClearDepth(1.0f);
|
|
||||||
glEnable(GL_DEPTH_TEST);
|
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
|
|
||||||
glColor4f(1.0f, 1.0f, 1.0f, 0.5);
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE);
|
|
||||||
|
|
||||||
/* Enable Lighting and GL_LIGHT0 */
|
|
||||||
glEnable(GL_LIGHTING);
|
|
||||||
glEnable(GL_LIGHT0);
|
|
||||||
|
|
||||||
/* Set up the textures */
|
|
||||||
texture[0] = glTextureLoadPVR(IMG_PATH, 0, 0);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
|
||||||
|
|
||||||
texture[1] = glTextureLoadPVR(IMG_PATH, 0, 0);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
|
|
||||||
while(1) {
|
|
||||||
#ifdef __DREAMCAST__
|
|
||||||
cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
|
cont = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
|
||||||
|
|
||||||
/* Check key status */
|
/* Check key status */
|
||||||
state = (cont_state_t *)maple_dev_status(cont);
|
state = (cont_state_t *)maple_dev_status(cont);
|
||||||
|
|
||||||
if(!state) {
|
if(!state) {
|
||||||
printf("Error reading controller\n");
|
printf("Error reading controller\n");
|
||||||
break;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state->buttons & CONT_START)
|
if(state->buttons & CONT_START)
|
||||||
break;
|
return 0;
|
||||||
|
|
||||||
if(state->buttons & CONT_A)
|
if(state->buttons & CONT_A)
|
||||||
z -= 0.02f;
|
z -= 0.02f;
|
||||||
|
@ -230,13 +227,23 @@ int main(int argc, char **argv) {
|
||||||
glDepthMask(1);
|
glDepthMask(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Draw the GL "scene" */
|
return 1;
|
||||||
draw_gl();
|
}
|
||||||
|
|
||||||
/* Finish the frame */
|
int main(int argc, char **argv) {
|
||||||
glKosSwapBuffers();
|
printf("nehe08 beginning\n");
|
||||||
|
|
||||||
|
/* Get basic stuff initialized */
|
||||||
|
glKosInit();
|
||||||
|
|
||||||
|
InitGL(640, 480);
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
if (!ReadController())
|
||||||
|
break;
|
||||||
|
|
||||||
|
DrawGLScene();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user