diff --git a/engine/client/cl_screen.c b/engine/client/cl_screen.c index 79e09779b..36da537c7 100644 --- a/engine/client/cl_screen.c +++ b/engine/client/cl_screen.c @@ -513,7 +513,7 @@ void SCR_DrawCenterString (vrect_t *rect, cprint_t *p) py = ( y * vid.height) / (float)vid.pixelheight; pw = rect->width+8; if (*p->titleimage) - R2D_ScalePic (px-16, py-16, pw + 16, linecount*8 + 32, pic); + R2D_ScalePic (rect->x + ((int)rect->width - pic->width)/2, rect->y + ((int)rect->height - pic->height)/2, pic->width, pic->height, pic); else Draw_TextBox(px-16, py-8-8, pw/8, linecount+2); } diff --git a/engine/client/r_surf.c b/engine/client/r_surf.c index 3c27f0df2..eb242c00e 100644 --- a/engine/client/r_surf.c +++ b/engine/client/r_surf.c @@ -2088,7 +2088,12 @@ void Surf_DrawWorld (void) } } - CL_LinkStaticEntities(vis); + if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL)) + { + CL_LinkStaticEntities(vis); + TRACE(("dbg: calling R_DrawParticles\n")); + P_DrawParticles (); + } RSpeedEnd(RSPEED_WORLDNODE); TRACE(("dbg: calling BE_DrawWorld\n")); diff --git a/engine/client/render.h b/engine/client/render.h index 35c075e13..c1850e1b3 100644 --- a/engine/client/render.h +++ b/engine/client/render.h @@ -410,6 +410,7 @@ extern cvar_t r_speeds; extern cvar_t r_waterwarp; extern cvar_t r_fullbright; extern cvar_t r_lightmap; +extern cvar_t r_glsl_offsetmapping; extern cvar_t r_shadow_realtime_dlight, r_shadow_realtime_dlight_shadows; extern cvar_t r_shadow_realtime_world,r_shadow_realtime_world_shadows; extern cvar_t r_mirroralpha; diff --git a/engine/client/sys_linux.c b/engine/client/sys_linux.c index 3df388425..dde2438f5 100644 --- a/engine/client/sys_linux.c +++ b/engine/client/sys_linux.c @@ -612,7 +612,7 @@ int main (int c, const char **v) COM_InitArgv(parms.argc, parms.argv); TL_InitLanguages(); - parms.memsize = 16*1024*1024; + parms.memsize = 64*1024*1024; j = COM_CheckParm("-mem"); if (j && j+1 < com_argc) diff --git a/engine/common/net_wins.c b/engine/common/net_wins.c index 7ce1fd364..5815cce7b 100644 --- a/engine/common/net_wins.c +++ b/engine/common/net_wins.c @@ -3029,7 +3029,7 @@ int TCP_OpenStream (netadr_t remoteaddr) int newsocket; int temp; struct sockaddr_qstorage qs; - struct sockaddr_qstorage loc; +// struct sockaddr_qstorage loc; temp = NetadrToSockadr(&remoteaddr, &qs); diff --git a/engine/d3d/d3d_shader.c b/engine/d3d/d3d_shader.c index d222a1767..aff5d00ef 100644 --- a/engine/d3d/d3d_shader.c +++ b/engine/d3d/d3d_shader.c @@ -154,10 +154,11 @@ void D3DShader_Init(void) return; } -void D3DShader_CreateProgram (program_t *prog, int permu, char **precompilerconstants, char *vert, char *frag) +qboolean D3DShader_CreateProgram (program_t *prog, int permu, char **precompilerconstants, char *vert, char *frag) { D3DXMACRO defines[64]; LPD3DXBUFFER code = NULL, errors = NULL; + qboolean success = false; prog->handle[permu].hlsl.vert = NULL; prog->handle[permu].hlsl.frag = NULL; @@ -168,7 +169,7 @@ void D3DShader_CreateProgram (program_t *prog, int permu, char **precompilercons for (consts = 2; precompilerconstants[consts]; consts++) ; if (consts >= sizeof(defines) / sizeof(defines[0])) - return; + return success; consts = 0; defines[consts].Name = NULL; /*shader type*/ @@ -189,8 +190,12 @@ void D3DShader_CreateProgram (program_t *prog, int permu, char **precompilercons defines[consts].Name = NULL; defines[consts].Definition = NULL; + success = true; + defines[0].Name = "VERTEX_SHADER"; - if (!FAILED(pD3DXCompileShader(vert, strlen(vert), defines, NULL, "main", "vs_2_0", 0, &code, &errors, (LPD3DXCONSTANTTABLE*)&prog->handle[permu].hlsl.ctabv))) + if (FAILED(pD3DXCompileShader(vert, strlen(vert), defines, NULL, "main", "vs_2_0", 0, &code, &errors, (LPD3DXCONSTANTTABLE*)&prog->handle[permu].hlsl.ctabv))) + success = false; + else { IDirect3DDevice9_CreateVertexShader(pD3DDev9, code->lpVtbl->GetBufferPointer(code), (IDirect3DVertexShader9**)&prog->handle[permu].hlsl.vert); code->lpVtbl->Release(code); @@ -203,7 +208,9 @@ void D3DShader_CreateProgram (program_t *prog, int permu, char **precompilercons } defines[0].Name = "FRAGMENT_SHADER"; - if (!FAILED(pD3DXCompileShader(frag, strlen(frag), defines, NULL, "main", "ps_2_0", 0, &code, &errors, (LPD3DXCONSTANTTABLE*)&prog->handle[permu].hlsl.ctabf))) + if (FAILED(pD3DXCompileShader(frag, strlen(frag), defines, NULL, "main", "ps_2_0", 0, &code, &errors, (LPD3DXCONSTANTTABLE*)&prog->handle[permu].hlsl.ctabf))) + success = false; + else { IDirect3DDevice9_CreatePixelShader(pD3DDev9, code->lpVtbl->GetBufferPointer(code), (IDirect3DPixelShader9**)&prog->handle[permu].hlsl.frag); code->lpVtbl->Release(code); @@ -215,6 +222,7 @@ void D3DShader_CreateProgram (program_t *prog, int permu, char **precompilercons errors->lpVtbl->Release(errors); } } + return success; } static int D3DShader_FindUniform_(LPD3DXCONSTANTTABLE ct, char *name) diff --git a/engine/gl/gl_backend.c b/engine/gl/gl_backend.c index 2e68e61af..9b459fbcc 100644 --- a/engine/gl/gl_backend.c +++ b/engine/gl/gl_backend.c @@ -127,6 +127,7 @@ struct { unsigned int shaderbits; unsigned int sha_attr; int currentprogram; + int lastuniform; /*program which was last set, so using the same prog for multiple surfaces on the same ent (ie: world) does not require lots of extra uniform chnges*/ vbo_t dummyvbo; int colourarraytype; @@ -2228,287 +2229,310 @@ static void DrawPass(const shaderpass_t *pass) BE_SubmitMeshChain(); } -static unsigned int BE_Program_Set_Attribute(const shaderprogparm_t *p, unsigned int perm) +static unsigned int BE_Program_Set_Attributes(const program_t *prog, unsigned int perm, qboolean entunchanged) { vec3_t param3; int r, g, b; + int i; + unsigned int attr = 0; + const shaderprogparm_t *p; - switch(p->type) + for (i = 0; i < prog->numparams; i++) { - case SP_ATTR_VERTEX: - /*we still do vertex transforms for billboards and shadows and such*/ - GL_SelectVBO(shaderstate.pendingvertexvbo); - qglVertexAttribPointer(p->handle[perm], 3, GL_FLOAT, GL_FALSE, sizeof(vecV_t), shaderstate.pendingvertexpointer); - return 1u<handle[perm]; - case SP_ATTR_COLOUR: - if (shaderstate.sourcevbo->colours.gl.addr) - { - GL_SelectVBO(shaderstate.sourcevbo->colours.gl.vbo); - qglVertexAttribPointer(p->handle[perm], 4, shaderstate.colourarraytype, GL_FALSE, 0, shaderstate.sourcevbo->colours.gl.addr); - return 1u<handle[perm]; - } -/* else if (shaderstate.sourcevbo->colours4ub) - { - GL_SelectVBO(shaderstate.sourcevbo->colours.gl.vbo); - qglVertexAttribPointer(p->handle[perm], 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(byte_vec4_t), shaderstate.sourcevbo->colours.gl.addr); - return 1u<handle[perm]; - }*/ - break; - case SP_ATTR_TEXCOORD: - GL_SelectVBO(shaderstate.sourcevbo->texcoord.gl.vbo); - qglVertexAttribPointer(p->handle[perm], 2, GL_FLOAT, GL_FALSE, sizeof(vec2_t), shaderstate.sourcevbo->texcoord.gl.addr); - return 1u<handle[perm]; - case SP_ATTR_LMCOORD: - GL_SelectVBO(shaderstate.sourcevbo->lmcoord.gl.vbo); - qglVertexAttribPointer(p->handle[perm], 2, GL_FLOAT, GL_FALSE, sizeof(vec2_t), shaderstate.sourcevbo->lmcoord.gl.addr); - return 1u<handle[perm]; - case SP_ATTR_NORMALS: - if (!shaderstate.sourcevbo->normals.gl.addr) - return 0; - GL_SelectVBO(shaderstate.sourcevbo->normals.gl.vbo); - qglVertexAttribPointer(p->handle[perm], 3, GL_FLOAT, GL_FALSE, sizeof(vec3_t), shaderstate.sourcevbo->normals.gl.addr); - return 1u<handle[perm]; - case SP_ATTR_SNORMALS: - if (!shaderstate.sourcevbo->svector.gl.addr) - return 0; - GL_SelectVBO(shaderstate.sourcevbo->svector.gl.vbo); - qglVertexAttribPointer(p->handle[perm], 3, GL_FLOAT, GL_FALSE, sizeof(vec3_t), shaderstate.sourcevbo->svector.gl.addr); - return 1u<handle[perm]; - case SP_ATTR_TNORMALS: - if (!shaderstate.sourcevbo->tvector.gl.addr) - return 0; - GL_SelectVBO(shaderstate.sourcevbo->tvector.gl.vbo); - qglVertexAttribPointer(p->handle[perm], 3, GL_FLOAT, GL_FALSE, sizeof(vec3_t), shaderstate.sourcevbo->tvector.gl.addr); - return 1u<handle[perm]; - case SP_ATTR_BONENUMS: - GL_SelectVBO(shaderstate.sourcevbo->bonenums.gl.vbo); - qglVertexAttribPointer(p->handle[perm], 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(byte_vec4_t), shaderstate.sourcevbo->bonenums.gl.addr); - return 1u<handle[perm]; - case SP_ATTR_BONEWEIGHTS: - GL_SelectVBO(shaderstate.sourcevbo->boneweights.gl.vbo); - qglVertexAttribPointer(p->handle[perm], 4, GL_FLOAT, GL_FALSE, sizeof(vec4_t), shaderstate.sourcevbo->boneweights.gl.addr); - return 1u<handle[perm]; + p = &prog->parm[i]; + if (p->handle[perm] == -1) + continue; /*not in this permutation*/ - case SP_M_VIEW: - qglUniformMatrix4fvARB(p->handle[perm], 1, false, r_refdef.m_view); - break; - case SP_M_PROJECTION: - qglUniformMatrix4fvARB(p->handle[perm], 1, false, r_refdef.m_projection); - break; - case SP_M_MODELVIEW: - qglUniformMatrix4fvARB(p->handle[perm], 1, false, shaderstate.modelviewmatrix); - break; - case SP_M_MODELVIEWPROJECTION: - { - float m16[16]; - Matrix4_Multiply(r_refdef.m_projection, shaderstate.modelviewmatrix, m16); - qglUniformMatrix4fvARB(p->handle[perm], 1, false, m16); - } - break; - case SP_M_INVMODELVIEWPROJECTION: - { - float m16[16], inv[16]; - Matrix4_Multiply(r_refdef.m_projection, shaderstate.modelviewmatrix, m16); - Matrix4_Invert(m16, inv); - qglUniformMatrix4fvARB(p->handle[perm], 1, false, inv); - } - break; - case SP_M_MODEL: - qglUniformMatrix4fvARB(p->handle[perm], 1, false, shaderstate.modelmatrix); - break; - case SP_M_ENTBONES: - { - qglUniformMatrix3x4fv(p->handle[perm], shaderstate.sourcevbo->numbones, false, shaderstate.sourcevbo->bones); - } - break; - case SP_M_INVVIEWPROJECTION: - { - float m16[16], inv[16]; - Matrix4_Multiply(r_refdef.m_projection, r_refdef.m_view, m16); - Matrix4_Invert(m16, inv); - qglUniformMatrix4fvARB(p->handle[perm], 1, false, inv); - } - break; + /*don't bother setting it if the ent properties are unchanged (but do if the mesh changed)*/ + if (entunchanged && p->type >= SP_FIRSTUNIFORM) + break; - case SP_E_LMSCALE: + switch(p->type) { - vec4_t colscale; - if (shaderstate.mode == BEM_DEPTHDARK) + case SP_ATTR_VERTEX: + /*we still do vertex transforms for billboards and shadows and such*/ + GL_SelectVBO(shaderstate.pendingvertexvbo); + qglVertexAttribPointer(p->handle[perm], 3, GL_FLOAT, GL_FALSE, sizeof(vecV_t), shaderstate.pendingvertexpointer); + attr |= 1u<handle[perm]; + break; + case SP_ATTR_COLOUR: + if (shaderstate.sourcevbo->colours.gl.addr) { - VectorClear(colscale); + GL_SelectVBO(shaderstate.sourcevbo->colours.gl.vbo); + qglVertexAttribPointer(p->handle[perm], 4, shaderstate.colourarraytype, GL_FALSE, 0, shaderstate.sourcevbo->colours.gl.addr); + attr |= 1u<handle[perm]; + break; } - else if (shaderstate.curentity->model && shaderstate.curentity->model->engineflags & MDLF_NEEDOVERBRIGHT) + /* else if (shaderstate.sourcevbo->colours4ub) { - float sc = 1<shaderRGBAf, sc, colscale); + GL_SelectVBO(shaderstate.sourcevbo->colours.gl.vbo); + qglVertexAttribPointer(p->handle[perm], 4, GL_UNSIGNED_BYTE, GL_TRUE, sizeof(byte_vec4_t), shaderstate.sourcevbo->colours.gl.addr); + return 1u<handle[perm]; + }*/ + break; + case SP_ATTR_TEXCOORD: + GL_SelectVBO(shaderstate.sourcevbo->texcoord.gl.vbo); + qglVertexAttribPointer(p->handle[perm], 2, GL_FLOAT, GL_FALSE, sizeof(vec2_t), shaderstate.sourcevbo->texcoord.gl.addr); + attr |= 1u<handle[perm]; + break; + case SP_ATTR_LMCOORD: + GL_SelectVBO(shaderstate.sourcevbo->lmcoord.gl.vbo); + qglVertexAttribPointer(p->handle[perm], 2, GL_FLOAT, GL_FALSE, sizeof(vec2_t), shaderstate.sourcevbo->lmcoord.gl.addr); + attr |= 1u<handle[perm]; + break; + case SP_ATTR_NORMALS: + if (!shaderstate.sourcevbo->normals.gl.addr) + break; + GL_SelectVBO(shaderstate.sourcevbo->normals.gl.vbo); + qglVertexAttribPointer(p->handle[perm], 3, GL_FLOAT, GL_FALSE, sizeof(vec3_t), shaderstate.sourcevbo->normals.gl.addr); + attr |= 1u<handle[perm]; + break; + case SP_ATTR_SNORMALS: + if (!shaderstate.sourcevbo->svector.gl.addr) + break; + GL_SelectVBO(shaderstate.sourcevbo->svector.gl.vbo); + qglVertexAttribPointer(p->handle[perm], 3, GL_FLOAT, GL_FALSE, sizeof(vec3_t), shaderstate.sourcevbo->svector.gl.addr); + attr |= 1u<handle[perm]; + break; + case SP_ATTR_TNORMALS: + if (!shaderstate.sourcevbo->tvector.gl.addr) + break; + GL_SelectVBO(shaderstate.sourcevbo->tvector.gl.vbo); + qglVertexAttribPointer(p->handle[perm], 3, GL_FLOAT, GL_FALSE, sizeof(vec3_t), shaderstate.sourcevbo->tvector.gl.addr); + attr |= 1u<handle[perm]; + break; + case SP_ATTR_BONENUMS: + GL_SelectVBO(shaderstate.sourcevbo->bonenums.gl.vbo); + qglVertexAttribPointer(p->handle[perm], 4, GL_UNSIGNED_BYTE, GL_FALSE, sizeof(byte_vec4_t), shaderstate.sourcevbo->bonenums.gl.addr); + attr |= 1u<handle[perm]; + break; + case SP_ATTR_BONEWEIGHTS: + GL_SelectVBO(shaderstate.sourcevbo->boneweights.gl.vbo); + qglVertexAttribPointer(p->handle[perm], 4, GL_FLOAT, GL_FALSE, sizeof(vec4_t), shaderstate.sourcevbo->boneweights.gl.addr); + attr |= 1u<handle[perm]; + break; + + case SP_M_VIEW: + qglUniformMatrix4fvARB(p->handle[perm], 1, false, r_refdef.m_view); + break; + case SP_M_PROJECTION: + qglUniformMatrix4fvARB(p->handle[perm], 1, false, r_refdef.m_projection); + break; + case SP_M_MODELVIEW: + qglUniformMatrix4fvARB(p->handle[perm], 1, false, shaderstate.modelviewmatrix); + break; + case SP_M_MODELVIEWPROJECTION: + { + float m16[16]; + Matrix4_Multiply(r_refdef.m_projection, shaderstate.modelviewmatrix, m16); + qglUniformMatrix4fvARB(p->handle[perm], 1, false, m16); + } + break; + case SP_M_INVMODELVIEWPROJECTION: + { + float m16[16], inv[16]; + Matrix4_Multiply(r_refdef.m_projection, shaderstate.modelviewmatrix, m16); + Matrix4_Invert(m16, inv); + qglUniformMatrix4fvARB(p->handle[perm], 1, false, inv); + } + break; + case SP_M_MODEL: + qglUniformMatrix4fvARB(p->handle[perm], 1, false, shaderstate.modelmatrix); + break; + case SP_M_ENTBONES: + { + qglUniformMatrix3x4fv(p->handle[perm], shaderstate.sourcevbo->numbones, false, shaderstate.sourcevbo->bones); + } + break; + case SP_M_INVVIEWPROJECTION: + { + float m16[16], inv[16]; + Matrix4_Multiply(r_refdef.m_projection, r_refdef.m_view, m16); + Matrix4_Invert(m16, inv); + qglUniformMatrix4fvARB(p->handle[perm], 1, false, inv); + } + break; + + case SP_E_LMSCALE: + { + vec4_t colscale; + if (shaderstate.mode == BEM_DEPTHDARK) + { + VectorClear(colscale); + } + else if (shaderstate.curentity->model && shaderstate.curentity->model->engineflags & MDLF_NEEDOVERBRIGHT) + { + float sc = 1<shaderRGBAf, sc, colscale); + } + else + { + VectorCopy(shaderstate.curentity->shaderRGBAf, colscale); + } + colscale[3] = shaderstate.curentity->shaderRGBAf[3]; + + qglUniform4fvARB(p->handle[perm], 1, (GLfloat*)colscale); + } + break; + + case SP_E_GLOWMOD: + qglUniform3fvARB(p->handle[perm], 1, (GLfloat*)shaderstate.curentity->glowmod); + break; + case SP_E_ORIGIN: + qglUniform3fvARB(p->handle[perm], 1, (GLfloat*)shaderstate.curentity->origin); + break; + case SP_E_COLOURS: + qglUniform4fvARB(p->handle[perm], 1, (GLfloat*)shaderstate.curentity->shaderRGBAf); + break; + case SP_E_COLOURSIDENT: + if (shaderstate.flags & BEF_FORCECOLOURMOD) + qglUniform4fvARB(p->handle[perm], 1, (GLfloat*)shaderstate.curentity->shaderRGBAf); + else + qglUniform4fARB(p->handle[perm], 1, 1, 1, shaderstate.curentity->shaderRGBAf[3]); + break; + case SP_E_TOPCOLOURS: + R_FetchTopColour(&r, &g, &b); + param3[0] = r/255.0f; + param3[1] = g/255.0f; + param3[2] = b/255.0f; + qglUniform3fvARB(p->handle[perm], 1, param3); + break; + case SP_E_BOTTOMCOLOURS: + R_FetchBottomColour(&r, &g, &b); + param3[0] = r/255.0f; + param3[1] = g/255.0f; + param3[2] = b/255.0f; + qglUniform3fvARB(p->handle[perm], 1, param3); + break; + + case SP_RENDERTEXTURESCALE: + if (gl_config.arb_texture_non_power_of_two) + { + param3[0] = 1; + param3[1] = 1; } else { - VectorCopy(shaderstate.curentity->shaderRGBAf, colscale); - } - colscale[3] = shaderstate.curentity->shaderRGBAf[3]; - - qglUniform4fvARB(p->handle[perm], 1, (GLfloat*)colscale); - } - break; - - case SP_E_GLOWMOD: - qglUniform3fvARB(p->handle[perm], 1, (GLfloat*)shaderstate.curentity->glowmod); - break; - case SP_E_ORIGIN: - qglUniform3fvARB(p->handle[perm], 1, (GLfloat*)shaderstate.curentity->origin); - break; - case SP_E_COLOURS: - qglUniform4fvARB(p->handle[perm], 1, (GLfloat*)shaderstate.curentity->shaderRGBAf); - break; - case SP_E_COLOURSIDENT: - if (shaderstate.flags & BEF_FORCECOLOURMOD) - qglUniform4fvARB(p->handle[perm], 1, (GLfloat*)shaderstate.curentity->shaderRGBAf); - else - qglUniform4fARB(p->handle[perm], 1, 1, 1, shaderstate.curentity->shaderRGBAf[3]); - break; - case SP_E_TOPCOLOURS: - R_FetchTopColour(&r, &g, &b); - param3[0] = r/255.0f; - param3[1] = g/255.0f; - param3[2] = b/255.0f; - qglUniform3fvARB(p->handle[perm], 1, param3); - break; - case SP_E_BOTTOMCOLOURS: - R_FetchBottomColour(&r, &g, &b); - param3[0] = r/255.0f; - param3[1] = g/255.0f; - param3[2] = b/255.0f; - qglUniform3fvARB(p->handle[perm], 1, param3); - break; - - case SP_RENDERTEXTURESCALE: - if (gl_config.arb_texture_non_power_of_two) - { - param3[0] = 1; - param3[1] = 1; - } - else - { - r = 1; - g = 1; - while (r < vid.pixelwidth) - r *= 2; - while (g < vid.pixelheight) - g *= 2; - param3[0] = vid.pixelwidth/(float)r; - param3[1] = vid.pixelheight/(float)g; - } - param3[2] = 1; - qglUniform3fvARB(p->handle[perm], 1, param3); - break; - - case SP_LIGHTSCREEN: - { - float v[4], tempv[4]; - - v[0] = shaderstate.lightorg[0]; - v[1] = shaderstate.lightorg[1]; - v[2] = shaderstate.lightorg[2]; - v[3] = 1; - - Matrix4x4_CM_Transform4(shaderstate.modelviewmatrix, v, tempv); - Matrix4x4_CM_Transform4(r_refdef.m_projection, tempv, v); - - v[3] *= 2; - v[0] = (v[0]/v[3]) + 0.5; - v[1] = (v[1]/v[3]) + 0.5; - v[2] = (v[2]/v[3]) + 0.5; - - qglUniform3fvARB(p->handle[perm], 1, v); - } - break; - case SP_LIGHTRADIUS: - qglUniform1fARB(p->handle[perm], shaderstate.lightradius); - break; - case SP_LIGHTCOLOUR: - qglUniform3fvARB(p->handle[perm], 1, shaderstate.lightcolours); - break; - case SP_W_FOG: - qglUniform4fvARB(p->handle[perm], 1, r_refdef.gfog_rgbd); - break; - case SP_V_EYEPOS: - qglUniform3fvARB(p->handle[perm], 1, r_origin); - break; - case SP_E_EYEPOS: - { - /*eye position in model space*/ - vec3_t t2; - Matrix4x4_CM_Transform3(shaderstate.modelmatrixinv, r_origin, t2); - qglUniform3fvARB(p->handle[perm], 1, t2); - } - break; - case SP_LIGHTPOSITION: - { - /*light position in model space*/ - vec3_t t2; - Matrix4x4_CM_Transform3(shaderstate.modelmatrixinv, shaderstate.lightorg, t2); - qglUniform3fvARB(p->handle[perm], 1, t2); - } - break; - case SP_LIGHTCOLOURSCALE: - qglUniform3fvARB(p->handle[perm], 1, shaderstate.lightcolourscale); - break; - case SP_LIGHTPROJMATRIX: - /*light's texture projection matrix*/ - { - float t[16]; - Matrix4_Multiply(shaderstate.lightprojmatrix, shaderstate.modelmatrix, t); - qglUniformMatrix4fvARB(p->handle[perm], 1, false, t); - } - break; - - /*static lighting info*/ - case SP_E_L_DIR: - qglUniform3fvARB(p->handle[perm], 1, (float*)shaderstate.curentity->light_dir); - break; - case SP_E_L_MUL: - qglUniform3fvARB(p->handle[perm], 1, (float*)shaderstate.curentity->light_range); - break; - case SP_E_L_AMBIENT: - qglUniform3fvARB(p->handle[perm], 1, (float*)shaderstate.curentity->light_avg); - break; - - case SP_E_TIME: - qglUniform1fARB(p->handle[perm], shaderstate.curtime); - break; - case SP_CONSTI: - case SP_TEXTURE: - qglUniform1iARB(p->handle[perm], p->ival); - break; - case SP_CONSTF: - qglUniform1fARB(p->handle[perm], p->fval); - break; - case SP_CVARI: - qglUniform1iARB(p->handle[perm], ((cvar_t*)p->pval)->ival); - break; - case SP_CVARF: - qglUniform1fARB(p->handle[perm], ((cvar_t*)p->pval)->value); - break; - case SP_CVAR3F: - { - cvar_t *var = (cvar_t*)p->pval; - char *vs = var->string; - vs = COM_Parse(vs); - param3[0] = atof(com_token); - vs = COM_Parse(vs); - param3[1] = atof(com_token); - vs = COM_Parse(vs); - param3[2] = atof(com_token); + r = 1; + g = 1; + while (r < vid.pixelwidth) + r *= 2; + while (g < vid.pixelheight) + g *= 2; + param3[0] = vid.pixelwidth/(float)r; + param3[1] = vid.pixelheight/(float)g; + } + param3[2] = 1; qglUniform3fvARB(p->handle[perm], 1, param3); - } - break; + break; - default: - Host_EndGame("Bad shader program parameter type (%i)", p->type); - break; + case SP_LIGHTSCREEN: + { + float v[4], tempv[4]; + + v[0] = shaderstate.lightorg[0]; + v[1] = shaderstate.lightorg[1]; + v[2] = shaderstate.lightorg[2]; + v[3] = 1; + + Matrix4x4_CM_Transform4(shaderstate.modelviewmatrix, v, tempv); + Matrix4x4_CM_Transform4(r_refdef.m_projection, tempv, v); + + v[3] *= 2; + v[0] = (v[0]/v[3]) + 0.5; + v[1] = (v[1]/v[3]) + 0.5; + v[2] = (v[2]/v[3]) + 0.5; + + qglUniform3fvARB(p->handle[perm], 1, v); + } + break; + case SP_LIGHTRADIUS: + qglUniform1fARB(p->handle[perm], shaderstate.lightradius); + break; + case SP_LIGHTCOLOUR: + qglUniform3fvARB(p->handle[perm], 1, shaderstate.lightcolours); + break; + case SP_W_FOG: + qglUniform4fvARB(p->handle[perm], 1, r_refdef.gfog_rgbd); + break; + case SP_V_EYEPOS: + qglUniform3fvARB(p->handle[perm], 1, r_origin); + break; + case SP_E_EYEPOS: + { + /*eye position in model space*/ + vec3_t t2; + Matrix4x4_CM_Transform3(shaderstate.modelmatrixinv, r_origin, t2); + qglUniform3fvARB(p->handle[perm], 1, t2); + } + break; + case SP_LIGHTPOSITION: + { + /*light position in model space*/ + vec3_t t2; + Matrix4x4_CM_Transform3(shaderstate.modelmatrixinv, shaderstate.lightorg, t2); + qglUniform3fvARB(p->handle[perm], 1, t2); + } + break; + case SP_LIGHTCOLOURSCALE: + qglUniform3fvARB(p->handle[perm], 1, shaderstate.lightcolourscale); + break; + case SP_LIGHTPROJMATRIX: + /*light's texture projection matrix*/ + { + float t[16]; + Matrix4_Multiply(shaderstate.lightprojmatrix, shaderstate.modelmatrix, t); + qglUniformMatrix4fvARB(p->handle[perm], 1, false, t); + } + break; + + /*static lighting info*/ + case SP_E_L_DIR: + qglUniform3fvARB(p->handle[perm], 1, (float*)shaderstate.curentity->light_dir); + break; + case SP_E_L_MUL: + qglUniform3fvARB(p->handle[perm], 1, (float*)shaderstate.curentity->light_range); + break; + case SP_E_L_AMBIENT: + qglUniform3fvARB(p->handle[perm], 1, (float*)shaderstate.curentity->light_avg); + break; + + case SP_E_TIME: + qglUniform1fARB(p->handle[perm], shaderstate.curtime); + break; + case SP_CONSTI: + case SP_TEXTURE: + qglUniform1iARB(p->handle[perm], p->ival); + break; + case SP_CONSTF: + qglUniform1fARB(p->handle[perm], p->fval); + break; + case SP_CVARI: + qglUniform1iARB(p->handle[perm], ((cvar_t*)p->pval)->ival); + break; + case SP_CVARF: + qglUniform1fARB(p->handle[perm], ((cvar_t*)p->pval)->value); + break; + case SP_CVAR3F: + { + cvar_t *var = (cvar_t*)p->pval; + char *vs = var->string; + vs = COM_Parse(vs); + param3[0] = atof(com_token); + vs = COM_Parse(vs); + param3[1] = atof(com_token); + vs = COM_Parse(vs); + param3[2] = atof(com_token); + qglUniform3fvARB(p->handle[perm], 1, param3); + } + break; + + default: + Host_EndGame("Bad shader program parameter type (%i)", p->type); + break; + } } - return 0; + return attr; } static void BE_RenderMeshProgram(const shader_t *shader, const shaderpass_t *pass) @@ -2541,16 +2565,18 @@ static void BE_RenderMeshProgram(const shader_t *shader, const shaderpass_t *pas perm |= PERMUTATION_FOG; if (r_glsl_offsetmapping.ival && TEXVALID(shaderstate.curtexnums->bump) && p->handle[perm|PERMUTATION_OFFSET].glsl) perm |= PERMUTATION_OFFSET; + GL_SelectProgram(p->handle[perm].glsl); + if (shaderstate.lastuniform == p->handle[perm].glsl) + i = true; + else + { + i = false; + shaderstate.lastuniform = p->handle[perm].glsl; + } + attr = BE_Program_Set_Attributes(p, perm, i); BE_SendPassBlendDepthMask(pass->shaderbits); - - for (i = 0; i < p->numparams; i++) - { - if (p->parm[i].handle[perm] == -1) - continue; /*not in this permutation*/ - attr |= BE_Program_Set_Attribute(&p->parm[i], perm); - } if (p->nofixedcompat) { qglDisableClientState(GL_COLOR_ARRAY); @@ -2767,6 +2793,8 @@ void GLBE_SelectEntity(entity_t *ent) qglLoadMatrixf(shaderstate.modelviewmatrix); if (shaderstate.curentity->flags & Q2RF_DEPTHHACK && qglDepthRange) qglDepthRange (gldepthmin, gldepthmin + 0.3*(gldepthmax-gldepthmin)); + + shaderstate.lastuniform = 0; } void BE_SelectFog(vec3_t colour, float alpha, float density) @@ -2815,6 +2843,8 @@ void GLBE_SelectDLight(dlight_t *dl, vec3_t colour) #ifdef RTLIGHTS shaderstate.lightcubemap = dl->cubetexture; #endif + + shaderstate.lastuniform = 0; } void BE_PushOffsetShadow(qboolean pushdepth) diff --git a/engine/gl/gl_rmain.c b/engine/gl/gl_rmain.c index dd3a8be3d..370985d1d 100644 --- a/engine/gl/gl_rmain.c +++ b/engine/gl/gl_rmain.c @@ -462,12 +462,6 @@ void R_RenderScene (void) RQ_BeginFrame(); - if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL)) - { - TRACE(("dbg: calling R_DrawParticles\n")); - P_DrawParticles (); - } - if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL)) { TRACE(("dbg: calling R_DrawWorld\n")); diff --git a/engine/gl/gl_rmisc.c b/engine/gl/gl_rmisc.c index 2467b0d84..d18eb9db6 100644 --- a/engine/gl/gl_rmisc.c +++ b/engine/gl/gl_rmisc.c @@ -550,7 +550,7 @@ TRACE(("dbg: GLR_NewMap: tp\n")); void GLR_PreNewMap(void) { - r_loadbumpmapping = r_deluxemapping.ival || r_shadow_realtime_world.ival || r_shadow_realtime_dlight.ival; + r_loadbumpmapping = r_deluxemapping.ival || r_shadow_realtime_world.ival || r_shadow_realtime_dlight.ival || r_glsl_offsetmapping.ival; } diff --git a/engine/gl/gl_shader.c b/engine/gl/gl_shader.c index 77601d0b0..69c34ede2 100644 --- a/engine/gl/gl_shader.c +++ b/engine/gl/gl_shader.c @@ -2507,40 +2507,6 @@ static void Shader_ProgAutoFields(program_t *prog, char **cvarnames, int *cvarty if (gl_config.nofixedfunc) prog->nofixedcompat = true; - /*set cvar unirforms*/ - for (i = 0; cvarnames[i]; i++) - { - if (prog->numparams == SHADER_PROGPARMS_MAX) - { - Con_Printf("Too many cvar paramters for program\n"); - break; - } - for (p = 0; cvarnames[i][p] && (unsigned char)cvarnames[i][p] > 32 && p < sizeof(tmpname)-1; p++) - tmpname[p] = cvarnames[i][p]; - tmpname[p] = 0; - cvar = Cvar_Get(tmpname, "0", CVAR_SHADERSYSTEM, "glsl cvars"); - if (!cvar) - continue; - cvar->flags |= CVAR_SHADERSYSTEM; - prog->parm[prog->numparams].type = cvartypes[i]; - prog->parm[prog->numparams].pval = cvar; - found = false; - for (p = 0; p < PERMUTATIONS; p++) - { - if (!prog->handle[p].glsl) - continue; - GL_SelectProgram(prog->handle[p].glsl); - uniformloc = qglGetUniformLocationARB(prog->handle[p].glsl, va("cvar_%s", tmpname)); - if (uniformloc != -1) - { - qglUniform1fARB(uniformloc, cvar->value); - found = true; - } - prog->parm[prog->numparams].handle[p] = uniformloc; - } - if (found) - prog->numparams++; - } for (i = 0; shader_field_names[i].name; i++) { found = false; @@ -2577,6 +2543,40 @@ static void Shader_ProgAutoFields(program_t *prog, char **cvarnames, int *cvarty } } } + /*set cvar unirforms*/ + for (i = 0; cvarnames[i]; i++) + { + if (prog->numparams == SHADER_PROGPARMS_MAX) + { + Con_Printf("Too many cvar paramters for program\n"); + break; + } + for (p = 0; cvarnames[i][p] && (unsigned char)cvarnames[i][p] > 32 && p < sizeof(tmpname)-1; p++) + tmpname[p] = cvarnames[i][p]; + tmpname[p] = 0; + cvar = Cvar_Get(tmpname, "0", CVAR_SHADERSYSTEM, "glsl cvars"); + if (!cvar) + continue; + cvar->flags |= CVAR_SHADERSYSTEM; + prog->parm[prog->numparams].type = cvartypes[i]; + prog->parm[prog->numparams].pval = cvar; + found = false; + for (p = 0; p < PERMUTATIONS; p++) + { + if (!prog->handle[p].glsl) + continue; + GL_SelectProgram(prog->handle[p].glsl); + uniformloc = qglGetUniformLocationARB(prog->handle[p].glsl, va("cvar_%s", tmpname)); + if (uniformloc != -1) + { + qglUniform1fARB(uniformloc, cvar->value); + found = true; + } + prog->parm[prog->numparams].handle[p] = uniformloc; + } + if (found) + prog->numparams++; + } /*set texture uniforms*/ for (p = 0; p < PERMUTATIONS; p++) { diff --git a/engine/gl/shader.h b/engine/gl/shader.h index 40749b342..5b8c13e45 100644 --- a/engine/gl/shader.h +++ b/engine/gl/shader.h @@ -492,7 +492,7 @@ qboolean D3DBE_LightCullModel(vec3_t org, model_t *model); void D3DBE_SelectEntity(entity_t *ent); void D3DBE_SelectDLight(dlight_t *dl, vec3_t colour); -void D3DShader_CreateProgram (program_t *prog, int permu, char **precompilerconstants, char *vert, char *frag); +qboolean D3DShader_CreateProgram (program_t *prog, int permu, char **precompilerconstants, char *vert, char *frag); int D3DShader_FindUniform(union programhandle_u *h, int type, char *name); void D3DShader_Init(void); void D3DBE_Reset(qboolean before); diff --git a/engine/http/iweb.h b/engine/http/iweb.h index 6d29c5f4a..322ef8a26 100644 --- a/engine/http/iweb.h +++ b/engine/http/iweb.h @@ -5,10 +5,10 @@ #ifdef WEBSVONLY -typedef unsigned char qbyte; -#include -#include -#include +#include "quakedef.h" +#ifdef _WIN32 +#include "winquake.h" +#endif #define Con_TPrintf IWebPrintf #define TL_NETBINDINTERFACE "binding to %s" @@ -24,12 +24,6 @@ typedef unsigned char qbyte; #define IWebFree free #endif -#include "quakedef.h" - -#ifdef _WIN32 -#include "winquake.h" -#endif - #define IWEBACC_READ 1 #define IWEBACC_WRITE 2 #define IWEBACC_FULL 4 diff --git a/engine/http/iwebiface.c b/engine/http/iwebiface.c index 167838d78..63b8d0f58 100644 --- a/engine/http/iwebiface.c +++ b/engine/http/iwebiface.c @@ -1,11 +1,5 @@ #include "quakedef.h" -#ifdef WEBSVONLY - #define WEBSERVER -#else - #include "bothdefs.h" -#endif - #ifdef WEBSERVER #include "iweb.h" @@ -102,7 +96,7 @@ int main(int argc, char **argv) while(1) { - FTP_ServerRun(1, 21); +// FTP_ServerRun(1, 21); HTTP_ServerPoll(1, 80); Sleep(1); } diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 18584eda9..eb1ba8769 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -2159,8 +2159,11 @@ static void QCBUILTIN PF_setsize (progfuncs_t *prinst, struct globalvars_s *pr_g e = G_EDICT(prinst, OFS_PARM0); if (e->isfree) { - Con_TPrintf(STL_EDICTWASFREE, "setsize"); - (*prinst->pr_trace) = 1; + if (progstype != PROG_H2) + { + Con_TPrintf(STL_EDICTWASFREE, "setsize"); + (*prinst->pr_trace) = 1; + } return; } min = G_VECTOR(OFS_PARM1); diff --git a/engine/server/savegame.c b/engine/server/savegame.c index 91f60fd3d..609eaf597 100644 --- a/engine/server/savegame.c +++ b/engine/server/savegame.c @@ -766,9 +766,6 @@ qboolean SV_LoadLevelCache(char *savename, char *level, char *startspot, qboolea pr_global_struct->time = 0.1; pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, ent); f = PR_FindFunction(svprogfuncs, PR_GetString(svprogfuncs, ent->v->classname), PR_ANY); - - svprogfuncs->ToggleBreak(svprogfuncs, PR_GetString(svprogfuncs, ent->v->classname), 0, 1); - svprogfuncs->ToggleBreak(svprogfuncs, "trigger_crosslevel_target_think", 0, 1); if (f) PR_ExecuteProgram(svprogfuncs, f); diff --git a/engine/server/sv_sys_unix.c b/engine/server/sv_sys_unix.c index 4aeb9bca8..193e2c7f7 100644 --- a/engine/server/sv_sys_unix.c +++ b/engine/server/sv_sys_unix.c @@ -700,7 +700,7 @@ int main(int argc, char *argv[]) } #endif - parms.memsize = 16*1024*1024; + parms.memsize = 64*1024*1024; j = COM_CheckParm("-mem"); if (j)