X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2F3dengfx%2Fsrc%2F3dengfx%2F3denginefx.cpp;h=e2333f215642cd30c7c1d31d5568e91c209ecc20;hb=2bafc8bc0e6f591e64b93c5f0f6771cbd5a39d4f;hp=899031c5bbbf5bef26092553d9d7208ea73f3628;hpb=6e23259dbabaeb1711a2a5ca25b9cb421f693759;p=summerhack diff --git a/src/3dengfx/src/3dengfx/3denginefx.cpp b/src/3dengfx/src/3dengfx/3denginefx.cpp index 899031c..e2333f2 100644 --- a/src/3dengfx/src/3dengfx/3denginefx.cpp +++ b/src/3dengfx/src/3dengfx/3denginefx.cpp @@ -154,7 +154,7 @@ namespace engfx_state { using namespace engfx_state; GraphicsInitParameters *load_graphics_context_config(const char *fname) { - static GraphicsInitParameters gip; + static GraphicsInitParameters gip; gip.x = 640; gip.y = 480; gip.bpp = 16; @@ -166,10 +166,10 @@ GraphicsInitParameters *load_graphics_context_config(const char *fname) { error("%s: could not load config file", __func__); return 0; } - + const ConfigOption *cfgopt; while((cfgopt = get_next_option())) { - + if(!strcmp(cfgopt->option, "fullscreen")) { if(!strcmp(cfgopt->str_value, "true")) { gip.fullscreen = true; @@ -180,20 +180,26 @@ GraphicsInitParameters *load_graphics_context_config(const char *fname) { return 0; } } else if(!strcmp(cfgopt->option, "resolution")) { - if(!isdigit(cfgopt->str_value[0])) { - error("%s: error parsing config file %s", __func__, fname); - return 0; - } - gip.x = atoi(cfgopt->str_value); - - char *ptr = cfgopt->str_value; - while(*ptr && *ptr != 'x') *ptr++; - if(!*ptr || !*(ptr+1) || !isdigit(*(ptr+1))) { - error("%s: error parsing config file %s", __func__, fname); - return 0; + if(!strcmp(cfgopt->str_value, "dontcare")) { + gip.x = 1024; + gip.y = 768; + gip.dont_care_flags |= DONT_CARE_SIZE; + } else { + if(!isdigit(cfgopt->str_value[0])) { + error("%s: error parsing config file %s", __func__, fname); + return 0; + } + gip.x = atoi(cfgopt->str_value); + + char *ptr = cfgopt->str_value; + while(*ptr && *ptr != 'x') ptr++; + if(!*ptr || !*(ptr+1) || !isdigit(*(ptr+1))) { + error("%s: error parsing config file %s", __func__, fname); + return 0; + } + + gip.y = atoi(ptr + 1); } - - gip.y = atoi(ptr + 1); } else if(!strcmp(cfgopt->option, "bpp")) { if(cfgopt->flags & CFGOPT_INT) { gip.bpp = cfgopt->int_value; @@ -203,12 +209,12 @@ GraphicsInitParameters *load_graphics_context_config(const char *fname) { } else { error("%s: error parsing config file %s", __func__, fname); return 0; - } + } } else if(!strcmp(cfgopt->option, "zbuffer")) { if(cfgopt->flags & CFGOPT_INT) { gip.depth_bits = cfgopt->int_value; } else if(!strcmp(cfgopt->str_value, "dontcare")) { - gip.depth_bits = 32; + gip.depth_bits = 24; gip.dont_care_flags |= DONT_CARE_DEPTH; } else { error("%s: error parsing config file %s", __func__, fname); @@ -273,6 +279,7 @@ SysCaps get_system_capabilities() { // fill the SysCaps structure //SysCaps sys_caps; + sys_caps.multitex = (bool)strstr(ext_str, "GL_ARB_multitexture"); sys_caps.load_transpose = (bool)strstr(ext_str, "GL_ARB_transpose_matrix"); sys_caps.gen_mipmaps = (bool)strstr(ext_str, "GL_SGIS_generate_mipmap"); sys_caps.tex_combine_ops = (bool)strstr(ext_str, "GL_ARB_texture_env_combine"); @@ -1013,7 +1020,7 @@ void use_vertex_colors(bool enable) { void set_render_target(Texture *tex, CubeMapFace cube_map_face) { static std::stack rt_stack; static std::stack face_stack; - + Texture *prev = rt_stack.empty() ? 0 : rt_stack.top(); CubeMapFace prev_face = CUBE_MAP_PX; // just to get rid of the uninitialized var warning if(!face_stack.empty()) prev_face = face_stack.top(); @@ -1024,7 +1031,7 @@ void set_render_target(Texture *tex, CubeMapFace cube_map_face) { set_texture(0, prev); glCopyTexSubImage2D(prev->get_type() == TEX_CUBE ? prev_face : GL_TEXTURE_2D, 0, 0, 0, 0, 0, prev->width, prev->height); } - + if(!tex) { rt_stack.pop(); if(prev->get_type() == TEX_CUBE) { @@ -1192,20 +1199,21 @@ Matrix4x4 get_matrix(TransformType xform_type, int num) { switch(xform_type) { case XFORM_WORLD: return world_matrix; - + case XFORM_VIEW: return view_matrix; - + case XFORM_TEXTURE: return tex_matrix[num]; - + case XFORM_PROJECTION: default: return proj_matrix; } } -void set_viewport(unsigned int x, unsigned int y, unsigned int xsize, unsigned int ysize) { +void set_viewport(unsigned int x, unsigned int y, unsigned int xsize, unsigned int ysize) +{ glViewport(x, y, xsize, ysize); } @@ -1218,14 +1226,12 @@ void set_viewport_norm(float x, float y, float xsize, float ysize) Matrix4x4 create_projection_matrix(scalar_t vfov, scalar_t aspect, scalar_t near_clip, scalar_t far_clip) { #ifdef COORD_LHS - scalar_t hfov = vfov * aspect; - scalar_t w = 1.0f / (scalar_t)tan(hfov * 0.5f); - scalar_t h = 1.0f / (scalar_t)tan(vfov * 0.5f); + scalar_t f = 1.0f / (scalar_t)tan(vfov * 0.5f); scalar_t q = far_clip / (far_clip - near_clip); - + Matrix4x4 mat; - mat[0][0] = w; - mat[1][1] = h; + mat[0][0] = f / aspect; + mat[1][1] = f; mat[2][2] = q; mat[3][2] = 1.0f; mat[2][3] = -q * near_clip;