/*---------------------------------------------------------------------------*/
-static void game_draw_balls(const struct s_file *fp, const float *bill_M)
+static void game_draw_balls(const struct s_file *fp,
+ const float *bill_M, float t)
{
float c[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
fp->uv[0].r);
glColor4fv(c);
- ball_draw(ball_M, pend_M, bill_M);
+ ball_draw(ball_M, pend_M, bill_M, t);
}
glPopMatrix();
glPopAttrib();
}
-static void game_draw_items(const struct s_file *fp)
+static void game_draw_items(const struct s_file *fp, float t)
{
- float r = 360.f * SDL_GetTicks() / 1000.f;
+ float r = 360.f * t;
int hi;
glPushAttrib(GL_LIGHTING_BIT);
glPopAttrib();
}
-static void game_draw_goals(const struct s_file *fp, const float *M)
+static void game_draw_goals(const struct s_file *fp, const float *M, float t)
{
if (goal_c == 0)
{
fp->zv[zi].p[1],
fp->zv[zi].p[2]);
- part_draw_goal(M, fp->zv[zi].r, goal_k);
+ part_draw_goal(M, fp->zv[zi].r, goal_k, t);
}
glPopMatrix();
}
glLightfv(GL_LIGHT1, GL_SPECULAR, light_c[1]);
}
-static void game_draw_back(int pose, int d)
+static void game_draw_back(int pose, int d, float t)
{
- float t = SDL_GetTicks() / 1000.f + 120.0f;
-
glPushMatrix();
{
if (d < 0)
glClipPlane(GL_CLIP_PLANE2, pz);
}
-static void game_draw_fore(int pose, const float *M, int d)
+static void game_draw_fore(int pose, const float *M, int d, float t)
{
const float *ball_p = file.uv->p;
const float ball_r = file.uv->r;
{
/* Draw the coins. */
- game_draw_items(&file);
+ game_draw_items(&file, t);
/* Draw the floor. */
/* Draw the ball. */
- game_draw_balls(&file, M);
+ game_draw_balls(&file, M, t);
}
/* Draw the particles and light columns. */
{
glColor3f(1.0f, 1.0f, 1.0f);
- sol_bill(&file, M);
- part_draw_coin(M);
+ sol_bill(&file, M, t);
+ part_draw_coin(M, t);
glDisable(GL_TEXTURE_2D);
{
- game_draw_goals(&file, M);
+ game_draw_goals(&file, M, t);
game_draw_jumps(&file);
game_draw_swchs(&file);
}
glPopMatrix();
}
-void game_draw(int pose, float st)
+void game_draw(int pose, float t)
{
float fov = view_fov;
glScalef(+1.0f, -1.0f, +1.0f);
game_draw_light();
- game_draw_back(pose, -1);
- game_draw_fore(pose, U, -1);
+ game_draw_back(pose, -1, t);
+ game_draw_fore(pose, U, -1, t);
}
glPopMatrix();
glFrontFace(GL_CCW);
game_draw_light();
game_refl_all();
- game_draw_back(pose, +1);
- game_draw_fore(pose, T, +1);
+ game_draw_back(pose, +1, t);
+ game_draw_fore(pose, T, +1, t);
}
glPopMatrix();
config_pop_matrix();
for (u = 0; u < abs(uniform); ++u)
st_timer(DT);
+
+ t0 = t1;
}
else
{
/* Render. */
- st_paint();
+ st_paint(0.001f * t0);
config_swap();
if (uniform < 0)
gui_delete(id);
}
-static void conf_paint(int id, float st)
+static void conf_paint(int id, float t)
{
config_push_persp((float) config_get_d(CONFIG_VIEW_FOV), 0.1f, FAR_DIST);
{
return id;
}
-static void demo_play_paint(int id, float st)
+static void demo_play_paint(int id, float t)
{
- game_draw(0, st);
+ game_draw(0, t);
if (show_hud)
hud_paint();
return id;
}
-static void demo_end_paint(int id, float st)
+static void demo_end_paint(int id, float t)
{
- game_draw(0, st);
+ game_draw(0, t);
gui_paint(id);
if (demo_paused)
/*---------------------------------------------------------------------------*/
-struct state st_help_demo;
-
-/*---------------------------------------------------------------------------*/
-
#define HELP_BACK 0
#define HELP_RULE 1
#define HELP_CONT 2
demo_replay_stop(0);
}
-static void help_demo_paint(int id, float st)
+static void help_demo_paint(int id, float t)
{
- game_draw(0, st);
+ game_draw(0, t);
}
static void help_demo_timer(int id, float dt)
#include "state.h"
extern struct state st_help;
+extern struct state st_help_demo;
#endif
/*---------------------------------------------------------------------------*/
-static void poser_paint(int id, float st)
+static void poser_paint(int id, float t)
{
- game_draw(1, st);
+ game_draw(1, t);
}
static int poser_buttn(int c, int d)
gui_delete(id);
}
-static void name_paint(int id, float st)
+static void name_paint(int id, float t)
{
if (draw_back)
{
config_pop_matrix();
}
else
- game_draw(0, st);
+ game_draw(0, t);
gui_paint(id);
}
return id;
}
-static void pause_paint(int id, float st)
+static void pause_paint(int id, float t)
{
- shared_paint(id, st);
+ shared_paint(id, t);
hud_paint();
}
return id;
}
-static void play_loop_paint(int id, float st)
+static void play_loop_paint(int id, float t)
{
- game_draw(0, st);
+ game_draw(0, t);
if (show_hud)
hud_paint();
{
}
-static void look_paint(int id, float st)
+static void look_paint(int id, float t)
{
- game_draw(0, st);
+ game_draw(0, t);
}
static void look_point(int id, int x, int y, int dx, int dy)
gui_delete(id);
}
-void shared_paint(int id, float st)
+void shared_paint(int id, float t)
{
- game_draw(0, st);
+ game_draw(0, t);
gui_paint(id);
}
}
}
-static void game_draw_balls(const struct s_file *fp, const float *bill_M)
+static void game_draw_balls(const struct s_file *fp,
+ const float *bill_M, float t)
{
static const GLfloat color[5][4] = {
{ 1.0f, 1.0f, 1.0f, 0.7f },
fp->uv[ui].r);
glColor4fv(color[ui]);
- ball_draw(ball_M, pend_M, bill_M);
+ ball_draw(ball_M, pend_M, bill_M, t);
}
glPopMatrix();
}
/*---------------------------------------------------------------------------*/
-void game_draw(int pose)
+void game_draw(int pose, float t)
{
static const float a[4] = { 0.2f, 0.2f, 0.2f, 1.0f };
static const float s[4] = { 0.0f, 0.0f, 0.0f, 1.0f };
if (pose == 0)
{
- game_draw_balls(fp, T);
+ game_draw_balls(fp, T, t);
game_draw_vect(fp);
}
void game_init(const char *);
void game_free(void);
-void game_draw(int);
+void game_draw(int, float);
void game_putt(void);
int game_step(const float[3], float);
if ((t1 = SDL_GetTicks()) > t0)
{
st_timer((t1 - t0) / 1000.f);
- st_paint();
+ st_paint(0.001f * t1);
SDL_GL_SwapBuffers();
t0 = t1;
gui_delete(id);
}
-static void title_paint(int id, float st)
+static void title_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
gui_paint(id);
}
gui_delete(id);
}
-static void course_paint(int id, float st)
+static void course_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
gui_paint(id);
}
gui_delete(id);
}
-static void party_paint(int id, float st)
+static void party_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
gui_paint(id);
}
audio_music_fade_in(0.5f);
}
-static void pause_paint(int id, float st)
+static void pause_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
gui_paint(id);
hud_paint();
}
gui_delete(id);
}
-static void next_paint(int id, float st)
+static void next_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
hud_paint();
gui_paint(id);
}
return 0;
}
-static void poser_paint(int id, float st)
+static void poser_paint(int id, float t)
{
- game_draw(1);
+ game_draw(1, t);
}
static int poser_buttn(int b, int d)
hud_free();
}
-static void flyby_paint(int id, float st)
+static void flyby_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
hud_paint();
}
config_set_d(CONFIG_CAMERA, 0);
}
-static void stroke_paint(int id, float st)
+static void stroke_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
hud_paint();
}
hud_free();
}
-static void roll_paint(int id, float st)
+static void roll_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
hud_paint();
}
hud_free();
}
-static void goal_paint(int id, float st)
+static void goal_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
gui_paint(id);
hud_paint();
}
hud_free();
}
-static void stop_paint(int id, float st)
+static void stop_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
hud_paint();
}
else
{
hole_fall();
- game_draw(0); /*TODO: is this call ok? */
+/* game_draw(0);*/ /*TODO: is this call ok? */ /* No, it's not. */
}
hud_init();
hud_free();
}
-static void fall_paint(int id, float st)
+static void fall_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
gui_paint(id);
hud_paint();
}
gui_delete(id);
}
-static void score_paint(int id, float st)
+static void score_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
gui_paint(id);
}
gui_delete(id);
}
-static void over_paint(int id, float st)
+static void over_paint(int id, float t)
{
- game_draw(0);
+ game_draw(0, t);
gui_paint(id);
}
/*---------------------------------------------------------------------------*/
static void ball_draw_solid(const float *ball_M,
- const float *ball_bill_M)
+ const float *ball_bill_M, float t)
{
if (has_solid)
{
if (mask == 0) glDepthMask(GL_FALSE);
glDisable(GL_LIGHTING);
{
- sol_bill(&solid, ball_bill_M);
+ sol_bill(&solid, ball_bill_M, t);
}
glEnable(GL_LIGHTING);
if (mask == 0) glDepthMask(GL_TRUE);
static void ball_draw_inner(const float *pend_M,
const float *bill_M,
- const float *pend_bill_M)
+ const float *pend_bill_M, float t)
{
if (has_inner)
{
glDisable(GL_LIGHTING);
{
if (pend)
- sol_bill(&inner, pend_bill_M);
+ sol_bill(&inner, pend_bill_M, t);
else
- sol_bill(&inner, bill_M);
+ sol_bill(&inner, bill_M, t);
}
glEnable(GL_LIGHTING);
static void ball_draw_outer(const float *pend_M,
const float *bill_M,
- const float *pend_bill_M)
+ const float *pend_bill_M, float t)
{
if (has_outer)
{
glDisable(GL_LIGHTING);
{
if (pend)
- sol_bill(&outer, pend_bill_M);
+ sol_bill(&outer, pend_bill_M, t);
else
- sol_bill(&outer, bill_M);
+ sol_bill(&outer, bill_M, t);
}
glEnable(GL_LIGHTING);
if (mask == 0) glDepthMask(GL_TRUE);
const float *pend_M,
const float *bill_M,
const float *ball_bill_M,
- const float *pend_bill_M)
+ const float *pend_bill_M, float t)
{
/* Sort the inner ball using clip planes. */
if (inner_flags & F_DRAWCLIP)
{
glEnable(GL_CLIP_PLANE1);
- ball_draw_inner( pend_M, bill_M, pend_bill_M);
+ ball_draw_inner( pend_M, bill_M, pend_bill_M, t);
glDisable(GL_CLIP_PLANE1);
glEnable(GL_CLIP_PLANE2);
- ball_draw_inner( pend_M, bill_M, pend_bill_M);
+ ball_draw_inner( pend_M, bill_M, pend_bill_M, t);
glDisable(GL_CLIP_PLANE2);
}
else if (inner_flags & F_DRAWBACK)
{
glCullFace(GL_FRONT);
- ball_draw_inner( pend_M, bill_M, pend_bill_M);
+ ball_draw_inner( pend_M, bill_M, pend_bill_M, t);
glCullFace(GL_BACK);
- ball_draw_inner( pend_M, bill_M, pend_bill_M);
+ ball_draw_inner( pend_M, bill_M, pend_bill_M, t);
}
/* Draw the inner ball normally. */
else
{
- ball_draw_inner( pend_M, bill_M, pend_bill_M);
+ ball_draw_inner( pend_M, bill_M, pend_bill_M, t);
}
}
const float *pend_M,
const float *bill_M,
const float *ball_bill_M,
- const float *pend_bill_M)
+ const float *pend_bill_M, float t)
{
/* Sort the solid ball with the inner ball using clip planes. */
if (solid_flags & F_DRAWCLIP)
{
glEnable(GL_CLIP_PLANE1);
- ball_draw_solid(ball_M, ball_bill_M);
+ ball_draw_solid(ball_M, ball_bill_M, t);
glDisable(GL_CLIP_PLANE1);
- ball_pass_inner(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M);
+ ball_pass_inner(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t);
glEnable(GL_CLIP_PLANE2);
- ball_draw_solid(ball_M, ball_bill_M);
+ ball_draw_solid(ball_M, ball_bill_M, t);
glDisable(GL_CLIP_PLANE2);
}
else if (solid_flags & F_DRAWBACK)
{
glCullFace(GL_FRONT);
- ball_draw_solid(ball_M, ball_bill_M);
+ ball_draw_solid(ball_M, ball_bill_M, t);
glCullFace(GL_BACK);
- ball_pass_inner(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M);
- ball_draw_solid(ball_M, ball_bill_M);
+ ball_pass_inner(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t);
+ ball_draw_solid(ball_M, ball_bill_M, t);
}
/* Draw the solid ball after the inner ball. */
else
{
- ball_pass_inner(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M);
- ball_draw_solid(ball_M, ball_bill_M);
+ ball_pass_inner(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t);
+ ball_draw_solid(ball_M, ball_bill_M, t);
}
}
const float *pend_M,
const float *bill_M,
const float *ball_bill_M,
- const float *pend_bill_M)
+ const float *pend_bill_M, float t)
{
/* Sort the outer ball with the solid ball using clip planes. */
if (outer_flags & F_DRAWCLIP)
{
glEnable(GL_CLIP_PLANE1);
- ball_draw_outer( pend_M, bill_M, pend_bill_M);
+ ball_draw_outer( pend_M, bill_M, pend_bill_M, t);
glDisable(GL_CLIP_PLANE1);
- ball_pass_solid(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M);
+ ball_pass_solid(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t);
glEnable(GL_CLIP_PLANE2);
- ball_draw_outer( pend_M, bill_M, pend_bill_M);
+ ball_draw_outer( pend_M, bill_M, pend_bill_M, t);
glDisable(GL_CLIP_PLANE2);
}
else if (outer_flags & F_DRAWBACK)
{
glCullFace(GL_FRONT);
- ball_draw_outer( pend_M, bill_M, pend_bill_M);
+ ball_draw_outer( pend_M, bill_M, pend_bill_M, t);
glCullFace(GL_BACK);
- ball_pass_solid(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M);
- ball_draw_outer( pend_M, bill_M, pend_bill_M);
+ ball_pass_solid(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t);
+ ball_draw_outer( pend_M, bill_M, pend_bill_M, t);
}
/* Draw the outer ball after the solid ball. */
else
{
- ball_pass_solid(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M);
- ball_draw_outer( pend_M, bill_M, pend_bill_M);
+ ball_pass_solid(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t);
+ ball_draw_outer( pend_M, bill_M, pend_bill_M, t);
}
}
void ball_draw(const float *ball_M,
const float *pend_M,
- const float *bill_M)
+ const float *bill_M, float t)
{
/* Compute transforms for ball and pendulum billboards. */
/* Go to GREAT pains to ensure all layers are drawn back-to-front. */
- ball_pass_outer(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M);
+ ball_pass_outer(ball_M, pend_M, bill_M, ball_bill_M, pend_bill_M, t);
}
/*---------------------------------------------------------------------------*/
void ball_free(void);
void ball_draw(const float *,
const float *,
- const float *);
+ const float *, float);
/*---------------------------------------------------------------------------*/
/* Allocate or reallocate space for the buffer. */
- if ((store_new = realloc(store, store_size + buffer_size)))
+ if ((store_new = (char *) realloc(store, store_size + buffer_size)))
{
/* Avoid passing garbage to string functions. */
/* Allocate and initialize the row pointers. */
- if ((bytep = png_malloc(writep, h * sizeof (png_bytep))))
+ if ((bytep = (png_bytep *) png_malloc(writep, h * sizeof (png_bytep))))
{
for (i = 0; i < h; ++i)
bytep[h - i - 1] = (png_bytep) (p + i * w * 3);
glPopMatrix();
}
-void part_draw_coin(const float *M)
+void part_draw_coin(const float *M, float t)
{
- float r = (float) SDL_GetTicks() / 1000.0f;
int i;
glBindTexture(GL_TEXTURE_2D, part_text);
part_coin[i].c[2],
part_coin[i].t);
- part_draw(M, part_coin[i].p, 1.0f, r * part_coin[i].w);
+ part_draw(M, part_coin[i].p, 1.0f, t * part_coin[i].w);
}
}
-void part_draw_goal(const float *M, float radius, float a)
+void part_draw_goal(const float *M, float radius, float a, float t)
{
- float r = (float) SDL_GetTicks() / 1000.0f;
int i;
glBindTexture(GL_TEXTURE_2D, part_text);
for (i = 0; i < PART_MAX_GOAL; i++)
if (part_goal[i].t > 0.0f)
- part_draw(M, part_goal[i].p, radius - 0.05f, r * part_goal[i].w);
+ part_draw(M, part_goal[i].p, radius - 0.05f, t * part_goal[i].w);
}
/*---------------------------------------------------------------------------*/
void part_burst(const float *, const float *);
void part_step(const float *, float);
-void part_draw_coin(const float *);
-void part_draw_goal(const float *, float, float);
+void part_draw_coin(const float *, float);
+void part_draw_goal(const float *, float, float, float);
/*---------------------------------------------------------------------------*/
if (depthtest == 0) glEnable(GL_DEPTH_TEST);
}
-void sol_bill(const struct s_file *fp, const float *M)
+void sol_bill(const struct s_file *fp, const float *M, float t)
{
- float t = SDL_GetTicks() / 1000.f + 120.0f;
const struct s_mtrl *mp = &default_mtrl;
int ri;
void sol_back(const struct s_file *, float, float, float);
void sol_refl(const struct s_file *);
void sol_draw(const struct s_file *, int, int);
-void sol_bill(const struct s_file *, const float *);
+void sol_bill(const struct s_file *, const float *, float);
void sol_shad(const struct s_file *);
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
-void st_paint(void)
+void st_paint(float t)
{
- int stereo = config_get_d(CONFIG_STEREO);
+ int stereo = config_get_d(CONFIG_STEREO);
if (state && state->paint)
{
{
glDrawBuffer(GL_BACK_LEFT);
config_clear();
- state->paint(state->gui_id, (float) (+stereo));
+ state->paint(state->gui_id, t);
glDrawBuffer(GL_BACK_RIGHT);
config_clear();
- state->paint(state->gui_id, (float) (-stereo));
+ state->paint(state->gui_id, t);
}
else
{
config_clear();
- state->paint(state->gui_id, 0.0f);
+ state->paint(state->gui_id, t);
}
}
}
{
int (*enter)(void);
void (*leave)(int dt);
- void (*paint)(int id, float st);
+ void (*paint)(int id, float t);
void (*timer)(int id, float dt);
void (*point)(int id, int x, int y, int dx, int dy);
void (*stick)(int id, int a, int v);
void init_state(struct state *);
int goto_state(struct state *);
-void st_paint(void);
+void st_paint(float);
void st_timer(float);
void st_point(int, int, int, int);
void st_stick(int, int);