[Tuxracer-checkins] CVS: tuxracer/src splash_screen.c,NONE,1.1 splash_screen.h,NONE,1.1
Status: Beta
Brought to you by:
jfpatry
From: Jasmin P. <jf...@us...> - 2000-09-11 04:22:55
|
Update of /cvsroot/tuxracer/tuxracer/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv8918 Added Files: splash_screen.c splash_screen.h Log Message: Initial checkin. --- NEW FILE --- /* * Tux Racer * Copyright (C) 1999-2000 Jasmin F. Patry * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "tuxracer.h" #include "audio.h" #include "keyboard.h" #include "gl_util.h" #include "fps.h" #include "loop.h" #include "render_util.h" #include "textures.h" #include "multiplayer.h" #define COORD_OFFSET_AMT -0.5 static const colour_t background_colour = { 0.48, 0.63, 0.90 }; static char *logo_bindings[4] = { "splash_screen_tl", "splash_screen_bl", "splash_screen_tr", "splash_screen_br" }; void splash_screen_init() { glutDisplayFunc( main_loop ); glutIdleFunc( NULL ); glutReshapeFunc( reshape ); glutMotionFunc( NULL ); glutPassiveMotionFunc( NULL ); play_music( "splash_screen" ); reshape( getparam_x_resolution(), getparam_y_resolution() ); } static void setup_perspective() { scalar_t offset = COORD_OFFSET_AMT; set_gl_options( SPLASH_SCREEN ); glMatrixMode( GL_PROJECTION ); glLoadIdentity(); glOrtho( offset, getparam_x_resolution() + offset, offset, getparam_y_resolution() + offset, -1.0, 1.0 ); glMatrixMode( GL_MODELVIEW ); glLoadIdentity(); } static void draw_background() { point2d_t ll, ur; scalar_t z = -1.0; ll.x = COORD_OFFSET_AMT; ll.y = COORD_OFFSET_AMT; ur.x = getparam_x_resolution() + COORD_OFFSET_AMT; ur.y = getparam_y_resolution() + COORD_OFFSET_AMT; glColor3f( background_colour.r, background_colour.g, background_colour.b ); glBegin( GL_QUADS ); { glVertex3f( ll.x, ll.y, z ); glVertex3f( ur.x, ll.y, z ); glVertex3f( ur.x, ur.y, z ); glVertex3f( ll.x, ur.y, z ); } glEnd(); } static void draw_logo() { GLuint texid[4]; int xoffsets[4] = { -1, -1, 0, 0 }; int yoffsets[4] = { 0, -1, 0, -1 }; point2d_t ll, ur; scalar_t z = -1.0; GLint w, h; int i; glEnable( GL_TEXTURE_2D ); for (i=0; i<4; i++) { if ( ! get_texture_binding( logo_bindings[i], &texid[i] ) ) { return; } } for (i=0; i<4; i++) { glBindTexture( GL_TEXTURE_2D, texid[i] ); glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &w ); glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &h ); ll.x = getparam_x_resolution()/2 + xoffsets[i]*w; ll.y = getparam_y_resolution()/2 + yoffsets[i]*h; ur.x = ll.x + w; ur.y = ll.y + h; glColor3f( 1.0, 1.0, 1.0 ); glBegin( GL_QUADS ); { glTexCoord2f( 0.0, 0.0 ); glVertex3f( ll.x, ll.y, z ); glTexCoord2f( 1.0, 0.0 ); glVertex3f( ur.x, ll.y, z ); glTexCoord2f( 1.0, 1.0 ); glVertex3f( ur.x, ur.y, z ); glTexCoord2f( 0.0, 1.0 ); glVertex3f( ll.x, ur.y, z ); } glEnd(); } } void splash_screen_loop( scalar_t time_step ) { check_gl_error(); update_audio(); clear_rendering_context(); /* Set up a orthogonal perspective matrix */ setup_perspective(); set_gl_options( SPLASH_SCREEN ); draw_background(); draw_logo(); reshape( getparam_x_resolution(), getparam_y_resolution() ); glutSwapBuffers(); } START_KEYBOARD_CB( splash_screen_cb ) { int i; g_game.mode = START; /* * Free textures */ for (i=0; i<sizeof(logo_bindings)/sizeof(logo_bindings[0]); i++) { unbind_texture( logo_bindings[i] ); } flush_textures(); glutPostRedisplay(); } END_KEYBOARD_CB void splash_screen_register() { int status = 0; status |= add_keymap_entry( SPLASH, DEFAULT_CALLBACK, NULL, NULL, splash_screen_cb ); check_assertion( status == 0, "out of keymap entries" ); register_loop_funcs( SPLASH, splash_screen_init, splash_screen_loop ); } --- NEW FILE --- /* * Tux Racer * Copyright (C) 1999-2000 Jasmin F. Patry * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifdef __cplusplus extern "C" { #endif #ifndef _SPLASH_SCREEN_H_ #define _SPLASH_SCREEN_H_ void splash_screen_init(); void splash_screen_loop( scalar_t time_step ); void splash_screen_register(); #endif #ifdef __cplusplus } /* extern "C" */ #endif |