int draw_sonic_fade( int inout ) { float amount=(gg_system_get_ticks()-fade_start)/(SONIC_FADE_SPEED*1000); int i=0; gg_colour_t col_red={1.0f, 0.0f, 0.0f, 1.0f }; gg_colour_t col_blue={0.0f, 0.0f, 1.0f, 1.0f }; gg_colour_t col_yellow={1.0f, 1.0f, 0.0f, 1.0f }; gg_colour_t col_black={0.0f, 0.0f, 0.0f, 1.0f }; gg_colour_t col_white={1.0f, 1.0f, 1.0f, 1.0f }; if ( amount < 1.0f ) { if ( inout == FADE_IN ) amount=1.0f-amount; if ( amount < 0.7f ) amount=(amount)/0.7f; else if (amount >= 0.7f ) amount=1.0f; gg_system_draw_filled_rect(0, 480-(480*amount), 640, 480, &col_blue ); gg_system_draw_filled_rect(640-(640*amount), 0, 640, (480/3), &col_yellow ); text_draw_string( 640-(640*amount)+280, (480/3)-30, "DreamChess the chess game", 1.2f, &col_white); gg_system_draw_filled_rect(0, 0, (((640/3)+(480/14))*amount)-(480/14), 480, &col_red ); for ( i=0; i<14; i++ ) { draw_tri((((640/3)+(480/14))*amount)-(480/14)+2, i*(480/14)-2, (((640/3)+(480/14))*amount)-(480/14)+2, i*(480/14)+(480/14)-2, (((640/3)+(480/14))*amount)-(480/14)+(480/14)+2, i*(480/14)+((480/14)/2)-2, &col_black); draw_tri((((640/3)+(480/14))*amount)-(480/14), i*(480/14), (((640/3)+(480/14))*amount)-(480/14), i*(480/14)+(480/14), (((640/3)+(480/14))*amount)-(480/14)+(480/14), i*(480/14)+((480/14)/2), &col_red); } text_draw_string( 640-(640*amount*2)+840, 480-(480/3), "Chess Hill", 3.0f, &col_white); text_draw_string( (640*amount*2)-1000, 480-(480/3)-50, "Zone", 3.0f, &col_white); text_draw_string( (640*amount*2)-860, 480-(480/3)-60, "1", 4.0f, &col_yellow); } /*printf( "Drawing sonic fade.. :%i,%f\n", inout, amount );*/ if ( amount >= 1.0f ) { return FALSE; } return TRUE; }
static gboolean expose(GtkWidget* widget, GdkEventExpose* e, gpointer data) { struct program *p = (struct program *)data; GdkGLContext* context = gtk_widget_get_gl_context(widget); GdkGLDrawable* drawable = gtk_widget_get_gl_drawable(widget); (void)e; p->draw.width = widget->allocation.width; p->draw.height = widget->allocation.height; if (!gdk_gl_drawable_gl_begin(drawable, context)) return FALSE; if (p->viewed.type == TYPE_TEXTURE) texture_draw(p); else draw_tri(p); if (gdk_gl_drawable_is_double_buffered (drawable)) gdk_gl_drawable_swap_buffers(drawable); else glFlush(); gdk_gl_drawable_gl_end(drawable); return TRUE; }
void draw_tri(vec2 p0, vec2 p1, vec2 p2, colour col) { draw_tri(p0, p1, p2, col, col, col); }