ui part 1
[voxelands-alt.git] / src / client / main.c
blob9cd2321913b4e4bda2455bf8354eb87ec06fd43d
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 *glass;
44 material_t *ice;
45 material_t *mud;
46 object_t *mudblock;
47 object_t *steelblock;
48 object_t *glassblock;
49 object_t *iceblock;
50 v3_t p;
51 float r;
52 textbuffer_t tb;
53 textbuffer_t tb2;
54 font_t *f;
55 int i;
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 i = textbuffer_addstr(&tb,"Hello world! - ößäндгя ygj");
80 vlprintf("hello world %d",i);
82 glasscolour.r = 255;
83 glasscolour.g = 255;
84 glasscolour.b = 255;
85 glasscolour.a = 10;
87 icecolour.r = 214;
88 icecolour.g = 220;
89 icecolour.b = 255;
90 icecolour.a = 250;
92 logo = mat_from_image("texture","menulogo.png");
93 steel = mat_from_image("texture","steel_block.png");
94 mud = mat_from_image("texture","mud.png");
95 glass = mat_from_colour(&glasscolour);
96 ice = mat_from_colour(&icecolour);
98 mat_shininess(steel,5.0,0.5);
99 mat_bumpiness(steel,0.1);
101 mat_bumpiness(mud,0.8);
103 mat_options(ice,0);
104 mat_shininess(ice,8.0,0.2);
106 mat_options(glass,0);
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