X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=vid_shared.c;h=4579c1434a32aaf5d853be81326c10d5ab84cae7;hb=ae2cc99336ec5e70b725f48fc10efc6469b6ea66;hp=d1ac242bd37c4109b96b379d5a17d2d8c0ac0795;hpb=66d1df20a5ed5ff954d7bf9db2db23cbe304281a;p=xonotic%2Fdarkplaces.git diff --git a/vid_shared.c b/vid_shared.c index d1ac242b..4579c143 100644 --- a/vid_shared.c +++ b/vid_shared.c @@ -2,6 +2,10 @@ #include "quakedef.h" #include "cdaudio.h" +#ifdef SUPPORTCG +#include +#endif + // global video state viddef_t vid; @@ -56,6 +60,9 @@ cvar_t vid_minwidth = {0, "vid_minwidth", "0", "minimum vid_width that is accept cvar_t vid_minheight = {0, "vid_minheight", "0", "minimum vid_height that is acceptable (to be set in default.cfg in mods)"}; cvar_t vid_gl13 = {0, "vid_gl13", "1", "enables faster rendering using OpenGL 1.3 features (such as GL_ARB_texture_env_combine extension)"}; cvar_t vid_gl20 = {0, "vid_gl20", "1", "enables faster rendering using OpenGL 2.0 features (such as GL_ARB_fragment_shader extension)"}; +#ifdef SUPPORTCG +cvar_t vid_cggl = {0, "vid_glcg", "1", "enables faster rendering using the Cg shader library"}; +#endif cvar_t gl_finish = {0, "gl_finish", "0", "make the cpu wait for the graphics processor at the end of each rendered frame (can help with strange input or video lag problems on some machines)"}; cvar_t vid_stick_mouse = {CVAR_SAVE, "vid_stick_mouse", "0", "have the mouse stuck in the center of the screen" }; @@ -103,10 +110,6 @@ void (GLAPIENTRY *qglMultiTexCoord4f) (GLenum, GLfloat, GLfloat, GLfloat, GLfloa void (GLAPIENTRY *qglActiveTexture) (GLenum); void (GLAPIENTRY *qglClientActiveTexture) (GLenum); -// GL_EXT_compiled_vertex_array -void (GLAPIENTRY *qglLockArraysEXT) (GLint first, GLint count); -void (GLAPIENTRY *qglUnlockArraysEXT) (void); - // general GL functions void (GLAPIENTRY *qglClearColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); @@ -191,6 +194,11 @@ void (GLAPIENTRY *qglTexEnvi)(GLenum target, GLenum pname, GLint param); void (GLAPIENTRY *qglTexParameterf)(GLenum target, GLenum pname, GLfloat param); void (GLAPIENTRY *qglTexParameterfv)(GLenum target, GLenum pname, GLfloat *params); void (GLAPIENTRY *qglTexParameteri)(GLenum target, GLenum pname, GLint param); +void (GLAPIENTRY *qglGetTexParameterfv)(GLenum target, GLenum pname, GLfloat *params); +void (GLAPIENTRY *qglGetTexParameteriv)(GLenum target, GLenum pname, GLint *params); +void (GLAPIENTRY *qglGetTexLevelParameterfv)(GLenum target, GLint level, GLenum pname, GLfloat *params); +void (GLAPIENTRY *qglGetTexLevelParameteriv)(GLenum target, GLint level, GLenum pname, GLint *params); +void (GLAPIENTRY *qglGetTexImage)(GLenum target, GLint level, GLenum format, GLenum type, GLvoid *pixels); void (GLAPIENTRY *qglHint)(GLenum target, GLenum mode); void (GLAPIENTRY *qglGenTextures)(GLsizei n, GLuint *textures); @@ -527,6 +535,11 @@ static dllfunction_t opengl110funcs[] = {"glTexParameterf", (void **) &qglTexParameterf}, {"glTexParameterfv", (void **) &qglTexParameterfv}, {"glTexParameteri", (void **) &qglTexParameteri}, + {"glGetTexImage", (void **) &qglGetTexImage}, + {"glGetTexParameterfv", (void **) &qglGetTexParameterfv}, + {"glGetTexParameteriv", (void **) &qglGetTexParameteriv}, + {"glGetTexLevelParameterfv", (void **) &qglGetTexLevelParameterfv}, + {"glGetTexLevelParameteriv", (void **) &qglGetTexLevelParameteriv}, {"glHint", (void **) &qglHint}, // {"glPixelStoref", (void **) &qglPixelStoref}, {"glPixelStorei", (void **) &qglPixelStorei}, @@ -576,13 +589,6 @@ static dllfunction_t multitexturefuncs[] = {NULL, NULL} }; -static dllfunction_t compiledvertexarrayfuncs[] = -{ - {"glLockArraysEXT", (void **) &qglLockArraysEXT}, - {"glUnlockArraysEXT", (void **) &qglUnlockArraysEXT}, - {NULL, NULL} -}; - static dllfunction_t texture3dextfuncs[] = { {"glTexImage3DEXT", (void **) &qglTexImage3D}, @@ -812,11 +818,11 @@ void VID_CheckExtensions(void) vid.support.ati_separate_stencil = GL_CheckExtension("2.0", gl2separatestencilfuncs, "-noseparatestencil", true) || GL_CheckExtension("GL_ATI_separate_stencil", atiseparatestencilfuncs, "-noseparatestencil", false); vid.support.ext_blend_minmax = GL_CheckExtension("GL_EXT_blend_minmax", blendequationfuncs, "-noblendminmax", false); vid.support.ext_blend_subtract = GL_CheckExtension("GL_EXT_blend_subtract", blendequationfuncs, "-noblendsubtract", false); - vid.support.ext_compiled_vertex_array = GL_CheckExtension("GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "-nocva", false); vid.support.ext_draw_range_elements = GL_CheckExtension("1.2", drawrangeelementsfuncs, "-nodrawrangeelements", true) || GL_CheckExtension("GL_EXT_draw_range_elements", drawrangeelementsextfuncs, "-nodrawrangeelements", false); vid.support.ext_framebuffer_object = GL_CheckExtension("GL_EXT_framebuffer_object", fbofuncs, "-nofbo", false); vid.support.ext_stencil_two_side = GL_CheckExtension("GL_EXT_stencil_two_side", stenciltwosidefuncs, "-nostenciltwoside", false); vid.support.ext_texture_3d = GL_CheckExtension("GL_EXT_texture3D", texture3dextfuncs, "-notexture3d", false); + vid.support.ext_texture_compression_s3tc = GL_CheckExtension("GL_EXT_texture_compression_s3tc", NULL, "-nos3tc", false); vid.support.ext_texture_edge_clamp = GL_CheckExtension("GL_EXT_texture_edge_clamp", NULL, "-noedgeclamp", false) || GL_CheckExtension("GL_SGIS_texture_edge_clamp", NULL, "-noedgeclamp", false); vid.support.ext_texture_filter_anisotropic = GL_CheckExtension("GL_EXT_texture_filter_anisotropic", NULL, "-noanisotropy", false); // COMMANDLINEOPTION: GL: -noanisotropy disables GL_EXT_texture_filter_anisotropic (allows higher quality texturing) @@ -824,7 +830,6 @@ void VID_CheckExtensions(void) // COMMANDLINEOPTION: GL: -noblendsubtract disables GL_EXT_blend_subtract // COMMANDLINEOPTION: GL: -nocombine disables GL_ARB_texture_env_combine or GL_EXT_texture_env_combine (required for bumpmapping and faster map rendering) // COMMANDLINEOPTION: GL: -nocubemap disables GL_ARB_texture_cube_map (required for bumpmapping) -// COMMANDLINEOPTION: GL: -nocva disables GL_EXT_compiled_vertex_array (renders faster) // COMMANDLINEOPTION: GL: -nodepthtexture disables use of GL_ARB_depth_texture (required for shadowmapping) // COMMANDLINEOPTION: GL: -nodrawbuffers disables use of GL_ARB_draw_buffers (required for r_shadow_deferredprepass) // COMMANDLINEOPTION: GL: -nodrawrangeelements disables GL_EXT_draw_range_elements (renders faster) @@ -834,6 +839,7 @@ void VID_CheckExtensions(void) // COMMANDLINEOPTION: GL: -nomtex disables GL_ARB_multitexture (required for faster map rendering) // COMMANDLINEOPTION: GL: -noocclusionquery disables GL_ARB_occlusion_query (which allows coronas to fade according to visibility, and potentially used for rendering optimizations) // COMMANDLINEOPTION: GL: -norectangle disables GL_ARB_texture_rectangle (required for bumpmapping) +// COMMANDLINEOPTION: GL: -nos3tc disables GL_EXT_texture_compression_s3tc (which allows use of .dds texture caching) // COMMANDLINEOPTION: GL: -noseparatestencil disables use of OpenGL2.0 glStencilOpSeparate and GL_ATI_separate_stencil extensions (which accelerate shadow rendering) // COMMANDLINEOPTION: GL: -noshaderobjects disables GL_ARB_shader_objects (required for vertex shader and fragment shader) // COMMANDLINEOPTION: GL: -noshadinglanguage100 disables GL_ARB_shading_language_100 (required for vertex shader and fragment shader) @@ -905,6 +911,16 @@ void VID_CheckExtensions(void) Con_DPrintf("Using GL2.0 rendering path - %i texture matrix, %i texture images, %i texcoords%s\n", vid.texunits, vid.teximageunits, vid.texarrayunits, vid.support.ext_framebuffer_object ? ", shadowmapping supported" : ""); vid.renderpath = RENDERPATH_GL20; } +#ifdef SUPPORTCG + else if (vid_cggl.integer && (vid.cgcontext = cgCreateContext())) + { + vid.texunits = 4; + vid.teximageunits = 16; + vid.texarrayunits = 8; + Con_DPrintf("Using NVIDIA Cg rendering path - %i texture matrix, %i texture images, %i texcoords%s\n", vid.texunits, vid.teximageunits, vid.texarrayunits, vid.support.ext_framebuffer_object ? ", shadowmapping supported" : ""); + vid.renderpath = RENDERPATH_CGGL; + } +#endif else if (vid.support.arb_texture_env_combine && vid.texunits >= 2 && vid_gl13.integer) { qglGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, (GLint*)&vid.texunits); @@ -1012,6 +1028,7 @@ void VID_UpdateGamma(qboolean force, int rampsize) switch(vid.renderpath) { case RENDERPATH_GL20: + case RENDERPATH_CGGL: if (v_glslgamma.integer) wantgamma = 0; break; @@ -1191,6 +1208,9 @@ void VID_Shared_Init(void) Cvar_RegisterVariable(&vid_minheight); Cvar_RegisterVariable(&vid_gl13); Cvar_RegisterVariable(&vid_gl20); +#ifdef SUPPORTCG + Cvar_RegisterVariable(&vid_cggl); +#endif Cvar_RegisterVariable(&gl_finish); Cmd_AddCommand("force_centerview", Force_CenterView_f, "recenters view (stops looking up/down)"); Cmd_AddCommand("vid_restart", VID_Restart_f, "restarts video system (closes and reopens the window, restarts renderer)");