diff options
| -rw-r--r-- | src/engine/client/client.cpp | 2 | ||||
| -rw-r--r-- | src/engine/client/gfx.cpp | 83 | ||||
| -rw-r--r-- | src/engine/config_variables.h | 14 | ||||
| -rw-r--r-- | src/engine/interface.h | 4 | ||||
| -rw-r--r-- | src/game/client/mapres_tilemap.cpp | 110 | ||||
| -rw-r--r-- | src/game/client/menu.cpp | 50 |
6 files changed, 96 insertions, 167 deletions
diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index d4c7f2db..55646b35 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -997,7 +997,7 @@ int main(int argc, char **argv) else if(argv[i][0] == '-' && argv[i][1] == 'w' && argv[i][2] == 0) { // -w - config.fullscreen = 0; + config.gfx_fullscreen = 0; } else if(argv[i][0] == '-' && argv[i][1] == 'e' && argv[i][2] == 0) diff --git a/src/engine/client/gfx.cpp b/src/engine/client/gfx.cpp index 1ccd686d..819061ba 100644 --- a/src/engine/client/gfx.cpp +++ b/src/engine/client/gfx.cpp @@ -24,10 +24,7 @@ struct custom_vertex }; const int vertex_buffer_size = 32*1024; -//static custom_vertex vertices[4]; static custom_vertex *vertices = 0; -//static index_buffer ib; -static unsigned short indecies[vertex_buffer_size*6]; static int num_vertices = 0; static vec4 color[4]; static vec2 texture[4]; @@ -85,8 +82,8 @@ static void draw_quad(bool _bflush = false) sizeof(custom_vertex), sizeof(vec3)+sizeof(vec2)); - glDrawElements(GL_TRIANGLES, num_vertices, GL_UNSIGNED_SHORT, indecies); - //opengl::draw_arrays(GL_QUADS, 0, num_vertices); + //glDrawElements(GL_TRIANGLES, num_vertices, GL_UNSIGNED_SHORT, indecies); + opengl::draw_arrays(GL_QUADS, 0, num_vertices); } else { @@ -109,70 +106,11 @@ static void draw_quad(bool _bflush = false) num_vertices = 0; } } -struct batch -{ - opengl::vertex_buffer vb; - int num; -}; - -void gfx_destoy_batch(void *in_b) -{ - batch *b = (batch*)in_b; - delete b; - -} - -void gfx_quads_draw_batch(void *in_b) -{ - batch *b = (batch*)in_b; - - if(GLEW_ARB_vertex_buffer_object) - { - // set the data - opengl::stream_vertex(&b->vb, 3, GL_FLOAT, sizeof(custom_vertex), 0); - opengl::stream_texcoord(&b->vb, 0, 2, GL_FLOAT, - sizeof(custom_vertex), - sizeof(vec3)); - opengl::stream_color(&b->vb, 4, GL_FLOAT, - sizeof(custom_vertex), - sizeof(vec3)+sizeof(vec2)); - opengl::draw_arrays(GL_QUADS, 0, b->num); - } - /* - else - { - glVertexPointer(3, GL_FLOAT, - sizeof(custom_vertex), - (char*)vertices); - glTexCoordPointer(2, GL_FLOAT, - sizeof(custom_vertex), - (char*)vertices + sizeof(vec3)); - glColorPointer(4, GL_FLOAT, - sizeof(custom_vertex), - (char*)vertices + sizeof(vec3) + sizeof(vec2)); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - glEnableClientState(GL_COLOR_ARRAY); - glDrawArrays(GL_QUADS, 0, b->num); - }*/ -} - -void *gfx_quads_create_batch() -{ - batch *b = new batch; - b->num = num_vertices; - b->vb.data(vertices, num_vertices*sizeof(custom_vertex), GL_STATIC_DRAW); - dbg_msg("gfx", "created batch. num=%d size=%d", num_vertices, num_vertices*sizeof(custom_vertex)); - num_vertices = 0; - gfx_quads_end(); - return b; -} - - bool gfx_init() { - if(!context.create(config.screen_width, config.screen_height, 24, 8, 16, 0, config.fullscreen?opengl::context::FLAG_FULLSCREEN:0)) + if(!context.create(config.gfx_screen_width, config.gfx_screen_height, 24, 8, 16, 0, + config.gfx_fullscreen?opengl::context::FLAG_FULLSCREEN:0)) { dbg_msg("game", "failed to create gl context"); return false; @@ -192,7 +130,7 @@ bool gfx_init() context.version_minor(), context.version_rev());*/ - gfx_mapscreen(0,0,config.screen_width, config.screen_height); + gfx_mapscreen(0,0,config.gfx_screen_width, config.gfx_screen_height); // TODO: make wrappers for this glEnable(GL_BLEND); @@ -225,6 +163,7 @@ bool gfx_init() textures[MAX_TEXTURES-1].next = -1; // init indecies + /* for(int i = 0; i < vertex_buffer_size; i++) { indecies[i*6 + 0] = i+0; @@ -234,7 +173,7 @@ bool gfx_init() indecies[i*6 + 3] = i+1; indecies[i*6 + 4] = i+3; indecies[i*6 + 5] = i+2; - } + }*/ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); @@ -242,7 +181,7 @@ bool gfx_init() gfx_load_texture_raw(4,4,IMG_RGBA,null_texture_data); // set vsync as needed - gfx_set_vsync(config.vsync); + gfx_set_vsync(config.gfx_vsync); return true; } @@ -273,7 +212,7 @@ video_mode fakemodes[] = { int gfx_get_video_modes(video_mode *list, int maxcount) { - if(config.display_all_modes) + if(config.gfx_display_all_modes) { mem_copy(list, fakemodes, sizeof(fakemodes)); return min((int)(sizeof(fakemodes)/sizeof(video_mode)), maxcount); @@ -458,12 +397,12 @@ void gfx_swap() int gfx_screenwidth() { - return config.screen_width; + return config.gfx_screen_width; } int gfx_screenheight() { - return config.screen_height; + return config.gfx_screen_height; } void gfx_texture_set(int slot) diff --git a/src/engine/config_variables.h b/src/engine/config_variables.h index 8dcc7365..4919af0b 100644 --- a/src/engine/config_variables.h +++ b/src/engine/config_variables.h @@ -1,19 +1,19 @@ #include "../game/game_variables.h" -MACRO_CONFIG_INT(screen_width, 800, 0, 0) -MACRO_CONFIG_INT(screen_height, 600, 0, 0) -MACRO_CONFIG_INT(fullscreen, 1, 0, 1) -MACRO_CONFIG_INT(color_depth, 24, 16, 24) -MACRO_CONFIG_INT(vsync, 1, 0, 1) MACRO_CONFIG_INT(debug, 0, 0, 1) -MACRO_CONFIG_INT(display_all_modes, 0, 0, 1) MACRO_CONFIG_INT(volume, 200, 0, 255) MACRO_CONFIG_INT(cpu_throttle, 0, 0, 1) MACRO_CONFIG_STR(player_name, 32, "nameless tee") MACRO_CONFIG_STR(clan_name, 32, "") MACRO_CONFIG_STR(password, 32, "") -MACRO_CONFIG_INT(gfx_texture_compression, 1, 0, 1) +MACRO_CONFIG_INT(gfx_screen_width, 800, 0, 0) +MACRO_CONFIG_INT(gfx_screen_height, 600, 0, 0) +MACRO_CONFIG_INT(gfx_fullscreen, 1, 0, 1) +MACRO_CONFIG_INT(gfx_color_depth, 24, 16, 24) +MACRO_CONFIG_INT(gfx_vsync, 1, 0, 1) +MACRO_CONFIG_INT(gfx_display_all_modes, 0, 0, 1) +MACRO_CONFIG_INT(gfx_texture_compression, 0, 0, 1) MACRO_CONFIG_INT(gfx_high_detail, 1, 0, 1) MACRO_CONFIG_INT(gfx_texture_quality, 1, 0, 1) diff --git a/src/engine/interface.h b/src/engine/interface.h index d51cedc4..f3de5109 100644 --- a/src/engine/interface.h +++ b/src/engine/interface.h @@ -754,10 +754,6 @@ float gfx_pretty_text_width(float size, const char *text, int length = -1); void gfx_getscreen(float *tl_x, float *tl_y, float *br_x, float *br_y); -void gfx_quads_draw_batch(void *batch); -void *gfx_quads_create_batch(); -void gfx_destoy_batch(void *batch); - void mods_message(int msg, int client_id); void modc_message(int msg); diff --git a/src/game/client/mapres_tilemap.cpp b/src/game/client/mapres_tilemap.cpp index 6f61e656..032238bf 100644 --- a/src/game/client/mapres_tilemap.cpp +++ b/src/game/client/mapres_tilemap.cpp @@ -6,16 +6,8 @@ #include <baselib/opengl.h> -void *batches[32] = {0}; - int tilemap_init() { - for(int i = 0; i < 32; i++) - if(batches[i]) - { - gfx_destoy_batch(batches[i]); - batches[i] = 0; - } return 0; } @@ -47,69 +39,57 @@ void tilemap_render(float scale, int fg) continue; gfx_texture_set(img_get(tmap->image)); - if(!batches[t]) - { - gfx_quads_begin(); - - int starty = (int)(screen_y0/scale)-1; - int startx = (int)(screen_x0/scale)-1; - int endy = (int)(screen_y1/scale)+1; - int endx = (int)(screen_x1/scale)+1; - - float frac = (1.0f/1024.0f);//2.0f; //2.0f; - float texsize = 1024.0f; - float nudge = 0.5f/texsize; - int border = 24; - for(int y = starty; y < endy; y++) - for(int x = startx; x < endx; x++) + gfx_quads_begin(); + + int starty = (int)(screen_y0/scale)-1; + int startx = (int)(screen_x0/scale)-1; + int endy = (int)(screen_y1/scale)+1; + int endx = (int)(screen_x1/scale)+1; + + float frac = (1.0f/1024.0f);//2.0f; //2.0f; + float texsize = 1024.0f; + float nudge = 0.5f/texsize; + for(int y = starty; y < endy; y++) + for(int x = startx; x < endx; x++) + { + int mx = x; + int my = y; + if(mx<0) mx = 0; + if(mx>=tmap->width) mx = tmap->width-1; + if(my<0) my = 0; + if(my>=tmap->height) my = tmap->height-1; + + int c = mx + my*tmap->width; + + unsigned char d = data[c*2]; + if(d) { - int mx = x; - int my = y; - if(mx<0) mx = 0; - if(mx>=tmap->width) mx = tmap->width-1; - if(my<0) my = 0; - if(my>=tmap->height) my = tmap->height-1; + /* + gfx_quads_setsubset( + (d%16)/16.0f*s+frac, + (d/16)/16.0f*s+frac, + ((d%16)/16.0f+1.0f/16.0f)*s-frac, + ((d/16)/16.0f+1.0f/16.0f)*s-frac); + */ - int c = mx + my*tmap->width; - - unsigned char d = data[c*2]; - if(d) - { - /* - gfx_quads_setsubset( - (d%16)/16.0f*s+frac, - (d/16)/16.0f*s+frac, - ((d%16)/16.0f+1.0f/16.0f)*s-frac, - ((d/16)/16.0f+1.0f/16.0f)*s-frac); - */ - - int tx = d%16; - int ty = d/16; - int px0 = tx*(1024/16); - int py0 = ty*(1024/16); - int px1 = (tx+1)*(1024/16)-1; - int py1 = (ty+1)*(1024/16)-1; + int tx = d%16; + int ty = d/16; + int px0 = tx*(1024/16); + int py0 = ty*(1024/16); + int px1 = (tx+1)*(1024/16)-1; + int py1 = (ty+1)*(1024/16)-1; - gfx_quads_setsubset( - nudge + px0/texsize+frac, - nudge + py0/texsize+frac, - nudge + px1/texsize-frac, - nudge + py1/texsize-frac); + gfx_quads_setsubset( + nudge + px0/texsize+frac, + nudge + py0/texsize+frac, + nudge + px1/texsize-frac, + nudge + py1/texsize-frac); - gfx_quads_drawTL(x*scale, y*scale, scale, scale); - } + gfx_quads_drawTL(x*scale, y*scale, scale, scale); } - - gfx_quads_end(); - //batches[t] = gfx_quads_create_batch(); - } + } - //gfx_quads_draw_batch(batches[t]); - //glCallList(lists_start+t); + gfx_quads_end(); } } - - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); - } diff --git a/src/game/client/menu.cpp b/src/game/client/menu.cpp index 06b65e62..1f9857a8 100644 --- a/src/game/client/menu.cpp +++ b/src/game/client/menu.cpp @@ -424,7 +424,7 @@ int ui_do_edit_box(void *id, float x, float y, float w, float h, char *str, int if (inside && ui_mouse_button(0)) { - int mx_rel = ui_mouse_x() - x; + int mx_rel = (int)(ui_mouse_x() - x); for (int i = 1; i <= len; i++) { @@ -727,6 +727,9 @@ const float row1_y = 180; const float row2_y = row1_y + 40; const float row3_y = row2_y + 40; const float row4_y = row3_y + 40; +const float row5_y = row4_y + 40; +const float row6_y = row5_y + 40; +const float row7_y = row6_y + 40; static int main_render() { @@ -873,9 +876,9 @@ static int settings_video_render_select_mode() char buf[128]; int s = 0; - if(modes[index].width == config_copy.screen_width && - modes[index].height == config_copy.screen_height && - depth == config_copy.color_depth) + if(modes[index].width == config_copy.gfx_screen_width && + modes[index].height == config_copy.gfx_screen_height && + depth == config_copy.gfx_color_depth) { s = 1; } @@ -886,9 +889,9 @@ static int settings_video_render_select_mode() column1_x, row1_y + 40 * i, 320, 32.0f, draw_teewars_button)) { // select - config_set_color_depth(&config_copy, depth); - config_set_screen_width(&config_copy, modes[index].width); - config_set_screen_height(&config_copy, modes[index].height); + config_set_gfx_color_depth(&config_copy, depth); + config_set_gfx_screen_width(&config_copy, modes[index].width); + config_set_gfx_screen_height(&config_copy, modes[index].height); screen = SCREEN_SETTINGS_VIDEO; } } @@ -898,23 +901,34 @@ static int settings_video_render_select_mode() static int settings_video_render() { - // we need to draw these bottom up, to make overlapping work correctly - ui_do_label(column1_x, row4_y + 50, "(A restart of the game is required for these settings to take effect.)", 20); - - ui_do_label(column1_x, row4_y, "V-sync:", 36); - config_set_vsync(&config_copy, ui_do_check_box(&config_copy.vsync, column2_x, row4_y + 5, 32, 32, config_copy.vsync)); - - ui_do_label(column1_x, row3_y, "Fullscreen:", 36); - config_set_fullscreen(&config_copy, ui_do_check_box(&config_copy.fullscreen, column2_x, row3_y + 5, 32, 32, config_copy.fullscreen)); - ui_do_label(column1_x, row2_y, "Mode:", 36); + ui_do_label(column1_x, row1_y, "Mode:", 36); char buf[128]; - sprintf(buf, "%dx%d %d bit", config_copy.screen_width, config_copy.screen_height, config_copy.color_depth); + sprintf(buf, "%dx%d %d bit", config_copy.gfx_screen_width, config_copy.gfx_screen_height, config_copy.gfx_color_depth); static int select_button = 0; - if(ui_do_button(&select_button, buf, 0, column2_x, row2_y, 300, 32, draw_teewars_button)) + if(ui_do_button(&select_button, buf, 0, column2_x, row1_y, 300, 32, draw_teewars_button)) screen = SCREEN_SETTINGS_VIDEO_SELECT_MODE; + // we need to draw these bottom up, to make overlapping work correctly + + ui_do_label(column1_x, row2_y, "Fullscreen:", 36); + config_set_gfx_fullscreen(&config_copy, ui_do_check_box(&config_copy.gfx_fullscreen, column3_x, row2_y + 5, 32, 32, config_copy.gfx_fullscreen)); + + ui_do_label(column1_x, row3_y, "V-sync:", 36); + config_set_gfx_vsync(&config_copy, ui_do_check_box(&config_copy.gfx_vsync, column3_x, row3_y + 5, 32, 32, config_copy.gfx_vsync)); + + ui_do_label(column1_x, row4_y, "Quality Textures:", 36); + config_set_gfx_texture_quality(&config_copy, ui_do_check_box(&config_copy.gfx_texture_quality, column3_x, row4_y + 5, 32, 32, config_copy.gfx_texture_quality)); + + ui_do_label(column1_x, row5_y, "Textures Compression:", 36); + config_set_gfx_texture_compression(&config_copy, ui_do_check_box(&config_copy.gfx_texture_compression, column3_x, row5_y + 5, 32, 32, config_copy.gfx_texture_compression)); + + ui_do_label(column1_x, row6_y, "High Detail:", 36); + config_set_gfx_high_detail(&config_copy, ui_do_check_box(&config_copy.gfx_high_detail, column3_x, row6_y + 5, 32, 32, config_copy.gfx_high_detail)); + + ui_do_label(column1_x, row6_y + 50, "(A restart of the game is required for these settings to take effect.)", 20); + return 0; } |