From 9b6ea1c114c7df51214ca7a76fef5fea787ddf69 Mon Sep 17 00:00:00 2001 From: Spoike Date: Tue, 4 Jan 2011 02:56:16 +0000 Subject: [PATCH] Fix for recent timing issues, hopefully. Fixed a couple of warnings. Added voip options to menus. GL+D3D merged builds compile, but d3d is probably broken still. Added vid_gl_context_es2 cvar to attempt to init a gles context. Note that you also need to set the requested gl version correctly. Changed qtv's webpage view slightly, for slightly updated npfte usage. git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3714 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_main.c | 28 +++--- engine/client/cl_tent.c | 1 - engine/client/cl_ui.c | 4 - engine/client/m_options.c | 5 ++ engine/client/menu.c | 6 ++ engine/client/merged.h | 44 ++++++++- engine/client/render.h | 21 +++-- engine/client/renderer.c | 24 +++-- engine/client/snd_directx.c | 4 +- engine/client/snd_dma.c | 2 +- engine/common/com_mesh.c | 4 +- engine/common/common.c | 2 +- engine/common/netinc.h | 3 +- engine/d3d/d3d_backend.c | 34 +++---- engine/d3d/d3d_image.c | 4 + engine/d3d/vid_d3d.c | 16 ++-- engine/gl/gl_backend.c | 34 +++---- engine/gl/gl_model.c | 2 +- engine/gl/gl_rmain.c | 8 +- engine/gl/gl_rsurf.c | 6 +- engine/gl/gl_vidcommon.c | 28 ++++++ engine/gl/gl_vidnt.c | 41 +++++++-- engine/gl/gl_warp.c | 19 ++-- engine/gl/gltod3d/gl_fakegl.cpp | 154 +++++++++++++++++--------------- engine/gl/shader.h | 56 ++++++------ engine/server/sv_main.c | 11 ++- engine/server/sv_user.c | 3 +- fteqtv/forward.c | 43 ++++++--- fteqtv/httpsv.c | 89 +++++++++++++++--- fteqtv/qtv.h | 2 + fteqtv/qw.c | 2 +- fteqtv/rcon.c | 57 +++++++++++- 32 files changed, 524 insertions(+), 233 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 626d6dfc..420cb6da 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -3319,6 +3319,8 @@ float Host_Frame (double time) // float fps; double realframetime; static double spare; + float maxfps; + qboolean maxfpsignoreserver; RSpeedLocals(); @@ -3371,23 +3373,25 @@ float Host_Frame (double time) */ Mod_Think(); //think even on idle (which means small walls and a fast cpu can get more surfaces done. + if ((cl_netfps.value>0 || cls.demoplayback || cl_indepphysics.ival)) { //limit the fps freely, and expect the netfps to cope. - if (cl_maxfps.ival > 0) - { - realtime += spare/1000; //don't use it all! - spare = CL_FilterTime((realtime - oldrealtime)*1000, cl_maxfps.value, true); - if (!spare) - return 1; - - realtime -= spare/1000; //don't use it all! - } + maxfpsignoreserver = true; + maxfps = cl_maxfps.ival; } else { - float maxfps = (cl_maxfps.ival>0||cls.protocol!=CP_QUAKEWORLD)?cl_maxfps.value:cl_netfps.value; + maxfpsignoreserver = false; + maxfps = (cl_maxfps.ival>0||cls.protocol!=CP_QUAKEWORLD)?cl_maxfps.value:cl_netfps.value; + /*gets buggy at times longer than 250ms (and 0/negative, obviously)*/ + if (maxfps < 4) + maxfps = 4; + } + + if (maxfps > 0) + { realtime += spare/1000; //don't use it all! - spare = CL_FilterTime((realtime - oldrealtime)*1000, maxfps, false); + spare = CL_FilterTime((realtime - oldrealtime)*1000, maxfps, maxfpsignoreserver); if (!spare) return 1; if (spare < 0 || cls.state < ca_onserver) @@ -3397,6 +3401,8 @@ float Host_Frame (double time) realtime -= spare/1000; //don't use it all! } + else + spare = 0; host_frametime = (realtime - oldrealtime)*cl.gamespeed; if (!cl.paused) diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index ba658f52..86acdfb2 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -349,7 +349,6 @@ void CL_ShutdownTEnts (void) void P_LoadedModel(model_t *mod) { struct associatedeffect *ae; - int j; mod->particleeffect = P_INVALID; mod->particletrail = P_INVALID; diff --git a/engine/client/cl_ui.c b/engine/client/cl_ui.c index 71c9f841..c8fcfea9 100644 --- a/engine/client/cl_ui.c +++ b/engine/client/cl_ui.c @@ -620,10 +620,6 @@ void VQ3_RenderView(const q3refdef_t *ref) qglEnable(GL_BLEND); } #endif -#ifdef D3DQUAKE - if (qrenderer == QR_DIRECT3D) - D3D9_Set2D(); -#endif vid.recalc_refdef = 1; r_refdef.time = 0; diff --git a/engine/client/m_options.c b/engine/client/m_options.c index d709e2bf..6c6f44c8 100644 --- a/engine/client/m_options.c +++ b/engine/client/m_options.c @@ -261,6 +261,7 @@ void M_Menu_Audio_f (void) menu_t *menu; int cursorpositionY; extern cvar_t nosound, precache, snd_leftisright, snd_khz, snd_eax, snd_speakers, ambient_level, bgmvolume, snd_playersoundvolume, ambient_fade, cl_staticsounds, snd_inactive, _snd_mixahead, snd_usemultipledevices, snd_noextraupdate, snd_show, bgmbuffer; + extern cvar_t cl_voip_play, cl_voip_send; static const char *soundqualityoptions[] = { "11025 Hz", @@ -303,6 +304,10 @@ void M_Menu_Audio_f (void) MC_AddWhiteText(menu, 16, y, " ", false); y+=8; y+=8; +#ifdef VOICECHAT + MC_AddCheckBox(menu, 16, y, " Voice Chat", &cl_voip_play,0);y+=8; + MC_AddCheckBox(menu, 16, y, " VOIP Voice Activation", &cl_voip_send,0);y+=8; +#endif MC_AddSlider(menu, 16, y, " CD Music Volume", &bgmvolume, 0, 1, 0.1);y+=8; MC_AddSlider(menu, 16, y, " CD Music Buffer", &bgmbuffer, 0, 10240, 1024);y+=8; MC_AddSlider(menu, 16, y, " Sound Volume", &volume, 0, 1, 0.1);y+=8; diff --git a/engine/client/menu.c b/engine/client/menu.c index e1759719..773ba598 100644 --- a/engine/client/menu.c +++ b/engine/client/menu.c @@ -271,6 +271,9 @@ bindnames_t qwbindnames[] = {"+klook", "keyboard look "}, {"+moveup", "swim up "}, {"+movedown", "swim down "}, +#ifdef VOICECHAT +{"+voip", "voice chat "}, +#endif {NULL} }; @@ -352,6 +355,9 @@ bindnames_t h2bindnames[] = {"impulse 112", "inv:flight "}, {"impulse 113", "inv:force cube"}, {"impulse 114", "inv:icon defn "}, +#ifdef VOICECHAT +{"+voip", "voice chat "}, +#endif {NULL} }; diff --git a/engine/client/merged.h b/engine/client/merged.h index 2f8b1fd6..10f14982 100644 --- a/engine/client/merged.h +++ b/engine/client/merged.h @@ -155,7 +155,8 @@ typedef union { void *ptr; #endif } texid_t; -enum uploadfmt; +typedef enum uploadfmt uploadfmt_t; +typedef enum backendmode_e backendmode_t; typedef struct rendererinfo_s { char *description; @@ -182,13 +183,13 @@ typedef struct rendererinfo_s { void (*Draw_Image) (float x, float y, float w, float h, float s1, float t1, float s2, float t2, mpic_t *pic); //gl-style scaled/coloured/subpic void (*Draw_ImageColours) (float r, float g, float b, float a); - texid_t (*IMG_LoadTexture) (char *identifier, int width, int height, enum uploadfmt fmt, void *data, unsigned int flags); + texid_t (*IMG_LoadTexture) (char *identifier, int width, int height, uploadfmt_t fmt, void *data, unsigned int flags); texid_t (*IMG_LoadTexture8Pal24) (char *identifier, int width, int height, qbyte *data, qbyte *palette24, unsigned int flags); texid_t (*IMG_LoadTexture8Pal32) (char *identifier, int width, int height, qbyte *data, qbyte *palette32, unsigned int flags); texid_t (*IMG_LoadCompressed) (char *name); texid_t (*IMG_FindTexture) (char *identifier); texid_t (*IMG_AllocNewTexture) (int w, int h); - void (*IMG_Upload) (texid_t tex, char *name, enum uploadfmt fmt, void *data, void *palette, int width, int height, unsigned int flags); + void (*IMG_Upload) (texid_t tex, char *name, uploadfmt_t fmt, void *data, void *palette, int width, int height, unsigned int flags); void (*IMG_DestroyTexture) (texid_t tex); void (*R_Init) (void); @@ -227,6 +228,29 @@ typedef struct rendererinfo_s { void (*SCR_UpdateScreen) (void); + + //Select the current render mode and modifier flags + void (*BE_SelectMode)(backendmode_t mode, unsigned int flags); + /*Draws an entire mesh list from a VBO. vbo can be null, in which case the chain may be drawn without batching. + Rules for using a list: Every mesh must be part of the same VBO, shader, lightmap, and must have the same pointers set*/ + void (*BE_DrawMesh_List)(shader_t *shader, int nummeshes, struct mesh_s **mesh, struct vbo_s *vbo, struct texnums_s *texnums); + void (*BE_DrawMesh_Single)(shader_t *shader, struct mesh_s *meshchain, struct vbo_s *vbo, struct texnums_s *texnums); + void (*BE_SubmitBatch)(struct batch_s *batch); + struct batch_s *(*BE_GetTempBatch)(void); + //Asks the backend to invoke DrawMeshChain for each surface, and to upload lightmaps as required + void (*BE_DrawWorld) (qbyte *vis); + //called at init, force the display to the right defaults etc + void (*BE_Init)(void); + //Generates an optimised VBO, one for each texture on the map + void (*BE_GenBrushModelVBO)(struct model_s *mod); + //Destroys the given vbo + void (*BE_ClearVBO)(struct vbo_s *vbo); + //Uploads all modified lightmaps + void (*BE_UploadAllLightmaps)(void); + void (*BE_SelectEntity)(struct entity_s *ent); + /*check to see if an ent should be drawn for the selected light*/ + qboolean (*BE_LightCullModel)(vec3_t org, struct model_s *model); + char *alignment; } rendererinfo_t; @@ -240,3 +264,17 @@ typedef struct rendererinfo_s { #define R_AllocNewTexture rf->IMG_AllocNewTexture #define R_Upload rf->IMG_Upload #define R_DestroyTexture rf->IMG_DestroyTexture + +#define BE_Init rf->BE_Init +#define BE_SelectMode rf->BE_SelectMode +#define BE_GenBrushModelVBO rf->BE_GenBrushModelVBO +#define BE_ClearVBO rf->BE_ClearVBO +#define BE_UploadAllLightmaps rf->BE_UploadAllLightmaps +#define BE_LightCullModel rf->BE_LightCullModel +#define BE_SelectEntity rf->BE_SelectEntity +#define BE_GetTempBatch rf->BE_GetTempBatch +#define BE_SubmitBatch rf->BE_SubmitBatch +#define BE_DrawMesh_List rf->BE_DrawMesh_List +#define BE_DrawMesh_Single rf->BE_DrawMesh_Single +#define BE_SubimtMeshes rf->BE_SubimtMeshes +#define BE_DrawWorld rf->BE_DrawWorld \ No newline at end of file diff --git a/engine/client/render.h b/engine/client/render.h index 81cd91e7..1915be4a 100644 --- a/engine/client/render.h +++ b/engine/client/render.h @@ -165,7 +165,7 @@ void R_LightArraysByte_BGR(vecV_t *coords, byte_vec4_t *colours, int vertcount, void R_LightArrays(vecV_t *coords, vec4_t *colours, int vertcount, vec3_t *normals); void R_DrawSkyChain (struct batch_s *batch); /*called from the backend, and calls back into it*/ -struct texnums_s R_InitSky (struct texture_s *mt, qbyte *src); /*generate q1 sky texnums*/ +void R_InitSky (struct texnums_s *ret, struct texture_s *mt, qbyte *src); /*generate q1 sky texnums*/ //r_surf.c void Surf_DrawWorld(void); @@ -219,7 +219,7 @@ void GLR_InitTextures (void); void GLR_InitEfrags (void); void GLR_RenderView (void); // must set r_refdef first // called whenever r_refdef or vid change -void R_DrawPortal(struct batch_s *batch, struct batch_s **blist); +void GLR_DrawPortal(struct batch_s *batch, struct batch_s **blist); void GLR_PreNewMap(void); void GLR_NewMap (void); @@ -288,15 +288,14 @@ texid_t GL_LoadTextureFmt (char *identifier, int width, int height, enum uploadf void GL_DestroyTexture(texid_t tex); #endif #ifdef D3DQUAKE -texid_t D3D_AllocNewTexture(int width, int height); -void D3D_UploadFmt(texid_t tex, char *name, enum uploadfmt fmt, void *data, int width, int height, unsigned int flags); -texid_t D3D_LoadTextureFmt (char *identifier, int width, int height, enum uploadfmt fmt, void *data, unsigned int flags); - -texid_t D3D_LoadCompressed(char *name); -texid_t D3D_FindTexture (char *identifier); - -texid_t D3D_LoadTexture8Pal32 (char *identifier, int width, int height, qbyte *data, qbyte *palette32, unsigned int flags); -texid_t D3D_LoadTexture8Pal24 (char *identifier, int width, int height, qbyte *data, qbyte *palette24, unsigned int flags); +texid_t D3D9_LoadTexture (char *identifier, int width, int height, enum uploadfmt fmt, void *data, unsigned int flags); +texid_t D3D9_LoadTexture8Pal24 (char *identifier, int width, int height, qbyte *data, qbyte *palette24, unsigned int flags); +texid_t D3D9_LoadTexture8Pal32 (char *identifier, int width, int height, qbyte *data, qbyte *palette32, unsigned int flags); +texid_t D3D9_LoadCompressed (char *name); +texid_t D3D9_FindTexture (char *identifier); +texid_t D3D9_AllocNewTexture(int width, int height); +void D3D9_Upload (texid_t tex, char *name, enum uploadfmt fmt, void *data, void *palette, int width, int height, unsigned int flags); +void D3D9_DestroyTexture (texid_t tex); #endif extern int image_width, image_height; diff --git a/engine/client/renderer.c b/engine/client/renderer.c index b94adbe2..a81e1e4a 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -237,6 +237,7 @@ cvar_t vid_gl_context_version = SCVAR ("vid_gl_context_version", ""); cvar_t vid_gl_context_forwardcompatible = SCVAR ("vid_gl_context_forwardcompatible", "0"); cvar_t vid_gl_context_compatibility = SCVAR ("vid_gl_context_compatibility", "1"); cvar_t vid_gl_context_debug = SCVAR ("vid_gl_context_debug", "0"); //for my ati drivers, debug 1 only works if version >= 3 +cvar_t vid_gl_context_es2 = SCVAR ("vid_gl_context_es2", "0"); //requires version set correctly, no debug, no compat #endif #if defined(GLQUAKE) || defined(D3DQUAKE) @@ -359,6 +360,7 @@ void GLRenderer_Init(void) Cvar_Register (&vid_gl_context_debug, GLRENDEREROPTIONS); Cvar_Register (&vid_gl_context_forwardcompatible, GLRENDEREROPTIONS); Cvar_Register (&vid_gl_context_compatibility, GLRENDEREROPTIONS); + Cvar_Register (&vid_gl_context_es2, GLRENDEREROPTIONS); //screen Cvar_Register (&gl_triplebuffer, GLRENDEREROPTIONS); @@ -827,14 +829,28 @@ rendererinfo_t dedicatedrendererinfo = { NULL, //SCR_UpdateScreen; + /*backend*/ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "" }; rendererinfo_t *pdedicatedrendererinfo = &dedicatedrendererinfo; rendererinfo_t openglrendererinfo; +rendererinfo_t d3dfglrendererinfo; + rendererinfo_t d3drendererinfo; -rendererinfo_t d3d7rendererinfo; -rendererinfo_t d3d9rendererinfo; rendererinfo_t *rendererinfo[] = { @@ -843,12 +859,10 @@ rendererinfo_t *rendererinfo[] = #endif #ifdef GLQUAKE &openglrendererinfo, - &d3drendererinfo, + &d3dfglrendererinfo, #endif #ifdef D3DQUAKE &d3drendererinfo, - &d3d7rendererinfo, - &d3d9rendererinfo, #endif }; diff --git a/engine/client/snd_directx.c b/engine/client/snd_directx.c index fbb7b506..765a48c8 100644 --- a/engine/client/snd_directx.c +++ b/engine/client/snd_directx.c @@ -21,7 +21,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "winquake.h" #include - +#ifndef DECLSPEC_SELECTANY +#define DECLSPEC_SELECTANY +#endif #define FORCE_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ EXTERN_C const GUID DECLSPEC_SELECTANY name \ = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index 0a2c4992..cc600909 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -112,7 +112,7 @@ cvar_t cl_voip_send = CVARD("cl_voip_send", "0", "Sends voice-over-ip data to th cvar_t cl_voip_vad_threshhold = CVARD("cl_voip_vad_threshhold", "15", "This is the threshhold for voice-activation-detection when sending voip data"); cvar_t cl_voip_vad_delay = CVARD("cl_voip_vad_delay", "0.3", "Keeps sending voice data for this many seconds after voice activation would normally stop"); cvar_t cl_voip_capturingvol = CVARD("cl_voip_capturingvol", "0.5", "Volume multiplier applied while capturing, to avoid your audio from being heard by others"); -cvar_t cl_voip_showmeter = CVARD("cl_voip_showmeter", "1", "Shows your speach volume above the hud. 0=hide, 1=show when transmitting, 2=ignore voice-activation disable"); +cvar_t cl_voip_showmeter = CVARD("cl_voip_showmeter", "1", "Shows your speech volume above the hud. 0=hide, 1=show when transmitting, 2=ignore voice-activation disable"); cvar_t cl_voip_play = CVARCD("cl_voip_play", "1", S_Voip_Play_Callback, "Enables voip playback."); cvar_t cl_voip_micamp = CVARD("cl_voip_micamp", "2", "Amplifies your microphone when using voip."); diff --git a/engine/common/com_mesh.c b/engine/common/com_mesh.c index 41c36111..d5ee29df 100644 --- a/engine/common/com_mesh.c +++ b/engine/common/com_mesh.c @@ -1500,7 +1500,7 @@ static void Mod_ClampModelSize(model_t *mod) } #ifdef GLQUAKE -static int R_FindTriangleWithEdge ( int *indexes, int numtris, int start, int end, int ignore) +static int R_FindTriangleWithEdge (index_t *indexes, int numtris, int start, int end, int ignore) { int i; int match, count; @@ -1532,7 +1532,7 @@ static int R_FindTriangleWithEdge ( int *indexes, int numtris, int start, int en static void Mod_BuildTriangleNeighbours ( int *neighbours, index_t *indexes, int numtris ) { int i, *n; - int *index; + index_t *index; for (i = 0, index = indexes, n = neighbours; i < numtris; i++, index += 3, n += 3) { diff --git a/engine/common/common.c b/engine/common/common.c index ba87aadf..5397d56b 100644 --- a/engine/common/common.c +++ b/engine/common/common.c @@ -3118,7 +3118,7 @@ void COM_Version_f (void) #endif // Don't print both as a 64bit MinGW built client -#ifdef __MINGW32__ && !defined(__MINGW64__) +#if defined(__MINGW32__) && !defined(__MINGW64__) Con_Printf("Compiled with MinGW32 version: %i.%i\n",__MINGW32_MAJOR_VERSION, __MINGW32_MINOR_VERSION); #endif diff --git a/engine/common/netinc.h b/engine/common/netinc.h index 463f8d1e..3f8503e9 100644 --- a/engine/common/netinc.h +++ b/engine/common/netinc.h @@ -36,7 +36,7 @@ { u_char s6_addr[16]; /* IPv6 address */ }; -#if _MSC_VER > 1200 + #define sockaddr_in6 sockaddr_in6_fixed /*earlier versions of msvc have a sockaddr_in6 which does _not_ match windows, so this *must* be redefined for any non-final msvc releases or it won't work at all*/ typedef struct sockaddr_in6 { short sin6_family; @@ -49,7 +49,6 @@ struct ip6_scope_id sin6_scope_struct; }; }; -#endif struct addrinfo { int ai_flags; diff --git a/engine/d3d/d3d_backend.c b/engine/d3d/d3d_backend.c index d55ddf1c..397f9f3c 100644 --- a/engine/d3d/d3d_backend.c +++ b/engine/d3d/d3d_backend.c @@ -1,13 +1,15 @@ #include "quakedef.h" #ifdef D3DQUAKE #include "shader.h" +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); +#endif #include -#ifndef GLQUAKE /*shaders have a few GL_FOO constants in them. they shouldn't, but they do.*/ #include #include "glsupp.h" -#endif extern LPDIRECT3DDEVICE9 pD3DDev9; @@ -178,7 +180,7 @@ enum IDirect3DVertexDeclaration9 *vertexdecls[D3D_VDEC_MAX]; -void BE_D3D_Reset(qboolean before) +void D3DBE_Reset(qboolean before) { int i, tmu; if (before) @@ -461,7 +463,7 @@ static void D3DBE_ApplyShaderBits(unsigned int bits) } } -void BE_Init(void) +void D3DBE_Init(void) { unsigned int i; be_maxpasses = MAX_TMUS; @@ -475,7 +477,7 @@ void BE_Init(void) shaderstate.dynst_size = sizeof(vec2_t) * DYNVBUFFSIZE; shaderstate.dynidx_size = sizeof(index_t) * DYNIBUFFSIZE; - BE_D3D_Reset(false); + D3DBE_Reset(false); /*force all state to change, thus setting a known state*/ shaderstate.shaderbits = ~0; @@ -1578,16 +1580,14 @@ static void BE_DrawMeshChain_Internal(void) } } -void BE_SelectMode(backendmode_t mode, unsigned int flags) +void D3DBE_SelectMode(backendmode_t mode, unsigned int flags) { shaderstate.mode = mode; shaderstate.flags = flags; } -void _CrtCheckMemory(void); - /*Generates an optimised vbo for each of the given model's textures*/ -void BE_GenBrushModelVBO(model_t *mod) +void D3DBE_GenBrushModelVBO(model_t *mod) { unsigned int maxvboverts; unsigned int maxvboelements; @@ -1737,7 +1737,7 @@ void BE_GenBrushModelVBO(model_t *mod) //} } /*Wipes a vbo*/ -void BE_ClearVBO(vbo_t *vbo) +void D3DBE_ClearVBO(vbo_t *vbo) { } @@ -1791,12 +1791,12 @@ void BE_UploadLightmaps(qboolean force) } } -void BE_UploadAllLightmaps(void) +void D3DBE_UploadAllLightmaps(void) { BE_UploadLightmaps(true); } -qboolean BE_LightCullModel(vec3_t org, model_t *model) +qboolean D3DBE_LightCullModel(vec3_t org, model_t *model) { #ifdef RTLIGHTS if ((shaderstate.mode == BEM_LIGHT || shaderstate.mode == BEM_STENCIL)) @@ -1808,7 +1808,7 @@ qboolean BE_LightCullModel(vec3_t org, model_t *model) return false; } -batch_t *BE_GetTempBatch(void) +batch_t *D3DBE_GetTempBatch(void) { if (shaderstate.wbatch >= shaderstate.maxwbatches) { @@ -1925,7 +1925,7 @@ static void BE_RotateForEntity (const entity_t *e, const model_t *mod) } } -void BE_SubmitBatch(batch_t *batch) +void D3DBE_SubmitBatch(batch_t *batch) { shaderstate.nummeshes = batch->meshes - batch->firstmesh; if (!shaderstate.nummeshes) @@ -1947,7 +1947,7 @@ void BE_SubmitBatch(batch_t *batch) BE_DrawMeshChain_Internal(); } -void BE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **meshlist, vbo_t *vbo, texnums_t *texnums) +void D3DBE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **meshlist, vbo_t *vbo, texnums_t *texnums) { shaderstate.curshader = shader; shaderstate.curtexnums = texnums; @@ -1958,7 +1958,7 @@ void BE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **meshlist, vbo_t BE_DrawMeshChain_Internal(); } -void BE_DrawMesh_Single(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, texnums_t *texnums) +void D3DBE_DrawMesh_Single(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, texnums_t *texnums) { shaderstate.curtime = realtime; shaderstate.curshader = shader; @@ -2510,7 +2510,7 @@ void BE_SubmitMeshes (qboolean drawworld, batch_t **blist) } } -void BE_DrawWorld (qbyte *vis) +void D3DBE_DrawWorld (qbyte *vis) { batch_t *batches[SHADER_SORT_COUNT]; RSpeedLocals(); diff --git a/engine/d3d/d3d_image.c b/engine/d3d/d3d_image.c index 80cabc99..3020c284 100644 --- a/engine/d3d/d3d_image.c +++ b/engine/d3d/d3d_image.c @@ -1,5 +1,9 @@ #include "quakedef.h" #ifdef D3DQUAKE +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); +#endif #include LPDIRECT3DDEVICE9 pD3DDev9; diff --git a/engine/d3d/vid_d3d.c b/engine/d3d/vid_d3d.c index 34b6389f..914199d8 100644 --- a/engine/d3d/vid_d3d.c +++ b/engine/d3d/vid_d3d.c @@ -5,9 +5,13 @@ #ifdef D3DQUAKE #include "winquake.h" -#include "d3d9quake.h" -#include "d3d9.h" +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); +#endif + +#include //#pragma comment(lib, "../libs/dxsdk9/lib/d3d9.lib") @@ -350,11 +354,11 @@ static LRESULT WINAPI D3D9_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA //vid.pixelheight = window_rect.bottom - window_rect.top; D3DVID_UpdateWindowStatus(hWnd); - BE_D3D_Reset(true); + D3DBE_Reset(true); vid.pixelwidth = d3dpp.BackBufferWidth = window_rect.right - window_rect.left; vid.pixelheight = d3dpp.BackBufferHeight = window_rect.bottom - window_rect.top; resetD3D9(); - BE_D3D_Reset(false); + D3DBE_Reset(false); Cvar_ForceCallback(&vid_conautoscale); Cvar_ForceCallback(&vid_conwidth); @@ -836,7 +840,7 @@ static void (D3D9_SCR_UpdateScreen) (void) //the user has task switched away from us or something, don't do anything. return; case D3DERR_DEVICENOTRESET: - BE_D3D_Reset(true); + D3DBE_Reset(true); resetD3D9(); if (FAILED(IDirect3DDevice9_TestCooperativeLevel(pD3DDev9))) { @@ -844,7 +848,7 @@ static void (D3D9_SCR_UpdateScreen) (void) Cmd_ExecuteString("vid_restart", RESTRICT_LOCAL); return; } - BE_D3D_Reset(false); + D3DBE_Reset(false); VID_ShiftPalette (NULL); break; diff --git a/engine/gl/gl_backend.c b/engine/gl/gl_backend.c index 444b37dd..52948a07 100644 --- a/engine/gl/gl_backend.c +++ b/engine/gl/gl_backend.c @@ -320,14 +320,14 @@ static const char PCFPASS_SHADER[] = "\ extern cvar_t r_glsl_offsetmapping, r_noportals; -#if 0//def _DEBUG +#ifdef _DEBUG #define checkerror() if (qglGetError()) Con_Printf("Error detected at line %s:%i\n", __FILE__, __LINE__) #else #define checkerror() #endif static void BE_SendPassBlendAndDepth(unsigned int sbits); -void BE_SubmitBatch(batch_t *batch); +void GLBE_SubmitBatch(batch_t *batch); struct { //internal state @@ -840,11 +840,13 @@ void Shader_LightPass_Spot(char *shortname, shader_t *s, const void *args) Shader_DefaultScript(shortname, s, shadertext); } -void BE_Init(void) +void GLBE_Init(void) { int i; double t; + checkerror(); + be_maxpasses = gl_mtexarbable; for (i = 0; i < FTABLE_SIZE; i++) @@ -2251,7 +2253,7 @@ static void BE_RenderMeshProgram(const shader_t *shader, const shaderpass_t *pas } #ifdef RTLIGHTS -qboolean BE_LightCullModel(vec3_t org, model_t *model) +qboolean GLBE_LightCullModel(vec3_t org, model_t *model) { if ((shaderstate.mode == BEM_LIGHT || shaderstate.mode == BEM_STENCIL)) { @@ -2282,7 +2284,7 @@ qboolean BE_LightCullModel(vec3_t org, model_t *model) #endif //Note: Be cautious about using BEM_LIGHT here. -void BE_SelectMode(backendmode_t mode, unsigned int flags) +void GLBE_SelectMode(backendmode_t mode, unsigned int flags) { extern int gldepthfunc; @@ -2368,7 +2370,7 @@ void BE_SelectMode(backendmode_t mode, unsigned int flags) shaderstate.flags = flags; } -void BE_SelectEntity(entity_t *ent) +void GLBE_SelectEntity(entity_t *ent) { if (shaderstate.curentity && shaderstate.curentity->flags & Q2RF_DEPTHHACK) qglDepthRange (gldepthmin, gldepthmax); @@ -2575,7 +2577,7 @@ static void DrawMeshes(void) } } -void BE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **meshlist, vbo_t *vbo, texnums_t *texnums) +void GLBE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **meshlist, vbo_t *vbo, texnums_t *texnums) { if (!vbo) { @@ -2626,7 +2628,7 @@ void BE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **meshlist, vbo_t DrawMeshes(); } } -void BE_DrawMesh_Single(shader_t *shader, mesh_t *mesh, vbo_t *vbo, texnums_t *texnums) +void GLBE_DrawMesh_Single(shader_t *shader, mesh_t *mesh, vbo_t *vbo, texnums_t *texnums) { shader->next = NULL; BE_DrawMesh_List(shader, 1, &mesh, NULL, texnums); @@ -2655,7 +2657,7 @@ void BE_DrawPolys(qboolean decalsset) BE_DrawMesh_Single(cl_stris[i].shader, &m, NULL, &cl_stris[i].shader->defaulttextures); } } -void BE_SubmitBatch(batch_t *batch) +void GLBE_SubmitBatch(batch_t *batch) { model_t *model = cl.worldmodel; int lm; @@ -2758,7 +2760,7 @@ static void BE_SubmitMeshesPortals(batch_t **worldlist, batch_t *dynamiclist) } BE_SelectMode(BEM_STANDARD, 0); - R_DrawPortal(batch, worldlist); + GLR_DrawPortal(batch, worldlist); /*clear depth again*/ GL_ForceDepthWritable(); @@ -2797,7 +2799,7 @@ static void BE_SubmitMeshesSortList(batch_t *sortlist) } } -void BE_SubmitMeshes (qboolean drawworld, batch_t **blist) +void GLBE_SubmitMeshes (qboolean drawworld, batch_t **blist) { model_t *model = cl.worldmodel; int i; @@ -2872,7 +2874,7 @@ static void BE_UpdateLightmaps(void) } } -batch_t *BE_GetTempBatch(void) +batch_t *GLBE_GetTempBatch(void) { if (shaderstate.wbatch >= shaderstate.maxwbatches) { @@ -2926,12 +2928,12 @@ void BE_BaseEntTextures(void) { batch_t *batches[SHADER_SORT_COUNT]; BE_GenModelBatches(batches); - BE_SubmitMeshes(false, batches); + GLBE_SubmitMeshes(false, batches); BE_SelectEntity(&r_worldentity); } #endif -void BE_DrawWorld (qbyte *vis) +void GLBE_DrawWorld (qbyte *vis) { extern cvar_t r_shadow_realtime_world, r_shadow_realtime_world_lightmaps; batch_t *batches[SHADER_SORT_COUNT]; @@ -2996,7 +2998,7 @@ void BE_DrawWorld (qbyte *vis) checkerror(); RSpeedRemark(); - BE_SubmitMeshes(true, batches); + GLBE_SubmitMeshes(true, batches); RSpeedEnd(RSPEED_WORLD); #ifdef RTLIGHTS @@ -3038,7 +3040,7 @@ void BE_DrawNonWorld (void) shaderstate.curentity = NULL; shaderstate.updatetime = cl.servertime; - BE_SubmitMeshes(false, batches); + GLBE_SubmitMeshes(false, batches); BE_SelectEntity(&r_worldentity); shaderstate.updatetime = realtime; diff --git a/engine/gl/gl_model.c b/engine/gl/gl_model.c index 28a42c35..2cecf8c9 100644 --- a/engine/gl/gl_model.c +++ b/engine/gl/gl_model.c @@ -1082,7 +1082,7 @@ TRACE(("dbg: RMod_LoadTextures: inittexturedescs\n")); if (!Q_strncmp(mt->name,"sky",3)) { - tn = R_InitSky (tx, (char *)mt + mt->offsets[0]); + R_InitSky (&tn, tx, (char *)mt + mt->offsets[0]); } else #ifdef PEXT_BULLETENS diff --git a/engine/gl/gl_rmain.c b/engine/gl/gl_rmain.c index 091c95ea..21ce2017 100644 --- a/engine/gl/gl_rmain.c +++ b/engine/gl/gl_rmain.c @@ -27,6 +27,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "shader.h" #include "gl_draw.h" +#ifdef _DEBUG +#define checkerror() if (qglGetError()) Con_Printf("Error detected at line %s:%i\n", __FILE__, __LINE__) +#else +#define checkerror() +#endif + void R_RenderBrushPoly (msurface_t *fa); #define PROJECTION_DISTANCE 200 @@ -1272,7 +1278,7 @@ static void TransformDir(vec3_t in, vec3_t planea[3], vec3_t viewa[3], vec3_t re VectorMA(result, d, viewa[i], result); } } -void R_DrawPortal(batch_t *batch, batch_t **blist) +void GLR_DrawPortal(batch_t *batch, batch_t **blist) { entity_t *view; GLdouble glplane[4]; diff --git a/engine/gl/gl_rsurf.c b/engine/gl/gl_rsurf.c index 0c5577ea..44572356 100644 --- a/engine/gl/gl_rsurf.c +++ b/engine/gl/gl_rsurf.c @@ -29,7 +29,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern cvar_t gl_bump; -void BE_ClearVBO(vbo_t *vbo) +void GLBE_ClearVBO(vbo_t *vbo) { int vboh[7]; int i, j; @@ -128,7 +128,7 @@ static qboolean GL_BuildVBO(vbo_t *vbo, void *vdata, int vsize, void *edata, int return true; } -void BE_GenBrushModelVBO(model_t *mod) +void GLBE_GenBrushModelVBO(model_t *mod) { unsigned int maxvboverts; unsigned int maxvboelements; @@ -278,7 +278,7 @@ void BE_GenBrushModelVBO(model_t *mod) }*/ } -void BE_UploadAllLightmaps(void) +void GLBE_UploadAllLightmaps(void) { int i; // diff --git a/engine/gl/gl_vidcommon.c b/engine/gl/gl_vidcommon.c index 5ffe8f7b..09f02cb6 100644 --- a/engine/gl/gl_vidcommon.c +++ b/engine/gl/gl_vidcommon.c @@ -2,6 +2,13 @@ #ifdef GLQUAKE #include "glquake.h" #include "gl_draw.h" +#include "shader.h" + +#ifdef _DEBUG +#define checkerror() if (qglGetError()) Con_Printf("Error detected at line %s:%i\n", __FILE__, __LINE__) +#else +#define checkerror() +#endif //standard 1.1 opengl calls void (APIENTRY *qglAlphaFunc) (GLenum func, GLclampf ref); @@ -912,7 +919,11 @@ void GL_Init(void *(*getglfunction) (char *name)) { Con_Printf ("GL_EXTENSIONS:"); for (i = 0; i < gl_num_extensions; i++) + { Con_Printf (" %s", qglGetStringi(GL_EXTENSIONS, i)); + if ((i & 15) == 15) + Con_Printf("\n"); + } Con_Printf ("\n"); } else @@ -942,16 +953,20 @@ void GL_Init(void *(*getglfunction) (char *name)) qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + checkerror(); #ifdef DEBUG if (qglDebugMessageEnableAMD) qglDebugMessageEnableAMD(0, 0, 0, NULL, true); if (qglDebugMessageCallbackAMD) qglDebugMessageCallbackAMD(myGLDEBUGPROCAMD, NULL); + qglGetError(); /*suck up the invalid operation error for non-debug contexts*/ #endif #if HASHPROGRAMS Hash_InitTable(&compiledshaderstable, sizeof(compiledshadersbuckets)/Hash_BytesForBuckets(1), compiledshadersbuckets); #endif + + checkerror(); } unsigned int d_8to24rgbtable[256]; @@ -1039,6 +1054,19 @@ rendererinfo_t openglrendererinfo = { GLSCR_UpdateScreen, + GLBE_SelectMode, + GLBE_DrawMesh_List, + GLBE_DrawMesh_Single, + GLBE_SubmitBatch, + GLBE_GetTempBatch, + GLBE_DrawWorld, + GLBE_Init, + GLBE_GenBrushModelVBO, + GLBE_ClearVBO, + GLBE_UploadAllLightmaps, + GLBE_SelectEntity, + GLBE_LightCullModel, + "" }; diff --git a/engine/gl/gl_vidnt.c b/engine/gl/gl_vidnt.c index 6986f0bf..b9994a8d 100644 --- a/engine/gl/gl_vidnt.c +++ b/engine/gl/gl_vidnt.c @@ -152,6 +152,12 @@ void ClearAllStates (void); void VID_UpdateWindowStatus (HWND hWnd); void GL_Init(void *(*getglfunction) (char *name)); +#ifdef _DEBUG +#define checkerror() if (qglGetError()) Con_Printf("Error detected at line %s:%i\n", __FILE__, __LINE__) +#else +#define checkerror() +#endif + typedef void (APIENTRY *lp3DFXFUNC) (int, int, int, int, int, const void*); lp3DFXFUNC qglColorTableEXT; qboolean is8bit = false; @@ -170,6 +176,7 @@ extern cvar_t vid_preservegamma; extern cvar_t vid_gl_context_version; extern cvar_t vid_gl_context_debug; +extern cvar_t vid_gl_context_es2; extern cvar_t vid_gl_context_forwardcompatible; extern cvar_t vid_gl_context_compatibility; @@ -237,11 +244,12 @@ HGLRC (APIENTRY *qwglCreateContextAttribsARB)(HDC hDC, HGLRC hShareContext, cons #define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092 #define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093 #define WGL_CONTEXT_FLAGS_ARB 0x2094 -#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 -#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 +#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001 +#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 #define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126 -#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 -#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001 +#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 +#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004 /*WGL_CONTEXT_ES2_PROFILE_BIT_EXT*/ #define ERROR_INVALID_VERSION_ARB 0x2095 #define ERROR_INVALID_PROFILE_ARB 0x2096 @@ -938,7 +946,20 @@ qboolean VID_AttachGL (rendererstate_t *info) Con_SafePrintf(CON_ERROR "wglMakeCurrent failed\n"); //green to make it show. return false; } - +/* + if (developer.ival) + { + char *(WINAPI *wglGetExtensionsString)(void) = NULL; + if (!wglGetExtensionsString) + wglGetExtensionsString = getglfunc("wglGetExtensionsString"); + if (!wglGetExtensionsString) + wglGetExtensionsString = getglfunc("wglGetExtensionsStringARB"); + if (!wglGetExtensionsString) + wglGetExtensionsString = getglfunc("wglGetExtensionsStringEXT"); + if (wglGetExtensionsString) + Con_SafePrintf("WGL extensions: %s\n", wglGetExtensionsString()); + } +*/ qwglCreateContextAttribsARB = getglfunc("wglCreateContextAttribsARB"); #ifdef _DEBUG //attempt to promote that to opengl3. @@ -981,10 +1002,12 @@ qboolean VID_AttachGL (rendererstate_t *info) } /*only switch contexts if there's actually a point*/ - if (i || !vid_gl_context_compatibility.ival) + if (i || !vid_gl_context_compatibility.ival || vid_gl_context_es2.ival) { attribs[i+1] = 0; - if (vid_gl_context_compatibility.ival) + if (vid_gl_context_es2.ival) + attribs[i+1] |= WGL_CONTEXT_ES2_PROFILE_BIT_EXT; + else if (vid_gl_context_compatibility.ival) attribs[i+1] |= WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB; else attribs[i+1] |= WGL_CONTEXT_CORE_PROFILE_BIT_ARB; @@ -1020,6 +1043,8 @@ qboolean VID_AttachGL (rendererstate_t *info) TRACE(("dbg: VID_AttachGL: GL_Init\n")); GL_Init(getglfunc); + checkerror(); + qwglChoosePixelFormatARB = getglfunc("wglChoosePixelFormatARB"); qwglSwapIntervalEXT = getglfunc("wglSwapIntervalEXT"); @@ -1036,6 +1061,8 @@ qboolean VID_AttachGL (rendererstate_t *info) if (!qGetDeviceGammaRamp) qGetDeviceGammaRamp = (void*)GetDeviceGammaRamp; if (!qSetDeviceGammaRamp) qSetDeviceGammaRamp = (void*)SetDeviceGammaRamp; + checkerror(); + return true; } diff --git a/engine/gl/gl_warp.c b/engine/gl/gl_warp.c index 31acea95..81f02f18 100644 --- a/engine/gl/gl_warp.c +++ b/engine/gl/gl_warp.c @@ -735,7 +735,7 @@ R_InitSky A sky texture is 256*128, with the right side being a masked overlay ============== */ -texnums_t R_InitSky (texture_t *mt, qbyte *src) +void R_InitSky (struct texnums_s *tn, texture_t *mt, qbyte *src) { int i, j, p; unsigned trans[128*128]; @@ -743,9 +743,8 @@ texnums_t R_InitSky (texture_t *mt, qbyte *src) int r, g, b; unsigned *rgba; char name[MAX_QPATH]; - texnums_t tn; - memset(&tn, 0, sizeof(tn)); + memset(tn, 0, sizeof(*tn)); // make an average value for the back to avoid // a fringe on the top level @@ -769,9 +768,9 @@ texnums_t R_InitSky (texture_t *mt, qbyte *src) Q_snprintfz(name, sizeof(name), "%s_solid", mt->name); Q_strlwr(name); - tn.base = R_LoadReplacementTexture(name, NULL, IF_NOALPHA); - if (!TEXVALID(tn.base)) - tn.base = R_LoadTexture32(name, 128, 128, trans, IF_NOALPHA|IF_NOGAMMA); + tn->base = R_LoadReplacementTexture(name, NULL, IF_NOALPHA); + if (!TEXVALID(tn->base)) + tn->base = R_LoadTexture32(name, 128, 128, trans, IF_NOALPHA|IF_NOGAMMA); alphamask = LittleLong(0x7fffffff); for (i=0 ; i<128 ; i++) @@ -786,10 +785,8 @@ texnums_t R_InitSky (texture_t *mt, qbyte *src) Q_snprintfz(name, sizeof(name), "%s_trans", mt->name); Q_strlwr(name); - tn.fullbright = R_LoadReplacementTexture(name, NULL, 0); - if (!TEXVALID(tn.fullbright)) - tn.fullbright = R_LoadTexture32(name, 128, 128, trans, IF_NOGAMMA); - - return tn; + tn->fullbright = R_LoadReplacementTexture(name, NULL, 0); + if (!TEXVALID(tn->fullbright)) + tn->fullbright = R_LoadTexture32(name, 128, 128, trans, IF_NOGAMMA); } #endif diff --git a/engine/gl/gltod3d/gl_fakegl.cpp b/engine/gl/gltod3d/gl_fakegl.cpp index 54ae6b9a..538c936a 100644 --- a/engine/gl/gltod3d/gl_fakegl.cpp +++ b/engine/gl/gltod3d/gl_fakegl.cpp @@ -4060,7 +4060,7 @@ d3dglfunc_t glfuncs[] = { }; -qboolean D3DVID_Init(rendererstate_t *info, unsigned char *palette) +static qboolean D3DVID_Init(rendererstate_t *info, unsigned char *palette) { strcpy(info->glrenderer, "D3D"); return GLVID_Init(info, palette); @@ -4070,98 +4070,104 @@ extern "C" { #include "gl_draw.h" } -rendererinfo_t d3drendererinfo = { - "Direct3D", +rendererinfo_t d3dfglrendererinfo = { + "Direct3D Wrapper", { "faked3d", "crap" }, - QR_OPENGL, + QR_OPENGL, - GLDraw_SafePicFromWad, - GLDraw_CachePic, - GLDraw_SafeCachePic, - GLDraw_Init, - GLDraw_ReInit, - GLDraw_Character, - GLDraw_ColouredCharacter, - GLDraw_TinyCharacter, - GLDraw_String, - GLDraw_Alt_String, - GLDraw_Crosshair, - GLDraw_DebugChar, - GLDraw_Pic, - GLDraw_ScalePic, - GLDraw_SubPic, - GLDraw_TransPic, - GLDraw_TransPicTranslate, - GLDraw_ConsoleBackground, - GLDraw_EditorBackground, - GLDraw_TileClear, - GLDraw_Fill, - GLDraw_FillRGB, - GLDraw_FadeScreen, - GLDraw_BeginDisc, - GLDraw_EndDisc, + R2D_SafePicFromWad, + R2D_SafeCachePic, + GLDraw_Init, + GLDraw_ReInit, + GLDraw_Crosshair, + R2D_ScalePic, + R2D_SubPic, + GLDraw_TransPicTranslate, + R2D_ConsoleBackground, + R2D_EditorBackground, + R2D_TileClear, + GLDraw_Fill, + GLDraw_FillRGB, + GLDraw_FadeScreen, + GLDraw_BeginDisc, + GLDraw_EndDisc, - GLDraw_Image, - GLDraw_ImageColours, + R2D_Image, + R2D_ImageColours, - GLR_Init, - GLR_DeInit, - GLR_ReInit, - GLR_RenderView, + GL_LoadTextureFmt, + GL_LoadTexture8Pal24, + GL_LoadTexture8Pal32, + GL_LoadCompressed, + GL_FindTexture, + GL_AllocNewTexture, + GL_UploadFmt, + GL_DestroyTexture, + + GLR_Init, + GLR_DeInit, + GLR_RenderView, - NULL, - NULL, - - GLR_NewMap, - GLR_PreNewMap, - GLR_LightPoint, - GLR_PushDlights, + GLR_NewMap, + GLR_PreNewMap, + GLR_LightPoint, - Surf_AddStain, - Surf_LessenStains, + Surf_AddStain, + Surf_LessenStains, - MediaGL_ShowFrameBGR_24_Flip, - MediaGL_ShowFrameRGBA_32, - MediaGL_ShowFrame8bit, + RMod_Init, + RMod_ClearAll, + RMod_ForName, + RMod_FindName, + RMod_Extradata, + RMod_TouchModel, + + RMod_NowLoadExternal, + RMod_Think, + + Mod_GetTag, + Mod_TagNumForName, + Mod_SkinNumForName, + Mod_FrameNumForName, + Mod_FrameDuration, + + D3DVID_Init, + GLVID_DeInit, + GLVID_SetPalette, + GLVID_ShiftPalette, + GLVID_GetRGBInfo, + + GLVID_SetCaption, //setcaption - GLMod_Init, - GLMod_ClearAll, - GLMod_ForName, - GLMod_FindName, - GLMod_Extradata, - GLMod_TouchModel, + GLSCR_UpdateScreen, - GLMod_NowLoadExternal, - GLMod_Think, + /*backend*/ + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, - Mod_GetTag, - Mod_TagNumForName, - Mod_SkinForName, - Mod_FrameForName, - Mod_GetFrameDuration, - - D3DVID_Init, - GLVID_DeInit, - GLVID_SetPalette, - GLVID_ShiftPalette, - GLVID_GetRGBInfo, - - NULL, //setcaption - - - GLSCR_UpdateScreen, - - "" + "" }; extern "C" { -rendererinfo_t *pd3drendererinfo = &d3drendererinfo; +rendererinfo_t *pd3dfglrendererinfo = &d3dfglrendererinfo; } #endif diff --git a/engine/gl/shader.h b/engine/gl/shader.h index f33f26cb..d27ddb25 100644 --- a/engine/gl/shader.h +++ b/engine/gl/shader.h @@ -376,7 +376,7 @@ void Shader_NeedReload(void); mfog_t *CM_FogForOrigin(vec3_t org); //not all modes accept meshes - STENCIL(intentional) and DEPTHONLY(not implemented) -typedef enum +enum backendmode_e { BEM_STANDARD, //regular mode to draw surfaces akin to q3 (aka: legacy mode). lightmaps+delux+ambient BEM_DEPTHONLY, //just a quick depth pass. textures used only for alpha test (shadowmaps). @@ -385,7 +385,7 @@ typedef enum BEM_LIGHT, //we have a valid light BEM_SMAPLIGHTSPOT, //we have a spot light using a shadowmap BEM_SMAPLIGHT //we have a light using a shadowmap -} backendmode_t; +}; #define BEF_FORCEDEPTHWRITE 1 #define BEF_FORCEDEPTHTEST 2 @@ -394,31 +394,40 @@ typedef enum #define BEF_FORCENODEPTH 16 //disables any and all depth. #define BEF_PUSHDEPTH 32 //additional polygon offset -//Select the current render mode and modifier flags -void BE_SelectMode(backendmode_t mode, unsigned int flags); - -/*Draws an entire mesh list from a VBO. vbo can be null, in which case the chain may be drawn without batching. - Rules for using a list: Every mesh must be part of the same VBO, shader, lightmap, and must have the same pointers set*/ -void BE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **mesh, vbo_t *vbo, texnums_t *texnums); -void BE_DrawMesh_Single(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, texnums_t *texnums); -void BE_SubmitBatch(batch_t *batch); -batch_t *BE_GetTempBatch(void); +#ifdef GLQUAKE +void GLBE_Init(void); +void GLBE_SelectMode(backendmode_t mode, unsigned int flags); +void GLBE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **mesh, vbo_t *vbo, texnums_t *texnums); +void GLBE_DrawMesh_Single(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, texnums_t *texnums); +void GLBE_SubmitBatch(batch_t *batch); +batch_t *GLBE_GetTempBatch(void); +void GLBE_GenBrushModelVBO(model_t *mod); +void GLBE_ClearVBO(vbo_t *vbo); +void GLBE_UploadAllLightmaps(void); +void GLBE_DrawWorld (qbyte *vis); +qboolean GLBE_LightCullModel(vec3_t org, model_t *model); +void GLBE_SelectEntity(entity_t *ent); +#endif +#ifdef D3DQUAKE +void D3DBE_Init(void); +void D3DBE_SelectMode(backendmode_t mode, unsigned int flags); +void D3DBE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **mesh, vbo_t *vbo, texnums_t *texnums); +void D3DBE_DrawMesh_Single(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, texnums_t *texnums); +void D3DBE_SubmitBatch(batch_t *batch); +batch_t *D3DBE_GetTempBatch(void); +void D3DBE_GenBrushModelVBO(model_t *mod); +void D3DBE_ClearVBO(vbo_t *vbo); +void D3DBE_UploadAllLightmaps(void); +void D3DBE_DrawWorld (qbyte *vis); +qboolean D3DBE_LightCullModel(vec3_t org, model_t *model); +void D3DBE_SelectEntity(entity_t *ent); +#endif //Asks the backend to invoke DrawMeshChain for each surface, and to upload lightmaps as required -void BE_DrawWorld (qbyte *vis); void BE_DrawNonWorld (void); -//called at init, force the display to the right defaults etc -void BE_Init(void); +void D3DBE_Reset(qboolean before); -void BE_D3D_Reset(qboolean before); - -//Generates an optimised VBO, one for each texture on the map -void BE_GenBrushModelVBO(model_t *mod); -//Destroys the given vbo -void BE_ClearVBO(vbo_t *vbo); -//Uploads all modified lightmaps -void BE_UploadAllLightmaps(void); //Builds a hardware shader from the software representation void BE_GenerateProgram(shader_t *shader); @@ -435,8 +444,5 @@ void Sh_Shutdown(void); void BE_BaseEntShadowDepth(void); //Sets the given light+colour to be the current one that everything is to be lit/culled by. void BE_SelectDLight(dlight_t *dl, vec3_t colour); -//Returns true if the mesh is not lit by the current light -qboolean BE_LightCullModel(vec3_t org, model_t *model); #endif -void BE_SelectEntity(entity_t *ent); #endif diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index 94ca9116..70903d48 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -3475,10 +3475,11 @@ SV_Frame void SV_Frame (void) { extern cvar_t pr_imitatemvdsv; - static double start, end; + static double start, end, idletime; float oldtime; qboolean isidle; static int oldpaused; + float timedelta; start = Sys_DoubleTime (); svs.stats.idle += start - end; @@ -3508,8 +3509,12 @@ void SV_Frame (void) { oldtime = sv.time; sv.time = (Sys_DoubleTime() - sv.starttime)*sv.gamespeed; + timedelta = sv.time - oldtime; if (sv.time < oldtime) + { sv.time = oldtime; //urm + timedelta = 0; + } if (sv.paused && sv.time > 1.5) { @@ -3602,7 +3607,7 @@ void SV_MVDStream_Poll(void); } } - if (!isidle) + if (!isidle || idletime > 0.1) { #ifdef SQL @@ -3656,7 +3661,9 @@ void SV_MVDStream_Poll(void); if (ge && ge->edicts) SVQ2_ClearEvents(); #endif + idletime = 0; } + idletime += timedelta; // collect timing statistics end = Sys_DoubleTime (); diff --git a/engine/server/sv_user.c b/engine/server/sv_user.c index 19399ac7..8e9fb8e0 100644 --- a/engine/server/sv_user.c +++ b/engine/server/sv_user.c @@ -2121,7 +2121,7 @@ struct void SV_VoiceReadPacket(void) { unsigned int vt = host_client->voice_target; - unsigned int j, cln; + unsigned int j; struct voice_ring_s *ring; unsigned short bytes; client_t *cl; @@ -2227,7 +2227,6 @@ void SV_VoiceSendPacket(client_t *client, sizebuf_t *buf) unsigned int clno; qboolean send; struct voice_ring_s *ring; - client_t *split; if (client->controller) client = client->controller; diff --git a/fteqtv/forward.c b/fteqtv/forward.c index 8e9d8cc8..9d840541 100644 --- a/fteqtv/forward.c +++ b/fteqtv/forward.c @@ -239,8 +239,11 @@ void Net_ProxySend(cluster_t *cluster, oproxy_t *prox, void *buffer, int length) Net_TryFlushProxyBuffer(cluster, prox); //try flushing if (prox->buffersize-prox->bufferpos + length > MAX_PROXY_BUFFER) //damn, still too big. { //they're too slow. hopefully it was just momentary lag - printf("QTV client is too lagged\n"); - prox->flushing = true; + if (!prox->flushing) + { + printf("QTV client is too lagged\n"); + prox->flushing = true; + } return; } } @@ -648,11 +651,27 @@ qboolean SV_ReadPendingProxy(cluster_t *cluster, oproxy_t *pend) if (pend->flushing) { - if (pend->bufferpos == pend->buffersize) + if (pend->srcfile) { - if (pend->srcfile) +#if 0 + //bufferend = transmit point + //buffersize = write point + if (bufferend < buffersize) + space = (MAX_PROXY_BUFFER - pend->buffersize) + pend->bufferend; + else + space = pend->bufferend - pend->buffersize; + + if (space < 256) /*don't bother reading if we're dribbling*/ + return false; + if (space > 0) /*never fully saturate so as to not confuse the ring*/ + space--; + + if (space > MAX_PROXY_BUFFER - + fread(prox->buffer + pend->buffersize, 1, space, pend->srcfile); +#else + if (pend->bufferpos == pend->buffersize) { - char buffer[4096]; + char buffer[MAX_PROXY_BUFFER/2]; len = fread(buffer, 1, sizeof(buffer), pend->srcfile); if (!len) { @@ -660,13 +679,15 @@ qboolean SV_ReadPendingProxy(cluster_t *cluster, oproxy_t *pend) pend->srcfile = NULL; } Net_ProxySend(cluster, pend, buffer, len); - return false; //don't try reading anything yet - } - else - { - pend->drop = true; - return false; } +#endif + return false; //don't try reading anything yet + } + + if (pend->bufferpos == pend->buffersize) + { + pend->drop = true; + return false; } else return false; diff --git a/fteqtv/httpsv.c b/fteqtv/httpsv.c index ca83819e..e61a6e2f 100644 --- a/fteqtv/httpsv.c +++ b/fteqtv/httpsv.c @@ -1,5 +1,6 @@ #include "qtv.h" +#define MINPLUGVER "4239" //main reason to use connection close is because we're lazy and don't want to give sizes in advance (yes, we could use chunks..) @@ -166,6 +167,30 @@ static void HTTPSV_SendHTMLHeader(cluster_t *cluster, oproxy_t *dest, char *titl ); Net_ProxySend(cluster, dest, buffer, strlen(buffer)); + + if (plugin) + { + s = + ""; + Net_ProxySend(cluster, dest, s, strlen(s)); + } } static void HTTPSV_SendHTMLFooter(cluster_t *cluster, oproxy_t *dest) @@ -173,9 +198,15 @@ static void HTTPSV_SendHTMLFooter(cluster_t *cluster, oproxy_t *dest) char *s; char buffer[2048]; - snprintf(buffer, sizeof(buffer), "
QTV Version: %i www.fteqw.com
", cluster->buildnumber); + /*Proxy version*/ + snprintf(buffer, sizeof(buffer), "
Server Version: %i www.fteqw.com", cluster->buildnumber); Net_ProxySend(cluster, dest, buffer, strlen(buffer)); + /*Plugin version*/ + s = ""; + Net_ProxySend(cluster, dest, s, strlen(s)); + + /*terminate html page*/ s = "\n" "\n"; Net_ProxySend(cluster, dest, s, strlen(s)); @@ -289,8 +320,6 @@ static void HTTPSV_GenerateCSSFile(cluster_t *cluster, oproxy_t *dest) HTMLPRINT("dl.nowplaying ul { margin: 0 0 0 1em; padding: 0; }"); HTMLPRINT("#navigation { background-color: #eef; }"); HTMLPRINT("#navigation li { display: inline; list-style: none; margin: 0 3em; }"); - HTMLPRINT("div.optdiv { margin: 0px 0px 0px 0px; position: fixed; left: 0%; width: 50%; top: 0%; height: 100%; }"); - HTMLPRINT("div.plugdiv { margin: 0px 0px 0px 0px; position: fixed; left: 50%; width: 50%; top: 0%; height: 100%; }"); } static qboolean HTTPSV_GetHeaderField(char *s, char *field, char *buffer, int buffersize) @@ -721,12 +750,12 @@ static void HTTPSV_GeneratePlugin(cluster_t *cluster, oproxy_t *dest) "QuakeTV With Plugin" " \n" "" - "
" + "
" "" "
" - "
" + "
" /*once for IE*/ "" + "" "" - "" + "" /*once again for firefox and similar friends*/ "" + "" "" - "" - "It looks like you either don't have the required plugin or its not supported by your browser.
" - "You can download one for firefox here (open with firefox itself).
" - "You can download one for internet explorer here.
" - "You can download one for other browsers here.
" + "" + "Plugin failed to load" "
" "
" "
" "" ""; @@ -1065,11 +1122,17 @@ void HTTPSV_GetMethod(cluster_t *cluster, oproxy_t *pend) { HTTPSV_GenerateAdmin(cluster, pend, 0, NULL, args); } +#if defined(_DEBUG) || defined(DEBUG) else REDIRECTIF("/", "/plugin.html") +#endif else REDIRECTIF("/", "/nowplaying.html") else REDIRECTIF("/about.html", "http://www.fteqw.com/") else REDIRECTIF("/qtvsplash.jpg", "/file/qtvsplash.jpg") /*lame, very lame*/ +#if defined(_DEBUG) || defined(DEBUG) + else REDIRECTIF("/npfte.xpi", "/file/npfte_dbg.xpi") /*lame, very lame*/ +#else else REDIRECTIF("/npfte.xpi", "/file/npfte.xpi") /*lame, very lame*/ +#endif else REDIRECTIF("/npfte.exe", "/file/npfte.exe") /*lame, very lame*/ else REDIRECTIF("/iefte.exe", "/file/iefte.exe") /*lame, very lame*/ else if (uriargmatch(uri, "/demos.html", urilen, &args)) diff --git a/fteqtv/qtv.h b/fteqtv/qtv.h index dcddcf06..12e1ab04 100644 --- a/fteqtv/qtv.h +++ b/fteqtv/qtv.h @@ -693,6 +693,8 @@ struct cluster_s { char master[MAX_QPATH]; char demodir[MAX_QPATH]; char downloaddir[MAX_QPATH]; //must be slash terminated, or empty. + char plugindatasource[256]; //sued by the http server for use with npfte + char mapsource[256]; //sued by the http server for use with npfte qboolean chokeonnotupdated; qboolean lateforward; qboolean notalking; diff --git a/fteqtv/qw.c b/fteqtv/qw.c index a8da5df1..d48eb992 100644 --- a/fteqtv/qw.c +++ b/fteqtv/qw.c @@ -2574,7 +2574,7 @@ void QTV_SayCommand(cluster_t *cluster, sv_t *qtv, viewer_t *v, char *fullcomman QW_StuffcmdToViewer(v, "bind pause \"say proxy:menu\"\n"); QW_StuffcmdToViewer(v, "bind backspace \"say proxy:menu back\"\n"); - QW_PrintfToViewer(v, "All keys bound not recognised\n"); + QW_PrintfToViewer(v, "All keys bound\n"); } else if (!*command) { diff --git a/fteqtv/rcon.c b/fteqtv/rcon.c index cad79dbb..02bb888c 100644 --- a/fteqtv/rcon.c +++ b/fteqtv/rcon.c @@ -857,6 +857,8 @@ void Cmd_Streams(cmdctxt_t *ctx) case ERR_NONE: if (qtv->controller) status = " (player controlled)"; + else if (qtv->autodisconnect == AD_STATUSPOLL) + status = " (polling)"; else if (qtv->parsingconnectiondata) status = " (connecting)"; else @@ -1150,6 +1152,56 @@ void Cmd_DLDir(cmdctxt_t *ctx) } } +void Cmd_PluginDataSource(cmdctxt_t *ctx) +{ + char *val; + val = Cmd_Argv(ctx, 1); + + if (!Cmd_IsLocal(ctx)) + { + Cmd_Printf(ctx, "plugindatasource may not be used remotely\n"); + return; + } + + if (*val) + { + while (*val > 0 &&*val <= ' ') + val++; + + strlcpy(ctx->cluster->plugindatasource, val, sizeof(ctx->cluster->plugindatasource)); + Cmd_Printf(ctx, "Changed plugindatasource to \"%s\"\n", ctx->cluster->plugindatasource); + } + else + { + Cmd_Printf(ctx, "Current plugindatasource is \"%s\"\n", ctx->cluster->plugindatasource); + } +} + +void Cmd_MapSource(cmdctxt_t *ctx) +{ + char *val; + val = Cmd_Argv(ctx, 1); + + if (!Cmd_IsLocal(ctx)) + { + Cmd_Printf(ctx, "mapsource may not be used remotely\n"); + return; + } + + if (*val) + { + while (*val > 0 &&*val <= ' ') + val++; + + strlcpy(ctx->cluster->mapsource, val, sizeof(ctx->cluster->mapsource)); + Cmd_Printf(ctx, "Changed mapsource url to \"%s\"\n", ctx->cluster->mapsource); + } + else + { + Cmd_Printf(ctx, "Current mapsource url is \"%s\"\n", ctx->cluster->mapsource); + } +} + void Cmd_MuteStream(cmdctxt_t *ctx) { char *val; @@ -1245,7 +1297,6 @@ const rconcommands_t rconcommands[] = {"maxproxies", 0, 1, Cmd_MaxProxies, "sets a limit on tcp/qtv client connections"}, {"demodir", 0, 1, Cmd_DemoDir, "specifies where to get the demo list from"}, {"basedir", 0, 1, Cmd_BaseDir, "specifies where to get any files required by the game. this is prefixed to the server-specified game dir."}, - {"dldir", 0, 1, Cmd_DLDir, "specifies the path to download stuff from (http://server/file/ maps here)"}, {"ping", 0, 1, Cmd_Ping, "sends a udp ping to a qtv proxy or server"}, {"reconnect", 0, 1, Cmd_Reconnect, "forces a stream to reconnect to its server (restarts demos)"}, {"echo", 0, 1, Cmd_Echo, "a useless command that echos a string"}, @@ -1269,6 +1320,10 @@ const rconcommands_t rconcommands[] = {"tcpport", 0, 1, Cmd_MVDPort, "specifies which port to listen on for tcp/qtv connections"}, {"mvdport", 0, 1, Cmd_MVDPort}, + {"dldir", 0, 1, Cmd_DLDir, "specifies the path to download stuff from (http://server/file/ maps to this native path)"}, + {"plugindatasource",0,1,Cmd_PluginDataSource, "Specifies the dataDownload property for plugins in the web server"}, + {"mapsource", 0, 1, Cmd_MapSource,"Public URL for where to download missing maps from"}, + #ifdef VIEWER {"watch", 1, 0, Cmd_Watch, "specifies to watch that stream in the built-in viewer"}, #endif