font rendering... mostly
[voxelands-alt.git] / src / client / main.c
blobcd2b8b5987d1fba840bf9c1304470dd2a1da3f66
1 /************************************************************************
2 * main.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 "path.h"
22 #include "net.h"
23 #include "content.h"
24 #define _WM_EXPOSE_ALL
25 #include "wm.h"
26 #include "graphics.h"
28 static int state_client = VLSTATE_PLAY;
30 /* get/set the client state */
31 int client_state(int s)
33 int r = state_client;
34 if (s != VLSTATE_GET)
35 state_client = s;
36 return r;
39 int main(int argc, char** argv)
41 material_t *logo;
42 material_t *steel;
43 material_t *mud;
44 object_t *block1;
45 object_t *block2;
46 v3_t p;
47 float r;
48 textbuffer_t tb;
49 textbuffer_t tb2;
50 font_t *f;
51 int i;
52 char buff[256];
54 command_init();
55 path_init();
56 config_init(argc,argv);
57 events_init();
58 time_init();
59 intl_init();
60 sys_console_init();
61 net_init();
62 content_init();
64 wm_init();
65 wm_title(PACKAGE " - " VERSION);
67 font_load("font.ttf","default");
69 f = font_find("default");
71 textbuffer_init(&tb,f,14,20,20,0,0,0,0);
72 textbuffer_init(&tb2,f,14,20,40,0,0,0,0);
73 i = textbuffer_addstr(&tb,"Hello world! - ößäндгя ygj");
75 vlprintf("hello world %d",i);
77 logo = mat_from_image("texture","menulogo.png");
78 steel = mat_from_image("texture","steel_block.png");
79 mud = mat_from_image("texture","mud.png");
81 mat_shininess(steel,5.0,0.5);
82 mat_bumpiness(steel,0.1);
84 mat_bumpiness(mud,0.8);
86 p.x = 4.0;
87 p.y = 0.0;
88 p.z = -10.0;
89 block1 = render3d_cube(3.0,&p,mud);
90 p.x = -4.0;
91 block2 = render3d_cube(3.0,&p,steel);
92 r = 0.0;
94 while (state_client != VLSTATE_EXIT) {
95 render_pre();
97 r += 45.0*client_dtime();
98 if (r > 360.0)
99 r -= 360.0;
101 object_rotate(block1,20.0,r,-r);
102 object_rotate(block2,20.0,-r,r);
104 textbuffer_clear(&tb2);
105 textbuffer_init(&tb2,f,14,20,40,0,0,0,0);
106 sprintf(buff,"FPS: %d",wm_data.fps);
107 textbuffer_addstr(&tb2,buff);
109 render2d_textbuffer(&tb);
110 render2d_textbuffer(&tb2);
112 render2d_quad_mat(logo,412,150,200,200);
114 render_post();
117 content_exit();
118 net_exit();
119 config_save();
120 events_exit();
121 path_exit();
123 return 0;
126 #ifdef WIN32
127 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
129 LPWSTR *args;
130 char** argv;
131 int argc = 0;
133 args = CommandLineToArgvW(GetCommandLineW(), &argc);
134 if (args) {
135 argv = (char**)args;
136 }else{
137 argv = malloc(sizeof(char*));
138 argv[0] = NULL;
140 return main(argc,argv);
142 #endif