remove deprecated luminance texture generation
[voxelands-alt.git] / src / graphics / render.c
blobd7e182e72ab8fbb16753864fdb3333f72534faaa
1 /************************************************************************
2 * object.c
3 * voxelands - 3d voxel world sandbox game
4 * Copyright (C) Lisa 'darkrose' Milne 2016 <lisa@ltmnet.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>
18 ************************************************************************/
20 #include "common.h"
21 #include "graphics.h"
22 #include "ui.h"
24 static struct {
25 int ticks;
26 int tticks;
27 int tpf;
28 int fticks;
29 int font_init;
30 float dtime;
31 } render_data = {
37 0.1
40 /* get client-side frame time */
41 float client_dtime()
43 return render_data.dtime;
46 /* clear the frame */
47 void render_pre()
49 if (!render_data.ticks)
50 render_data.ticks = time_ticks();
51 render_data.tpf = 1000/wm_data.frame_cap;
52 events_main();
55 /* render to frame */
56 void render_post()
58 ui_render();
60 if (wm_data.cursor.mat) {
61 int mouse[2];
62 events_get_mouse(mouse);
63 render2d_quad_mat(wm_data.cursor.mat,mouse[0]+wm_data.cursor.x,mouse[1]+wm_data.cursor.y,wm_data.cursor.w,wm_data.cursor.h);
66 /* should get this from sky when in-game */
67 glClearColor(0, 0, 0, 1.0);
68 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
70 render3d();
72 render2d();
74 wm_update();
76 /* calculate a scale factor for smooth animations */
77 render_data.tticks = interval_delay(render_data.ticks,wm_data.frame_cap);
78 wm_data.fps = calc_fps(render_data.ticks,render_data.tticks);
79 render_data.dtime = time_dtime(render_data.ticks);
80 render_data.ticks = render_data.tticks;