modify logging to simplify i18n
[voxelands-alt.git] / src / client / main.c
bloba492d8446d2b66294f091e327886db11326f0b84
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"
27 #include "ui.h"
29 static int state_client = VLSTATE_PLAY;
31 /* get/set the client state */
32 int client_state(int s)
34 int r = state_client;
35 if (s != VLSTATE_GET)
36 state_client = s;
37 return r;
40 int main(int argc, char** argv)
42 material_t *logo;
43 material_t *steel;
44 material_t *glass;
45 material_t *ice;
46 material_t *mud;
47 object_t *mudblock;
48 object_t *steelblock;
49 object_t *glassblock;
50 object_t *iceblock;
51 v3_t p;
52 float r;
53 textbuffer_t tb;
54 textbuffer_t tb2;
55 font_t *f;
56 char buff[256];
57 colour_t glasscolour;
58 colour_t icecolour;
60 command_init();
61 path_init();
62 config_init(argc,argv);
63 events_init();
64 time_init();
65 intl_init();
66 sys_console_init();
67 net_init();
68 content_init();
70 wm_init();
71 wm_title(PACKAGE " - " VERSION);
72 ui_init();
74 f = font_find("default");
76 textbuffer_init(&tb,f,14,20,20,0,0,0,0);
77 textbuffer_init(&tb2,f,14,20,40,0,0,0,0);
78 textbuffer_addstr(&tb,"Hello world! - ößäндгя ygj");
80 glasscolour.r = 255;
81 glasscolour.g = 255;
82 glasscolour.b = 255;
83 glasscolour.a = 10;
85 icecolour.r = 214;
86 icecolour.g = 220;
87 icecolour.b = 255;
88 icecolour.a = 220;
90 logo = mat_from_image("texture","menulogo.png");
91 steel = mat_from_image("texture","steel_block.png");
92 mud = mat_from_image("texture","mud.png");
93 glass = mat_from_colour(&glasscolour);
94 ice = mat_from_colour(&icecolour);
96 mat_options(logo,MATOPT_ALPHA_BLEND);
98 mat_shininess(steel,5.0,0.5);
99 mat_bumpiness(steel,0.1);
101 mat_bumpiness(mud,0.8);
103 mat_options(ice,MATOPT_ALPHA_BLEND);
104 mat_shininess(ice,8.0,0.2);
106 mat_options(glass,MATOPT_ADDITIVE_BLEND);
107 mat_shininess(glass,2.0,0.8);
109 p.x = 4.0;
110 p.y = 4.0;
111 p.z = -10.0;
112 mudblock = render3d_cube(3.0,&p,mud);
113 p.x = -4.0;
114 steelblock = render3d_cube(3.0,&p,steel);
115 p.y = -4.0;
116 p.x = 4.0;
117 glassblock = render3d_cube(3.0,&p,glass);
118 p.x = -4.0;
119 iceblock = render3d_cube(3.0,&p,ice);
120 r = 0.0;
122 while (state_client != VLSTATE_EXIT) {
123 render_pre();
125 r += 45.0*client_dtime();
126 if (r > 360.0)
127 r -= 360.0;
129 object_rotate(mudblock,20.0,r,-r);
130 object_rotate(steelblock,20.0,-r,r);
131 object_rotate(glassblock,20.0,-r,-r);
132 object_rotate(iceblock,20.0,r,r);
134 textbuffer_clear(&tb2);
135 sprintf(buff,"FPS: %d",wm_data.fps);
136 textbuffer_addstr(&tb2,buff);
138 render2d_textbuffer(&tb);
139 render2d_textbuffer(&tb2);
141 render2d_quad_mat(logo,412,150,200,200);
143 render_post();
146 content_exit();
147 net_exit();
148 config_save();
149 events_exit();
150 path_exit();
152 return 0;
155 #ifdef WIN32
156 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
158 LPWSTR *args;
159 char** argv;
160 int argc = 0;
162 args = CommandLineToArgvW(GetCommandLineW(), &argc);
163 if (args) {
164 argv = (char**)args;
165 }else{
166 argv = malloc(sizeof(char*));
167 argv[0] = NULL;
169 return main(argc,argv);
171 #endif