#include "cl_collision.h"
#include "r_shadow.h"
-/* Per-VM scenes */
-renderscene_t* renderscenes[PRVM_MAXPROGS];
-#define RENDERSCENE (*renderscenes[prognum])
-
//============================================================================
// Client
//[515]: unsolved PROBLEMS
void CSQC_RelinkCSQCEntities (void);
const char *Key_GetBind (int key);
-
-
-
-
-
// #1 void(vector ang) makevectors
static void VM_CL_makevectors (void)
{
//============================================================================
//[515]: SCENE MANAGER builtins
-extern qboolean CSQC_AddRenderEdict (renderscene_t* scene, prvm_edict_t *ed);//csprogs.c
+extern qboolean CSQC_AddRenderEdict (prvm_edict_t *ed);//csprogs.c
static void CSQC_R_RecalcView (void)
{
typedef struct vmpolygons_s
{
- //static float vm_polygon_linewidth = 1;
- mempool_t *pool;
- unsigned char current_vertices;
- qboolean initialized;
- vm_polygon_t *polygons;
- unsigned long polygons_num, drawpolygons_num; //[515]: ok long on 64bit ?
- qboolean polygonbegin; //[515]: for "no-crap-on-the-screen" check
+ //static float vm_polygon_linewidth = 1;
+ mempool_t *pool;
+ unsigned char current_vertices;
+ qboolean initialized;
+ vm_polygon_t *polygons;
+ unsigned long polygons_num, drawpolygons_num; //[515]: ok long on 64bit ?
+ qboolean polygonbegin; //[515]: for "no-crap-on-the-screen" check
} vmpolygons_t;
vmpolygons_t vmpolygons[PRVM_MAXPROGS];
#define VM_DEFPOLYNUM 64 //[515]: enough for default ?
static void VM_DrawPolygonCallback (const entity_render_t *ent, const rtlight_t *rtlight, int numsurfaces, int *surfacelist)
{
int surfacelistindex;
- vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-
+ vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
+
// LordHavoc: FIXME: this is stupid code
for (surfacelistindex = 0;surfacelistindex < numsurfaces;surfacelistindex++)
{
void VM_CL_AddPolygonsToMeshQueue (void)
{
int i;
- vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-
+ vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
+
if(!polys->drawpolygons_num)
return;
R_Mesh_Matrix(&identitymatrix);
{
vm_polygon_t *p;
const char *picname;
- vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-
+ vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
+
VM_SAFEPARMCOUNTRANGE(2, 4, VM_CL_R_PolygonBegin);
if(!polys->initialized)
{
float *coords, *tx, *rgb, alpha;
vm_polygon_t *p;
- vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-
+ vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
+
VM_SAFEPARMCOUNT(4, VM_CL_R_PolygonVertex);
if(!polys->polygonbegin)
//void() R_EndPolygon
void VM_CL_R_PolygonEnd (void)
{
- vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-
+ vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
+
VM_SAFEPARMCOUNT(0, VM_CL_R_PolygonEnd);
if(!polys->polygonbegin)
{
void VM_Polygons_Reset(void)
{
- vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
-
+ vmpolygons_t* polys = vmpolygons + PRVM_GetProgNr();
+
// TODO: replace vm_polygons stuff with a more general debugging polygon system, and make vm_polygons functions use that system
if(polys->initialized)
{
{
VM_Cmd_Init();
VM_Polygons_Reset();
- renderscenes[PRVM_CLIENTPROG] = &client_scene;
}
void VM_CL_Cmd_Reset(void)
void VM_CL_precache_model (void);
void VM_CL_setorigin (void);
-/* Per-VM scenes */
-extern renderscene_t* renderscenes[PRVM_MAXPROGS];
-
void VM_CL_R_AddDynamicLight (void);
void VM_CL_R_ClearScene (void);
void VM_CL_R_AddEntities (void);
void MP_Draw (void)
{
+ r_refdef_t clientrefdef = r_refdef;
+ r_refdef = menu_refdef;
+
PRVM_Begin;
PRVM_SetProg(PRVM_MENUPROG);
+ // FIXME: this really shouldnt error out lest we have a very broken refdef state...?
+ // or does it kill the server too?
PRVM_ExecuteProgram(prog->funcoffsets.m_draw,"m_draw() required");
PRVM_End;
+
+ menu_refdef = r_refdef;
+ r_refdef = clientrefdef;
}
void MP_ToggleMenu_f (void)
//
// menu router
//
+
+// hack
+extern r_refdef_t menu_refdef;
+
void MR_Init_Commands (void);
void MR_Init (void);
void MR_Restart (void);
#include "quakedef.h"
#include "prvm_cmds.h"
+#include "clvm_cmds.h"
#include "menu.h"
//============================================================================
#ifdef SUPPORT_GECKO
"DP_GECKO_SUPPORT "
#endif
+"DP_QC_RENDER_SCENE"
;
/*
VM_findflags, // #87
VM_findchainflags, // #88
VM_cvar_defstring, // #89
-NULL, // #90
-NULL, // #91
-NULL, // #92
+VM_CL_setmodel, // #90 void(entity e, string m) setmodel (QUAKE)
+VM_CL_precache_model, // #91 void(string s) precache_model (QUAKE)
+VM_CL_setorigin, // #92 void(entity e, vector o) setorigin (QUAKE)
NULL, // #93
NULL, // #94
NULL, // #95
NULL, // #297
NULL, // #298
NULL, // #299
-NULL, // #300
-NULL, // #301
-NULL, // #302
-NULL, // #303
-NULL, // #304
-NULL, // #305
-NULL, // #306
-NULL, // #307
-NULL, // #308
-NULL, // #309
+// CSQC range #300-#399
+VM_CL_R_ClearScene, // #300 void() clearscene (DP_QC_RENDER_SCENE)
+VM_CL_R_AddEntities, // #301 void(float mask) addentities (DP_QC_RENDER_SCENE)
+VM_CL_R_AddEntity, // #302 void(entity ent) addentity (DP_QC_RENDER_SCENE)
+VM_CL_R_SetView, // #303 float(float property, ...) setproperty (DP_QC_RENDER_SCENE)
+VM_CL_R_RenderScene, // #304 void() renderscene (DP_QC_RENDER_SCENE)
+VM_CL_R_AddDynamicLight, // #305 void(vector org, float radius, vector lightcolours) adddynamiclight (DP_QC_RENDER_SCENE)
+VM_CL_R_PolygonBegin, // #306 void(string texturename, float flag[, float is2d, float lines]) R_BeginPolygon
+VM_CL_R_PolygonVertex, // #307 void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
+VM_CL_R_PolygonEnd, // #308 void() R_EndPolygon
+NULL/*VM_CL_R_LoadWorldModel*/, // #309 void(string modelname) R_LoadWorldModel
NULL, // #310
NULL, // #311
NULL, // #312
const int vm_m_numbuiltins = sizeof(vm_m_builtins) / sizeof(prvm_builtin_t);
+r_refdef_t menu_refdef;
+
void VM_M_Cmd_Init(void)
{
VM_Cmd_Init();
+ VM_Polygons_Reset();
+
+ memset (&menu_refdef, 0, sizeof (r_refdef_t));
+
+ menu_refdef.frustumscale_x = 1;
+ menu_refdef.frustumscale_y = 1;
+ menu_refdef.maxentities = MAX_EDICTS + 256 + 512;
+ menu_refdef.entities = (entity_render_t **)Mem_Alloc(cls.permanentmempool, sizeof(entity_render_t *) * menu_refdef.maxentities);
+
+ menu_refdef.view.width = vid.width;
+ menu_refdef.view.height = vid.height;
+ menu_refdef.view.depth = 1;
+ menu_refdef.view.x = 0;
+ menu_refdef.view.y = 0;
+ menu_refdef.view.z = 0;
+ menu_refdef.view.colormask[0] = true;
+ menu_refdef.view.colormask[1] = true;
+ menu_refdef.view.colormask[2] = true;
+ menu_refdef.view.colormask[3] = true;
+
+ menu_refdef.view.useperspective = true;
+ menu_refdef.view.frustum_y = tan(scr_fov.value * M_PI / 360.0) * (3.0/4.0);
+ menu_refdef.view.frustum_x = menu_refdef.view.frustum_y * (float)menu_refdef.view.width / (float)menu_refdef.view.height / vid_pixelheight.value;
}
void VM_M_Cmd_Reset(void)
{
//VM_Cmd_Init();
VM_Cmd_Reset();
+ VM_Polygons_Reset();
}