Merging D3D and GL renderers a little.

D3D should be functional now. Maybe not pretty, maybe not complete, maybe not correct, but at least playable, at least with classic particles.
Some download fixes.
Some q3vm 64bit fixes.
Removed some dead cvars.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3614 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2010-11-02 23:17:25 +00:00
parent 4bd284003d
commit fcba94f554
39 changed files with 936 additions and 775 deletions

View file

@ -453,7 +453,7 @@ int VM_LerpTag(void *out, model_t *model, int f1, int f2, float l2, char *tagnam
#define VALIDATEPOINTER(o,l) if ((int)o + l >= mask || VM_POINTER(o) < offset) Host_EndGame("Call to cgame trap %i passes invalid pointer\n", fn); //out of bounds.
static qintptr_t CG_SystemCallsEx(void *offset, quintptr_t mask, qintptr_t fn, const qintptr_t *arg)
static qintptr_t CG_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, const qintptr_t *arg)
{
int ret=0;
@ -1043,35 +1043,51 @@ static qintptr_t CG_SystemCallsEx(void *offset, quintptr_t mask, qintptr_t fn, c
return ret;
}
#ifdef _DEBUG
static qintptr_t CG_SystemCallsExWrapper(void *offset, quintptr_t mask, qintptr_t fn, const qintptr_t *arg)
{ //this is so we can use edit and continue properly (vc doesn't like function pointers for edit+continue)
return CG_SystemCallsEx(offset, mask, fn, arg);
static int CG_SystemCallsVM(void *offset, quintptr_t mask, int fn, const int *arg)
{
if (sizeof(qintptr_t) == sizeof(int))
return CG_SystemCalls(offset, mask, fn, (qintptr_t*)arg);
else
{
qintptr_t args[10];
args[0]=arg[0];
args[1]=arg[1];
args[2]=arg[2];
args[3]=arg[3];
args[4]=arg[4];
args[5]=arg[5];
args[6]=arg[6];
args[7]=arg[7];
args[8]=arg[8];
args[9]=arg[9];
return CG_SystemCalls(offset, mask, fn, args);
}
}
#define CG_SystemCallsEx CG_SystemCallsExWrapper
#endif
//I'm not keen on this.
//but dlls call it without saying what sort of vm it comes from, so I've got to have them as specifics
static int EXPORT_FN CG_SystemCalls(int arg, ...)
static qintptr_t EXPORT_FN CG_SystemCallsNative(qintptr_t arg, ...)
{
int args[10];
qintptr_t args[10];
va_list argptr;
va_start(argptr, arg);
args[0]=va_arg(argptr, int);
args[1]=va_arg(argptr, int);
args[2]=va_arg(argptr, int);
args[3]=va_arg(argptr, int);
args[4]=va_arg(argptr, int);
args[5]=va_arg(argptr, int);
args[6]=va_arg(argptr, int);
args[7]=va_arg(argptr, int);
args[8]=va_arg(argptr, int);
args[9]=va_arg(argptr, int);
args[0]=va_arg(argptr, qintptr_t);
args[1]=va_arg(argptr, qintptr_t);
args[2]=va_arg(argptr, qintptr_t);
args[3]=va_arg(argptr, qintptr_t);
args[4]=va_arg(argptr, qintptr_t);
args[5]=va_arg(argptr, qintptr_t);
args[6]=va_arg(argptr, qintptr_t);
args[7]=va_arg(argptr, qintptr_t);
args[8]=va_arg(argptr, qintptr_t);
args[9]=va_arg(argptr, qintptr_t);
va_end(argptr);
return CG_SystemCallsEx(NULL, (unsigned)~0, arg, args);
return CG_SystemCalls(NULL, (unsigned)~0, arg, args);
}
int CG_Refresh(void)
@ -1127,7 +1143,7 @@ void CG_Start (void)
Z_FreeTags(CGTAGNUM);
SCR_BeginLoadingPlaque();
cgvm = VM_Create(NULL, "vm/cgame", CG_SystemCalls, CG_SystemCallsEx);
cgvm = VM_Create(NULL, "vm/cgame", CG_SystemCallsNative, CG_SystemCallsVM);
if (cgvm)
{ //hu... cgame doesn't appear to have a query version call!
SCR_EndLoadingPlaque();

View file

@ -2750,8 +2750,11 @@ void CL_DownloadSize_f(void)
}
else if (!strcmp(size, "p"))
{
Con_Printf("Download of \"%s\" failed. Not allowed.\n", rname);
CL_DownloadFailed(rname);
if (stricmp(cls.downloadremotename, rname))
{
Con_Printf("Download of \"%s\" failed. Not allowed.\n", rname);
CL_DownloadFailed(rname);
}
}
else if (!strcmp(size, "r"))
{
@ -2774,6 +2777,7 @@ void CL_DownloadSize_f(void)
if (!strcmp(dl->rname, rname))
{
dl->size = strtoul(size, NULL, 0);
dl->flags &= ~DLLF_SIZEUNKNOWN;
return;
}
}
@ -2997,6 +3001,7 @@ void CL_Init (void)
Cvar_Register (&r_drawflame, "Item effects");
Cvar_Register (&allow_download_csprogs, cl_controlgroup);
Cvar_Register (&allow_download_redirection, cl_controlgroup);
//
// info mirrors

View file

@ -1187,7 +1187,10 @@ void CL_RequestNextDownload (void)
if (cls.state == ca_active || requiredownloads.value || (fl & DLLF_REQUIRED))
{
if ((fl & DLLF_OVERWRITE) || !COM_FCheckExists (dl->localname))
{
CL_SendDownloadStartRequest(dl->rname, dl->localname);
return;
}
else
{
Con_Printf("Already have %s\n", dl->localname);
@ -1441,7 +1444,7 @@ void CL_ParseChunkedDownload(void)
else
Con_Printf("Couldn't find file \"%s\" on the server\n", svname);
cls.downloadmethod = 0;
cls.downloadmethod = DL_NONE;
CL_DownloadFailed(svname);
CL_RequestNextDownload();

View file

@ -680,10 +680,7 @@ void UI_RegisterFont(char *fontName, int pointSize, fontInfo_t *font)
#define VALIDATEPOINTER(o,l) if ((int)o + l >= mask || VM_POINTER(o) < offset) Host_EndGame("Call to ui trap %i passes invalid pointer\n", fn); //out of bounds.
#ifndef _DEBUG
static
#endif
int UI_SystemCallsEx(void *offset, quintptr_t mask, int fn, const int *arg)
static qintptr_t UI_SystemCalls(void *offset, quintptr_t mask, qintptr_t fn, const qintptr_t *arg)
{
int ret=0;
char adrbuf[MAX_ADR_SIZE];
@ -1321,17 +1318,33 @@ int UI_SystemCallsEx(void *offset, quintptr_t mask, int fn, const int *arg)
return ret;
}
#ifdef _DEBUG
static int UI_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, const int *arg)
static int UI_SystemCallsVM(void *offset, quintptr_t mask, int fn, const int *arg)
{ //this is so we can use edit and continue properly (vc doesn't like function pointers for edit+continue)
return UI_SystemCallsEx(offset, mask, fn, arg);
if (sizeof(int) == sizeof(qintptr_t))
{
return UI_SystemCalls(offset, mask, fn, arg);
}
else
{
qintptr_t args[9];
args[0]=arg[0];
args[1]=arg[1];
args[2]=arg[2];
args[3]=arg[3];
args[4]=arg[4];
args[5]=arg[5];
args[6]=arg[6];
args[7]=arg[7];
args[8]=arg[8];
return UI_SystemCalls(offset, mask, fn, args);
}
}
#define UI_SystemCallsEx UI_SystemCallsExWrapper
#endif
//I'm not keen on this.
//but dlls call it without saying what sort of vm it comes from, so I've got to have them as specifics
static qintptr_t EXPORT_FN UI_SystemCalls(qintptr_t arg, ...)
static qintptr_t EXPORT_FN UI_SystemCallsNative(qintptr_t arg, ...)
{
qintptr_t args[9];
va_list argptr;
@ -1348,7 +1361,7 @@ static qintptr_t EXPORT_FN UI_SystemCalls(qintptr_t arg, ...)
args[8]=va_arg(argptr, qintptr_t);
va_end(argptr);
return UI_SystemCallsEx(NULL, ~0, arg, args);
return UI_SystemCalls(NULL, ~(quintptr_t)0, arg, args);
}
qboolean UI_DrawStatusBar(int scores)
@ -1522,7 +1535,7 @@ void UI_Start (void)
if (qrenderer != QR_OPENGL && qrenderer != QR_DIRECT3D)
return;
uivm = VM_Create(NULL, "vm/ui", UI_SystemCalls, UI_SystemCallsEx);
uivm = VM_Create(NULL, "vm/ui", UI_SystemCallsNative, UI_SystemCallsVM);
if (uivm)
{
apiversion = VM_Call(uivm, UI_GETAPIVERSION, 6);

View file

@ -775,6 +775,7 @@ int Image_WritePNG (char *filename, int compression, qbyte *pixels, int width, i
#ifdef _MSC_VER
#pragma comment(lib, MSVCLIBSPATH "jpeg.lib")
#pragma comment(lib, MSVCLIBSPATH "libjpeg64.lib")
#endif
#ifndef JPEG_FALSE

View file

@ -418,7 +418,6 @@ presetinfo_t preset[] =
{"gl_specular", {"0", "0", "0", "1", "1"}},
{"r_loadlit", {"0", "1", "1", "2", "2"}},
{"r_fastsky", {"1", "0", "0", "-1", "-1"}},
{"r_waterlayers", {"0", "2", "", "4", "4"}},
{"r_shadow_realtime_dlight",{"0", "0", "0", "1", "1"}},
{"r_shadow_realtime_world", {"0", "0", "0", "0", "1"}},
{"gl_detail", {"0", "0", "0", "1", "1"}},
@ -592,7 +591,7 @@ void M_Menu_3D_f (void)
#ifndef MINIMAL
extern cvar_t r_xflip;
#endif
extern cvar_t r_novis, gl_dither, cl_item_bobbing, r_waterwarp, r_nolerp, r_fastsky, gl_nocolors, gl_lerpimages, gl_keeptjunctions, gl_lateswap, r_mirroralpha, r_wateralpha, r_drawviewmodel, gl_maxdist, gl_motionblur, gl_motionblurscale, gl_blend2d, gl_blendsprites, r_flashblend, gl_cshiftenabled, vid_multisample;
extern cvar_t r_novis, gl_dither, cl_item_bobbing, r_waterwarp, r_nolerp, r_fastsky, gl_nocolors, gl_lerpimages, gl_lateswap, r_mirroralpha, r_wateralpha, r_drawviewmodel, gl_motionblur, gl_motionblurscale, gl_blend2d, gl_blendsprites, r_flashblend, gl_cshiftenabled, vid_multisample;
int y;
menu = M_Options_Title(&y, sizeof(threeDmenuinfo_t));
@ -627,20 +626,21 @@ void M_Menu_3D_f (void)
MC_AddSlider(menu, 16, y, " Maximum Distance", &gl_maxdist,1,8192,128); y+=8;
MC_AddCheckBox(menu, 16, y, " GL Swapbuffer Delay", &gl_lateswap,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Mirror Reflections", &r_mirroralpha,0); y+=8;
#ifndef MINIMAL
#if !defined(MINIMAL) && defined(GLQUAKE)
MC_AddCheckBox(menu, 16, y, " Flip Horizontal View", &r_xflip,0); y+=8;
#endif
MC_AddCheckBox(menu, 16, y, " Water Transparency", &r_wateralpha,0); y+=8;
MC_AddSlider(menu, 16, y, " View Model Transparency", &r_drawviewmodel,0,1,0.1); y+=8;
MC_AddCheckBox(menu, 16, y, "Ignore Player Model Colors", &gl_nocolors,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Toggle Colinear Vertexes", &gl_keeptjunctions,0); y+=8;
MC_AddSlider(menu, 16, y, " Motion Blur", &gl_motionblur,0,1,0.5); y+=8;
MC_AddSlider(menu, 16, y, " Motion Blur Scale", &gl_motionblurscale,0,1,0.5); y+=8;
MC_AddCheckBox(menu, 16, y, " 2D Blending", &gl_blend2d,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Sprite Blending", &gl_blendsprites,0); y+=8;
MC_AddSlider(menu, 16, y, " Flash Blending", &r_flashblend,0,2,1); y+=8;
MC_AddCheckBox(menu, 16, y, " Poly Blending", &gl_cshiftenabled,0); y+=8;
#ifdef GLQUAKE
MC_AddCheckBox(menu, 16, y, " 16bit Color Dithering", &gl_dither,0); y+=8;
#endif
MC_AddCheckBox(menu, 16, y, " Model Bobbing", &cl_item_bobbing,0); y+=8;
info->multisamplingcombo = MC_AddCombo(menu, 16, y, " Multisample Anti-Aliasing", msaalevels, currentmsaalevel); y+=8;
y+=8;
@ -661,7 +661,7 @@ typedef struct {
qboolean M_VideoApplyTextures (union menuoption_s *op,struct menu_s *menu,int key)
{
texturemenuinfo_t *info = menu->data;
#ifndef MINIMAL
#if !defined(MINIMAL) && defined(GLQUAKE)
int currentbloomdiamond;
int currentbloomsamplesize;
@ -737,7 +737,7 @@ qboolean M_VideoApplyTextures (union menuoption_s *op,struct menu_s *menu,int ke
break;
}
#ifndef MINIMAL
#if !defined(MINIMAL) && defined(GLQUAKE)
if (r_bloom_sample_size.value >= 512)
currentbloomsamplesize = 7;
else if (r_bloom_sample_size.value == 384)
@ -916,20 +916,23 @@ void M_Menu_Textures_f (void)
int currenttexturefilter;
int currentanisotropylevel;
int currentmaxtexturesize;
#ifndef MINIMAL
#if !defined(MINIMAL) && defined(GLQUAKE)
int currentbloomsamplesize;
int currentbloomdiamond;
extern cvar_t r_bloom_sample_size, r_bloom_darken, r_bloom_intensity, r_bloom_diamond_size, r_bloom_alpha, r_bloom_fast_sample;
extern cvar_t r_bloom, r_bloom_sample_size, r_bloom_darken, r_bloom_intensity, r_bloom_diamond_size, r_bloom_alpha, r_bloom_fast_sample;
#endif
extern cvar_t gl_load24bit, gl_specular, gl_bump, gl_detail, gl_detailscale, gl_compress, gl_savecompressedtex, gl_triplebuffer, gl_picmip, gl_picmip2d, gl_max_size, r_stains, r_bloodstains, r_stainfadetime, r_stainfadeammount, gl_skyboxdist, r_drawflat, gl_schematics;
#if defined(GLQUAKE)
extern cvar_t gl_texture_anisotropic_filtering, gl_texturemode, gl_playermip;
#endif
extern cvar_t r_bloom, gl_load24bit, gl_specular, r_waterlayers, gl_bump, gl_detail, gl_detailscale, gl_compress, gl_savecompressedtex, gl_triplebuffer, gl_picmip, gl_picmip2d, gl_playermip, gl_max_size, r_stains, r_bloodstains, r_stainfadetime, r_stainfadeammount, gl_skyboxdist, r_drawflat, gl_schematics, gl_texturemode, gl_texture_anisotropic_filtering;
int y;
menu_t *menu = M_Options_Title(&y, sizeof(*info));
info = menu->data;
cursorpositionY = (y + 24);
#ifndef MINIMAL
#if !defined(MINIMAL) && defined(GLQUAKE)
if (r_bloom_sample_size.value >= 512)
currentbloomsamplesize = 7;
@ -964,6 +967,7 @@ void M_Menu_Textures_f (void)
currentbloomdiamond = 0;
#endif
#if defined(GLQUAKE)
if (!Q_strcasecmp(gl_texturemode.string, "gl_nearest_mipmap_nearest"))
currenttexturefilter = 0;
else if (!Q_strcasecmp(gl_texturemode.string, "gl_linear_mipmap_linear"))
@ -985,6 +989,10 @@ void M_Menu_Textures_f (void)
currentanisotropylevel = 0;
else
currentanisotropylevel = 0;
#else
currenttexturefilter = 0;
currentanisotropylevel = 0;
#endif
if (gl_max_size.value >= 8192)
currentmaxtexturesize = 9;
@ -1016,8 +1024,8 @@ void M_Menu_Textures_f (void)
info->texturefiltercombo = MC_AddCombo(menu, 16, y, " Texture Filter", texturefilternames, currenttexturefilter); y+=8;
info->anisotropycombo = MC_AddCombo(menu, 16, y, " Anisotropy Level", anisotropylevels, currentanisotropylevel); y+=8;
MC_AddCheckBox(menu, 16, y, " 32bit Textures", &gl_load24bit,0); y+=8;
#if !defined(MINIMAL) && defined(GLQUAKE)
MC_AddCheckBox(menu, 16, y, " Bloom", &r_bloom,0); y+=8;
#ifndef MINIMAL
MC_AddCheckBox(menu, 16, y, " Bloom Fast Sample", &r_bloom_fast_sample,0); y+=8;
info->bloomsamplesizecombo = MC_AddCombo(menu,16, y," Bloom Sample Size", bloomsamplesizeoptions, currentbloomsamplesize); y+=8;
MC_AddSlider(menu, 16, y, " Bloom Darken", &r_bloom_darken,0,5,0.25); y+=8;
@ -1034,7 +1042,9 @@ void M_Menu_Textures_f (void)
MC_AddCheckBox(menu, 16, y, " Triple Buffering", &gl_triplebuffer,0); y+=8;
MC_AddSlider(menu, 16, y, " 3D Texture Picmip", &gl_picmip,0,16,1); y+=8;
MC_AddSlider(menu, 16, y, " 2D Texture Picmip", &gl_picmip2d,0,16,1); y+=8;
#ifdef GLQUAKE
MC_AddSlider(menu, 16, y, " Model Texture Picmip", &gl_playermip,0,16,1); y+=8;
#endif
info->maxtexturesizecombo = MC_AddCombo(menu,16, y, " Maximum Texture Size", texturesizeoptions, currentmaxtexturesize); y+=8;
MC_AddCheckBox(menu, 16, y, " Stain Maps", &r_stains,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Blood Stains", &r_bloodstains,0); y+=8;
@ -1043,8 +1053,6 @@ void M_Menu_Textures_f (void)
MC_AddSlider(menu, 16, y, " Skybox Distance", &gl_skyboxdist,0,10000,100); y+=8;
MC_AddSlider(menu, 16, y, " Draw Flat Surfaces", &r_drawflat,0,2,1); y+=8;
MC_AddCheckBox(menu, 16, y, " Map Schematics", &gl_schematics,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Smooth Models", &gl_smoothmodels,0); y+=8;
MC_AddSlider(menu, 16, y, " Water Layers", &r_waterlayers,0,10,1); y+=8;
y+=8;
MC_AddCommand(menu, 16, y, " Apply", M_VideoApplyTextures); y+=8;

View file

@ -225,6 +225,7 @@ static qboolean PClassic_InitParticles (void)
classicmesh.indexes = classicindexes;
classicshader = R_RegisterShader("particles_classic",
"{\n"
"nomipmaps\n"
"{\n"
"map $diffuse\n"
"rgbgen vertex\n"

View file

@ -90,8 +90,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define QUAKEDEF_H__
#define WATERLAYERS
#ifdef SERVERONLY
#define isDedicated true
#endif

View file

@ -23,7 +23,7 @@ extern cvar_t gl_conback;
extern cvar_t gl_font;
extern cvar_t gl_contrast;
extern cvar_t vid_conautoscale;
void R2D_Font_Callback(struct cvar_s *var, char *oldvalue);
//We need this for minor things though, so we'll just use the slow accurate method.
//this is unlikly to be called too often.
@ -121,6 +121,8 @@ void R2D_Init(void)
"}\n"
);
Cvar_Hook(&gl_font, R2D_Font_Callback);
Cvar_ForceCallback(&gl_conback);
Cvar_ForceCallback(&vid_conautoscale);
Cvar_ForceCallback(&gl_font);

View file

@ -1911,6 +1911,140 @@ void Surf_SetupFrame(void)
}
}
static mesh_t *surfbatchmeshes[128];
static void Surf_BuildBrushBatch(batch_t *batch)
{
model_t *model = batch->ent->model;
unsigned int i;
batch->mesh = surfbatchmeshes;
batch->meshes = batch->surf_count;
for (i = 0; i < batch->surf_count; i++)
{
surfbatchmeshes[i] = model->surfaces[batch->surf_first + i].mesh;
}
}
void Surf_GenBrushBatches(batch_t **batches, entity_t *ent)
{
int i;
msurface_t *s;
model_t *model;
batch_t *b;
unsigned int bef;
model = ent->model;
if (R_CullEntityBox (ent, model->mins, model->maxs))
return;
#ifdef RTLIGHTS
if (BE_LightCullModel(ent->origin, model))
return;
#endif
// calculate dynamic lighting for bmodel if it's not an
// instanced model
if (model->fromgame != fg_quake3)
{
int k;
int shift;
currententity = ent;
currentmodel = ent->model;
if (model->nummodelsurfaces != 0 && r_dynamic.value)
{
for (k=rtlights_first; k<RTL_FIRST; k++)
{
if (!cl_dlights[k].radius)
continue;
if (!(cl_dlights[k].flags & LFLAG_ALLOW_LMHACK))
continue;
model->funcs.MarkLights (&cl_dlights[k], 1<<k,
model->nodes + model->hulls[0].firstclipnode);
}
}
shift = Surf_LightmapShift(model);
if ((ent->drawflags & MLS_MASKIN) == MLS_ABSLIGHT)
{
//update lightmaps.
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
Surf_RenderAmbientLightmaps (s, shift, ent->abslight);
}
else if (ent->drawflags & DRF_TRANSLUCENT)
{
//update lightmaps.
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
Surf_RenderAmbientLightmaps (s, shift, 255);
}
else
{
//update lightmaps.
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
Surf_RenderDynamicLightmaps (s, shift);
}
currententity = NULL;
}
bef = BEF_PUSHDEPTH;
if (ent->flags & Q2RF_ADDITIVE)
bef |= BEF_FORCEADDITIVE;
else if (ent->drawflags & DRF_TRANSLUCENT && r_wateralpha.value != 1)
{
bef |= BEF_FORCETRANSPARENT;
ent->shaderRGBAf[3] = r_wateralpha.value;
}
else if (ent->shaderRGBAf[3] < 1 && cls.protocol != CP_QUAKE3)
bef |= BEF_FORCETRANSPARENT;
if (ent->flags & RF_NODEPTHTEST)
bef |= BEF_FORCENODEPTH;
b = NULL;
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
{
if (!b || b->lightmap != s->lightmaptexturenum || b->texture != s->texinfo->texture || b->surf_count >= sizeof(surfbatchmeshes)/sizeof(surfbatchmeshes[0]))
{
b = BE_GetTempBatch();
if (!b)
break;
b->buildmeshes = NULL;
b->ent = ent;
b->texture = s->texinfo->texture;
b->shader = R_TextureAnimation(ent->framestate.g[FS_REG].frame[0], b->texture)->shader;
b->skin = &b->shader->defaulttextures;
b->flags = bef;
if (bef & BEF_FORCEADDITIVE)
{
b->next = batches[SHADER_SORT_ADDITIVE];
batches[SHADER_SORT_ADDITIVE] = b;
}
else if (bef & BEF_FORCETRANSPARENT)
{
b->next = batches[SHADER_SORT_BLEND];
batches[SHADER_SORT_BLEND] = b;
}
else
{
b->next = batches[b->shader->sort];
batches[b->shader->sort] = b;
}
b->surf_first = s - model->surfaces;
b->surf_count = 0;
b->buildmeshes = Surf_BuildBrushBatch;
b->meshes = 0;
b->firstmesh = 0;
b->lightmap = s->lightmaptexturenum;
b->mesh = NULL;
b->vbo = NULL;
}
b->surf_count++;
b->meshes++;
}
}
/*
=============
R_DrawWorld

View file

@ -159,11 +159,14 @@ extern entity_t r_worldentity;
//gl_alias.c
void R_GAlias_DrawBatch(struct batch_s *batch);
void R_GAlias_GenerateBatches(entity_t *e, struct batch_s **batches);
void R_LightArraysByte(vecV_t *coords, byte_vec4_t *colours, int vertcount, vec3_t *normals);
void R_LightArrays(vecV_t *coords, vec4_t *colours, int vertcount, vec3_t *normals);
//r_surf.c
struct model_s;
struct msurface_s;
void Surf_DrawWorld(void);
void Surf_GenBrushBatches(struct batch_s **batches, entity_t *ent);
void Surf_StainSurf(struct msurface_s *surf, float *parms);
void Surf_AddStain(vec3_t org, float red, float green, float blue, float radius);
void Surf_LessenStains(void);
@ -305,9 +308,6 @@ extern texid_t balltexture;
extern texid_t beamtexture;
extern texid_t ptritexture;
void GL_ParallelPerspective(double xmin, double xmax, double ymax, double ymin, double znear, double zfar);
void GL_InfinatePerspective(double fovx, double fovy, double zNear);
#if defined(GLQUAKE) || defined(D3DQUAKE)
void RMod_Init (void);
@ -410,12 +410,11 @@ extern cvar_t r_netgraph;
extern cvar_t r_xflip;
#endif
extern cvar_t gl_maxdist;
extern cvar_t gl_clear;
extern cvar_t gl_poly;
extern cvar_t gl_smoothmodels;
extern cvar_t gl_affinemodels;
extern cvar_t gl_nohwblend;
extern cvar_t gl_keeptjunctions;
extern cvar_t gl_reporttjunctions;
extern cvar_t r_flashblend;
extern cvar_t r_lightstylesmooth;

View file

@ -217,7 +217,7 @@ extern cvar_t r_drawentities;
extern cvar_t r_drawviewmodel;
extern cvar_t r_drawworld;
extern cvar_t r_fullbright;
extern cvar_t r_mirroralpha;
cvar_t r_mirroralpha = SCVARF("r_mirroralpha","1", CVAR_CHEAT);
extern cvar_t r_netgraph;
extern cvar_t r_norefresh;
extern cvar_t r_novis;
@ -289,6 +289,7 @@ cvar_t gl_savecompressedtex = SCVAR ("gl_savecompressedtex", "0");
cvar_t gl_schematics = SCVAR ("gl_schematics", "0");
cvar_t gl_skyboxdist = SCVAR ("gl_skyboxdist", "0"); //0 = guess.
cvar_t gl_smoothcrosshair = SCVAR ("gl_smoothcrosshair", "1");
cvar_t gl_maxdist = SCVAR("gl_maxdist", "8192");
#ifdef SPECULAR
cvar_t gl_specular = SCVAR ("gl_specular", "0");
@ -335,8 +336,6 @@ cvar_t vid_desktopgamma = SCVARF ("vid_desktopgamma", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH);
extern cvar_t gl_dither;
extern cvar_t gl_maxdist;
extern cvar_t r_waterlayers;
#endif
@ -373,7 +372,6 @@ void GLRenderer_Init(void)
Cvar_Register (&gl_clear, GLRENDEREROPTIONS);
Cvar_Register (&gl_smoothmodels, GRAPHICALNICETIES);
Cvar_Register (&gl_affinemodels, GLRENDEREROPTIONS);
Cvar_Register (&gl_nohwblend, GLRENDEREROPTIONS);
Cvar_Register (&r_flashblend, GLRENDEREROPTIONS);
@ -394,13 +392,10 @@ void GLRenderer_Init(void)
Cvar_Register (&r_shadow_realtime_dlight_shadows, GLRENDEREROPTIONS);
Cvar_Register (&r_shadow_realtime_world_lightmaps, GLRENDEREROPTIONS);
Cvar_Register (&gl_keeptjunctions, GLRENDEREROPTIONS);
Cvar_Register (&gl_reporttjunctions, GLRENDEREROPTIONS);
Cvar_Register (&gl_motionblur, GLRENDEREROPTIONS);
Cvar_Register (&gl_motionblurscale, GLRENDEREROPTIONS);
Cvar_Register (&gl_max_size, GLRENDEREROPTIONS);
Cvar_Register (&gl_maxdist, GLRENDEREROPTIONS);
Cvar_Register (&vid_multisample, GLRENDEREROPTIONS);
Cvar_Register (&gl_smoothcrosshair, GRAPHICALNICETIES);
@ -417,10 +412,6 @@ void GLRenderer_Init(void)
// Cvar_Register (&gl_lightmapmode, GLRENDEREROPTIONS);
#ifdef WATERLAYERS
Cvar_Register (&r_waterlayers, GRAPHICALNICETIES);
#endif
Cvar_Register (&r_polygonoffset_submodel_factor, GLRENDEREROPTIONS);
Cvar_Register (&r_polygonoffset_submodel_offset, GLRENDEREROPTIONS);
@ -611,6 +602,8 @@ void Renderer_Init(void)
Cvar_Register (&r_fastskycolour, GRAPHICALNICETIES);
Cvar_Register (&r_wateralpha, GRAPHICALNICETIES);
Cvar_Register (&gl_max_size, GLRENDEREROPTIONS);
Cvar_Register (&gl_maxdist, GLRENDEREROPTIONS);
Cvar_Register (&gl_miptexLevel, GRAPHICALNICETIES);
Cvar_Register (&r_drawflat, GRAPHICALNICETIES);
Cvar_Register (&r_menutint, GRAPHICALNICETIES);
@ -1844,7 +1837,7 @@ TRACE(("dbg: R_RestartRenderer_f\n"));
#if defined(GLQUAKE)
Cmd_ExecuteString("setrenderer gl\n", RESTRICT_LOCAL);
#elif defined(D3DQUAKE)
Cmd_ExecuteString("setrenderer d3d9\n", RESTRICT_LOCAL);
Cmd_ExecuteString("setrenderer d3d\n", RESTRICT_LOCAL);
#endif
return;
}

View file

@ -22,9 +22,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <dsound.h>
#ifdef _MSC_VER
#pragma comment(lib, MSVCLIBSPATH "dxsdk7/lib/dxguid.lib")
#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 } }
FORCE_DEFINE_GUID(IID_IDirectSound, 0x279AFA83, 0x4981, 0x11CE, 0xA5, 0x21, 0x00, 0x20, 0xAF, 0x0B, 0xE5, 0x60);
FORCE_DEFINE_GUID(IID_IKsPropertySet, 0x31efac30, 0x515c, 0x11d0, 0xa9, 0xaa, 0x00, 0xaa, 0x00, 0x61, 0xbe, 0x93);
#define SND_ERROR 0
#define SND_LOADED 1

View file

@ -77,6 +77,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define AVAIL_FREETYPE
#endif
#ifdef _WIN64
#undef AVAIL_PNGLIB
#undef AVAIL_ZLIB
#endif
#define ODE_DYNAMIC
#ifdef NO_PNG

View file

@ -898,6 +898,43 @@ avec3_t shadelight;
#include <xmmintrin.h>
#endif
void R_LightArraysByte(vecV_t *coords, byte_vec4_t *colours, int vertcount, vec3_t *normals)
{
extern cvar_t r_vertexdlights;
int i;
float l;
byte_vec4_t ambientlightb;
byte_vec4_t shadelightb;
VectorScale(ambientlight, 255, ambientlightb);
VectorScale(shadelight, 255, shadelightb);
if (ambientlightb[0] == shadelightb[0] && ambientlightb[1] == shadelightb[1] && ambientlightb[2] == shadelightb[2])
{
for (i = vertcount-1; i >= 0; i--)
{
colours[i][0] = ambientlightb[0];
colours[i][1] = ambientlightb[1];
colours[i][2] = ambientlightb[2];
}
}
else
{
vec3_t meanambient;
/*dotproduct will return a value between 1 and -1, so increase the ambient to be correct for normals facing away from the light*/
VectorMA(ambientlightb, 1, shadelightb, meanambient);
for (i = vertcount-1; i >= 0; i--)
{
l = DotProduct(normals[i], shadevector);
colours[i][0] = l*shadelightb[0]+meanambient[0];
colours[i][1] = l*shadelightb[1]+meanambient[1];
colours[i][2] = l*shadelightb[2]+meanambient[2];
}
}
}
void R_LightArrays(vecV_t *coords, avec4_t *colours, int vertcount, vec3_t *normals)
{
extern cvar_t r_vertexdlights;
@ -1917,11 +1954,11 @@ static void *Q1_LoadFrameGroup (daliasframetype_t *pframetype, int *seamremaps)
Q_strncpyz(frame->name, frameinfo->name, sizeof(frame->name));
verts = (vecV_t *)(pose+1);
svec = &normals[galias->numverts];
tvec = &svec[galias->numverts];
pose->ofsverts = (char *)verts - (char *)pose;
#ifndef SERVERONLY
normals = (vec3_t*)&verts[galias->numverts];
svec = &normals[galias->numverts];
tvec = &svec[galias->numverts];
pose->ofsnormals = (char *)normals - (char *)pose;
pose->ofssvector = (char *)svec - (char *)pose;
pose->ofstvector = (char *)tvec - (char *)pose;

View file

@ -3086,6 +3086,13 @@ void COM_Version_f (void)
#endif
#endif
#ifdef _WIN64
Con_Printf("Compiled for 64bit windows\n");
#endif
#ifdef _M_AMD64
Con_Printf("Compiled for AMD64 compatible cpus\n");
#endif
#ifdef _M_IX86
Con_Printf("x86 optimized for: ");

View file

@ -463,7 +463,7 @@ void FS_RebuildFSHash(void)
com_fschanged = false;
Con_Printf("%i unique files, %i duplicates\n", fs_hash_files, fs_hash_dups);
Con_DPrintf("%i unique files, %i duplicates\n", fs_hash_files, fs_hash_dups);
}
/*
@ -1809,7 +1809,7 @@ typedef struct {
const char *protocolname; //sent to the master server when this is the current gamemode.
const char *exename; //used if the exe name contains this
const char *argname; //used if this was used as a parameter.
const char *auniquefile; //used if this file is relative from the gamedir
const char *auniquefile[4]; //used if this file is relative from the gamedir
const char *customexec;
@ -1822,23 +1822,24 @@ const gamemode_info_t gamemode_info[] = {
//rogue/hipnotic have no special files - the detection conflicts and stops us from running regular quake
//protocol name(dpmaster) exename cmdline switch identifying file exec dir1 dir2 dir3 dir(fte) full name
{"Darkplaces-Quake", "darkplaces", "-quake", "id1/pak0.pak", NULL, {"id1", "qw", "fte"}, "Quake"},
{"Darkplaces-Hipnotic", "hipnotic", "-hipnotic", NULL, NULL, {"id1", "qw", "hipnotic", "fte"}, "Quake: Scourge of Armagon"},
{"Darkplaces-Rogue", "rogue", "-rogue", NULL, NULL, {"id1", "qw", "rogue", "fte"}, "Quake: Dissolution of Eternity"},
{"Nexuiz", "nexuiz", "-nexuiz", "nexuiz.exe", NEXCFG, {"data", "ftedata"}, "Nexuiz"},
{"DMF", "dmf", "-dmf", "base/src/progs.src",DMFCFG,{"base", }, "DMF"},
{"Darkplaces-Quake", "darkplaces", "-quake", {"id1/pak0.pak"}, NULL, {"id1", "qw", "fte"}, "Quake"},
{"Darkplaces-Hipnotic", "hipnotic", "-hipnotic", {NULL}, NULL, {"id1", "qw", "hipnotic", "fte"}, "Quake: Scourge of Armagon"},
{"Darkplaces-Rogue", "rogue", "-rogue", {NULL}, NULL, {"id1", "qw", "rogue", "fte"}, "Quake: Dissolution of Eternity"},
{"Nexuiz", "nexuiz", "-nexuiz", {"nexuiz.exe"}, NEXCFG, {"data", "ftedata"}, "Nexuiz"},
{"DMF", "dmf", "-dmf", {"base/src/progs.src"}, DMFCFG, {"base", }, "DMF"},
//supported commercial mods (some are currently only partially supported)
{"FTE-H2MP", "h2mp", "-portals", "portals/hexen.rc", HEX2CFG,{"data1", "portals", "fteh2"}, "Hexen II MP"},
{"FTE-Hexen2", "hexen", "-hexen2", "data1/pak0.pak", HEX2CFG,{"data1", "fteh2"}, "Hexen II"},
{"FTE-Quake2", "q2", "-q2", "baseq2/pak0.pak", NULL, {"baseq2", "fteq2"}, "Quake II"},
{"FTE-Quake3", "q3", "-q3", "baseq3/pak0.pk3", NULL, {"baseq3", "fteq3"}, "Quake III Arena"},
{"FTE-Quake4", "q4", "-q4", "q4base/pak00.pk4", NULL, {"q4base", "fteq4"}, "Quake 4"},
{"FTE-EnemyTerritory", "et", "-et", "etmain/pak0.pk3", NULL, {"etmain", "fteet"}, "Wolfenstein - Enemy Territory"},
{"FTE-H2MP", "h2mp", "-portals", {"portals/hexen.rc",
"portals/pak3.pak"}, HEX2CFG,{"data1", "portals", "fteh2"}, "Hexen II MP"},
{"FTE-Hexen2", "hexen", "-hexen2", {"data1/pak0.pak"}, HEX2CFG,{"data1", "fteh2"}, "Hexen II"},
{"FTE-Quake2", "q2", "-q2", {"baseq2/pak0.pak"}, NULL, {"baseq2", "fteq2"}, "Quake II"},
{"FTE-Quake3", "q3", "-q3", {"baseq3/pak0.pk3"}, NULL, {"baseq3", "fteq3"}, "Quake III Arena"},
{"FTE-Quake4", "q4", "-q4", {"q4base/pak00.pk4"}, NULL, {"q4base", "fteq4"}, "Quake 4"},
{"FTE-EnemyTerritory", "et", "-et", {"etmain/pak0.pk3"}, NULL, {"etmain", "fteet"}, "Wolfenstein - Enemy Territory"},
{"FTE-JK2", "jk2", "-jk2", "base/assets0.pk3", NULL, {"base", "fte"}, "Jedi Knight II: Jedi Outcast"},
{"FTE-JK2", "jk2", "-jk2", {"base/assets0.pk3"}, NULL, {"base", "fte"}, "Jedi Knight II: Jedi Outcast"},
{"FTE-HalfLife", "hl", "-halflife", "valve/liblist.gam",NULL, {"valve", "ftehl"}, "Half-Life"},
{"FTE-HalfLife", "hl", "-halflife", {"valve/liblist.gam"} ,NULL, {"valve", "ftehl"}, "Half-Life"},
{NULL}
};
@ -2376,7 +2377,7 @@ COM_InitFilesystem
void COM_InitFilesystem (void)
{
FILE *f;
int i;
int i, j;
char *ev;
qboolean usehome;
@ -2413,16 +2414,19 @@ void COM_InitFilesystem (void)
Cvar_Register(&com_gamename, "evil hacks");
Cvar_Register(&com_modname, "evil hacks");
//identify the game from a telling file
for (i = 0; gamemode_info[i].argname; i++)
for (i = 0; gamemode_info[i].argname && gamenum==-1; i++)
{
if (!gamemode_info[i].auniquefile)
continue; //no more
f = fopen(va("%s%s", com_quakedir, gamemode_info[i].auniquefile), "rb");
if (f)
for (j = 0; j < 4; j++)
{
fclose(f);
gamenum = i;
break;
if (!gamemode_info[i].auniquefile[j])
continue; //no more
f = fopen(va("%s%s", com_quakedir, gamemode_info[i].auniquefile[j]), "rb");
if (f)
{
fclose(f);
gamenum = i;
break;
}
}
}
//use the game based on an exe name over the filesystem one (could easily have multiple fs path matches).
@ -2438,30 +2442,34 @@ void COM_InitFilesystem (void)
{
gamenum = i;
if (gamemode_info[gamenum].auniquefile)
for (j = 0; j < 4; j++)
{
f = fopen(va("%s%s", com_quakedir, gamemode_info[i].auniquefile), "rb");
if (f)
if (gamemode_info[gamenum].auniquefile[j])
{
//we found it, its all okay
fclose(f);
break;
}
#ifdef _WIN32
if (Sys_FindGameData(gamemode_info[i].poshname, gamemode_info[i].exename, com_quakedir, sizeof(com_quakedir)))
{
if (com_quakedir[strlen(com_quakedir)-1] == '\\')
com_quakedir[strlen(com_quakedir)-1] = '/';
else if (com_quakedir[strlen(com_quakedir)-1] != '/')
f = fopen(va("%s%s", com_quakedir, gamemode_info[i].auniquefile[j]), "rb");
if (f)
{
com_quakedir[strlen(com_quakedir)+1] = '\0';
com_quakedir[strlen(com_quakedir)] = '/';
//we found it, its all okay
fclose(f);
break;
}
}
else
#ifdef _WIN32
if (Sys_FindGameData(gamemode_info[i].poshname, gamemode_info[i].exename, com_quakedir, sizeof(com_quakedir)))
{
if (com_quakedir[strlen(com_quakedir)-1] == '\\')
com_quakedir[strlen(com_quakedir)-1] = '/';
else if (com_quakedir[strlen(com_quakedir)-1] != '/')
{
com_quakedir[strlen(com_quakedir)+1] = '\0';
com_quakedir[strlen(com_quakedir)] = '/';
}
}
else
#endif
{
Con_Printf("Couldn't find the gamedata for this game mode!\n");
{
Con_Printf("Couldn't find the gamedata for this game mode!\n");
}
break;
}
}
break;

View file

@ -241,7 +241,7 @@ qintptr_t VARGS Plug_FindBuiltin(void *offset, quintptr_t mask, const qintptr_t
return 0;
}
int Plug_SystemCallsEx(void *offset, quintptr_t mask, int fn, const int *arg)
int Plug_SystemCallsVM(void *offset, quintptr_t mask, int fn, const int *arg)
{
#if FTE_WORDSIZE == 32
#define args arg
@ -270,7 +270,7 @@ int Plug_SystemCallsEx(void *offset, quintptr_t mask, int fn, const int *arg)
//I'm not keen on this.
//but dlls call it without saying what sort of vm it comes from, so I've got to have them as specifics
static qintptr_t EXPORT_FN Plug_SystemCalls(qintptr_t arg, ...)
static qintptr_t EXPORT_FN Plug_SystemCallsNative(qintptr_t arg, ...)
{
qintptr_t args[9];
va_list argptr;
@ -300,7 +300,7 @@ static qintptr_t EXPORT_FN Plug_SystemCalls(qintptr_t arg, ...)
plugin_t *Plug_Load(char *file)
{
plugin_t *newplug;
int argarray;
qintptr_t argarray;
for (newplug = plugs; newplug; newplug = newplug->next)
{
@ -312,7 +312,7 @@ plugin_t *Plug_Load(char *file)
newplug->name = (char*)(newplug+1);
strcpy(newplug->name, file);
newplug->vm = VM_Create(NULL, file, Plug_SystemCalls, Plug_SystemCallsEx);
newplug->vm = VM_Create(NULL, file, Plug_SystemCallsNative, Plug_SystemCallsVM);
currentplug = newplug;
if (newplug->vm)
{

View file

@ -337,7 +337,7 @@ qvm_t *QVM_LoadVM(const char *name, sys_callqvm_t syscall)
qvm_t *qvm;
qbyte *raw;
int n;
int i;
unsigned int i;
sprintf(path, "%s.qvm", name);
FS_LoadFile(path, &raw);
@ -379,7 +379,7 @@ qvm_t *QVM_LoadVM(const char *name, sys_callqvm_t syscall)
qvm->ds_mask = qvm->len_ds*sizeof(qbyte)+(qvm->len_ss+16*4)*sizeof(qbyte);//+4 for a stack check decrease
for (i = 0; i < sizeof(qvm->ds_mask)*8-1; i++)
{
if ((1<<(unsigned int)i) >= qvm->ds_mask) //is this bit greater than our minimum?
if ((1<<i) >= qvm->ds_mask) //is this bit greater than our minimum?
break;
}
qvm->len_ss = (1<<i) - qvm->len_ds*sizeof(qbyte) - 4; //expand the stack space to fill it.

View file

@ -1,7 +1,6 @@
#include "quakedef.h"
#ifdef D3DQUAKE
#include "shader.h"
#include <d3d9.h>
#include <GL/gl.h>
@ -9,10 +8,10 @@
extern LPDIRECT3DDEVICE9 pD3DDev9;
#define MAX_ARRAY_VERTS 65535
static avec4_t coloursarray[MAX_ARRAY_VERTS];
static float texcoordarray[SHADER_PASS_MAX][MAX_ARRAY_VERTS*2];
static vecV_t vertexarray[MAX_ARRAY_VERTS];
//#define d3dcheck(foo) foo
#define d3dcheck(foo) do{HRESULT err = foo; if (FAILED(err)) Sys_Error("D3D reported error on line %i - error %x\n", __LINE__, err);} while(0)
#define MAX_TMUS 4
/*========================================== tables for deforms =====================================*/
#define frand() (rand()*(1.0/RAND_MAX))
@ -80,6 +79,9 @@ static void FTable_Init(void)
typedef struct
{
backendmode_t mode;
unsigned int flags;
float curtime;
entity_t *curentity;
shader_t *curshader;
@ -94,18 +96,24 @@ typedef struct
unsigned int nummeshes;
D3DCOLOR passcolour;
qboolean passsinglecolour;
/*FIXME: we shouldn't lock these so much - we need to cache which batches have been submitted and set up streams separately from the vertex data*/
IDirect3DVertexBuffer9 *dynxyz_buff;
unsigned int dynxyz_offs;
unsigned int dynxyz_size;
IDirect3DVertexBuffer9 *dynst_buff[2];
unsigned int dynst_offs[2];
IDirect3DVertexBuffer9 *dynst_buff[MAX_TMUS];
unsigned int dynst_offs[MAX_TMUS];
unsigned int dynst_size;
IDirect3DVertexBuffer9 *dyncol_buff;
unsigned int dyncol_offs;
unsigned int dyncol_size;
IDirect3DIndexBuffer9 *dynidx_buff;
unsigned int dynidx_offs;
unsigned int dynidx_size;
} d3dbackend_t;
#define DYNVBUFFSIZE 65536
@ -123,7 +131,6 @@ enum
D3D_VDEC_ST1 = 1<<3,
D3D_VDEC_ST2 = 1<<3,
D3D_VDEC_ST3 = 1<<3,
#define MAX_TMUS 4
D3D_VDEC_MAX = 16
};
IDirect3DVertexDeclaration9 *vertexdecls[D3D_VDEC_MAX];
@ -139,11 +146,15 @@ void BE_Init(void)
FTable_Init();
IDirect3DDevice9_CreateVertexBuffer(pD3DDev9, DYNVBUFFSIZE, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &shaderstate.dynxyz_buff, NULL);
shaderstate.dynxyz_size = sizeof(vecV_t) * DYNVBUFFSIZE;
shaderstate.dyncol_size = sizeof(byte_vec4_t) * DYNVBUFFSIZE;
shaderstate.dynst_size = sizeof(vec2_t) * DYNVBUFFSIZE;
shaderstate.dynidx_size = sizeof(index_t) * DYNIBUFFSIZE;
IDirect3DDevice9_CreateVertexBuffer(pD3DDev9, shaderstate.dynxyz_size, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &shaderstate.dynxyz_buff, NULL);
for (tmu = 0; tmu < MAX_TMUS; tmu++)
IDirect3DDevice9_CreateVertexBuffer(pD3DDev9, DYNVBUFFSIZE, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &shaderstate.dynst_buff[tmu], NULL);
IDirect3DDevice9_CreateVertexBuffer(pD3DDev9, DYNVBUFFSIZE, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &shaderstate.dyncol_buff, NULL);
IDirect3DDevice9_CreateIndexBuffer(pD3DDev9, DYNIBUFFSIZE, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, D3DFMT_QINDEX, D3DPOOL_DEFAULT, &shaderstate.dynidx_buff, NULL);
IDirect3DDevice9_CreateVertexBuffer(pD3DDev9, shaderstate.dynst_size, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &shaderstate.dynst_buff[tmu], NULL);
IDirect3DDevice9_CreateVertexBuffer(pD3DDev9, shaderstate.dyncol_size, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, 0, D3DPOOL_DEFAULT, &shaderstate.dyncol_buff, NULL);
IDirect3DDevice9_CreateIndexBuffer(pD3DDev9, shaderstate.dynidx_size, D3DUSAGE_DYNAMIC|D3DUSAGE_WRITEONLY, D3DFMT_QINDEX, D3DPOOL_DEFAULT, &shaderstate.dynidx_buff, NULL);
for (i = 0; i < D3D_VDEC_MAX; i++)
{
@ -326,10 +337,10 @@ static void D3DBE_ApplyShaderBits(unsigned int bits)
}
}
static void allocvertexbuffer(IDirect3DVertexBuffer9 *buff, unsigned int *offset, void **data, unsigned int bytes)
static void allocvertexbuffer(IDirect3DVertexBuffer9 *buff, unsigned int bmaxsize, unsigned int *offset, void **data, unsigned int bytes)
{
unsigned int boff;
if (*offset + bytes > DYNVBUFFSIZE)
if (*offset + bytes > bmaxsize)
{
boff = 0;
*offset = bytes;
@ -339,7 +350,7 @@ static void allocvertexbuffer(IDirect3DVertexBuffer9 *buff, unsigned int *offset
boff = *offset;
*offset += bytes;
}
IDirect3DVertexBuffer9_Lock(buff, boff, bytes, data, boff?D3DLOCK_NOOVERWRITE:D3DLOCK_DISCARD);
d3dcheck(IDirect3DVertexBuffer9_Lock(buff, boff, bytes, data, boff?D3DLOCK_NOOVERWRITE:D3DLOCK_DISCARD));
}
static unsigned int allocindexbuffer(void **dest, unsigned int entries)
@ -358,7 +369,7 @@ static unsigned int allocindexbuffer(void **dest, unsigned int entries)
shaderstate.dynidx_offs += bytes;
}
IDirect3DIndexBuffer9_Lock(shaderstate.dynidx_buff, offset, entries, dest, offset?D3DLOCK_NOOVERWRITE:D3DLOCK_DISCARD);
d3dcheck(IDirect3DIndexBuffer9_Lock(shaderstate.dynidx_buff, offset, entries, dest, offset?D3DLOCK_NOOVERWRITE:D3DLOCK_DISCARD));
return offset/sizeof(index_t);
}
@ -400,13 +411,27 @@ static void SelectPassTexture(unsigned int tu, shaderpass_t *pass)
break;
/*case T_GEN_CURRENTRENDER:
fixme
FIXME: no code to grab the current screen and convert to a texture
break;*/
case T_GEN_VIDEOMAP:
IDirect3DDevice9_SetTexture (pD3DDev9, tu, Media_UpdateForShader(pass->cin).ptr);
break;
}
/*lightmaps don't use mipmaps*/
if (pass->flags & SHADER_PASS_NOMIPMAP)
{
IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MIPFILTER, D3DTEXF_NONE);
IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
}
else
{
IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR);
IDirect3DDevice9_SetSamplerState(pD3DDev9, tu, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);
}
switch (pass->blendmode)
{
case GL_DOT3_RGB_ARB:
@ -442,8 +467,13 @@ static void SelectPassTexture(unsigned int tu, shaderpass_t *pass)
if (tu == 0)
{
IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_COLORARG2, D3DTA_CONSTANT);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_CONSTANT, shaderstate.passcolour);
if (shaderstate.passsinglecolour)
{
IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_COLORARG2, D3DTA_CONSTANT);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_CONSTANT, shaderstate.passcolour);
}
else
IDirect3DDevice9_SetTextureStageState(pD3DDev9, tu, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
}
}
@ -507,7 +537,7 @@ static void colourgenbyte(const shaderpass_t *pass, int cnt, const byte_vec4_t *
break;
case RGB_GEN_LIGHTING_DIFFUSE:
//collect lighting details for mobile entities
// if (!mesh->normals_array)
if (!mesh->normals_array)
{
block = D3DCOLOR_RGBA(255, 255, 255, 255);
while((cnt)--)
@ -515,10 +545,10 @@ static void colourgenbyte(const shaderpass_t *pass, int cnt, const byte_vec4_t *
((D3DCOLOR*)dst)[cnt] = block;
}
}
/* else
else
{
R_LightArraysByte(mesh->xyz_array, dst, cnt, mesh->normals_array);
}*/
}
break;
case RGB_GEN_WAVE:
{
@ -553,6 +583,7 @@ static void colourgenbyte(const shaderpass_t *pass, int cnt, const byte_vec4_t *
static void alphagenbyte(const shaderpass_t *pass, int cnt, const byte_vec4_t *src, byte_vec4_t *dst, const mesh_t *mesh)
{
/*FIXME: Skip this if the rgbgen did it*/
float *table;
unsigned char t;
float f;
@ -616,7 +647,7 @@ static void alphagenbyte(const shaderpass_t *pass, int cnt, const byte_vec4_t *s
}
break;
/*FIXME: specular not supported (most noticable on q3dm0)*/
/*case ALPHA_GEN_SPECULAR:
{
mat3_t axis;
@ -646,7 +677,6 @@ static void alphagenbyte(const shaderpass_t *pass, int cnt, const byte_vec4_t *s
static unsigned int BE_GenerateColourMods(unsigned int vertcount, const shaderpass_t *pass)
{
/*
unsigned int ret = 0;
unsigned char *map;
const mesh_t *m;
@ -658,57 +688,67 @@ static unsigned int BE_GenerateColourMods(unsigned int vertcount, const shaderpa
else
usearray = true;
if (usearray && meshlist->colors4b_array)
m = shaderstate.meshlist[0];
if (usearray && m->colors4b_array)
{
shaderstate.passsinglecolour = false;
shaderstate.passcolour = D3DCOLOR_RGBA(255,255,255,255);
ret |= D3D_VDEC_COL4B;
allocvertexbuffer(shaderstate.dyncol_buff, &shaderstate.dyncol_offs, (void**)&map, vertcount*sizeof(D3DCOLOR));
allocvertexbuffer(shaderstate.dyncol_buff, shaderstate.dyncol_size, &shaderstate.dyncol_offs, (void**)&map, vertcount*sizeof(D3DCOLOR));
for (vertcount = 0, mno = 0; mno < shaderstate.nummeshes; mno++)
{
m = shaderstate.meshlist[mno];
/*FIXME: rgba->bgra...*/
memcpy((char*)map+vertcount*sizeof(D3DCOLOR), m->colors4b_array, m->numvertexes*sizeof(D3DCOLOR));
vertcount += m->numvertexes;
}
IDirect3DVertexBuffer9_Unlock(shaderstate.dyncol_buff);
IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, shaderstate.dyncol_buff, shaderstate.dyncol_offs - vertcount*sizeof(D3DCOLOR), sizeof(D3DCOLOR));
d3dcheck(IDirect3DVertexBuffer9_Unlock(shaderstate.dyncol_buff));
d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, shaderstate.dyncol_buff, shaderstate.dyncol_offs - vertcount*sizeof(D3DCOLOR), sizeof(D3DCOLOR)));
}
else if (usearray && meshlist->colors4f_array)
else if (usearray && m->colors4f_array)
{
unsigned int v;
float *src;
shaderstate.passsinglecolour = false;
shaderstate.passcolour = D3DCOLOR_RGBA(255,255,255,255);
ret |= D3D_VDEC_COL4B;
allocvertexbuffer(shaderstate.dyncol_buff, &shaderstate.dyncol_offs, (void**)&map, vertcount*sizeof(D3DCOLOR));
for (m = meshlist, vertcount = 0; m; vertcount += m->numvertexes, m = m->next)
allocvertexbuffer(shaderstate.dyncol_buff, shaderstate.dyncol_size, &shaderstate.dyncol_offs, (void**)&map, vertcount*sizeof(D3DCOLOR));
for (vertcount = 0, mno = 0; mno < shaderstate.nummeshes; mno++)
{
m = shaderstate.meshlist[mno];
src = m->colors4f_array[0];
for (v = 0; v < m->numvertexes; v++)
{
map[0] = src[0]*255;
map[0] = src[2]*255;
map[1] = src[1]*255;
map[2] = src[2]*255;
map[2] = src[0]*255;
map[3] = src[3]*255;
/*FIXME: no clamping here*/
map += 4;
src += 4;
}
vertcount += m->numvertexes;
}
map -= vertcount*4;
colourgenbyte(pass, vertcount, (byte_vec4_t*)map, (byte_vec4_t*)map, meshlist);
alphagenbyte(pass, vertcount, (byte_vec4_t*)map, (byte_vec4_t*)map, meshlist);
IDirect3DVertexBuffer9_Unlock(shaderstate.dyncol_buff);
IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, shaderstate.dyncol_buff, shaderstate.dyncol_offs - vertcount*sizeof(D3DCOLOR), sizeof(D3DCOLOR));
/*FIXME: m is wrong. its the last ent only*/
colourgenbyte(pass, vertcount, (byte_vec4_t*)map, (byte_vec4_t*)map, m);
alphagenbyte(pass, vertcount, (byte_vec4_t*)map, (byte_vec4_t*)map, m);
d3dcheck(IDirect3DVertexBuffer9_Unlock(shaderstate.dyncol_buff));
d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, shaderstate.dyncol_buff, shaderstate.dyncol_offs - vertcount*sizeof(D3DCOLOR), sizeof(D3DCOLOR)));
}
else
{
shaderstate.passsinglecolour = true;
shaderstate.passcolour = D3DCOLOR_RGBA(255,255,255,255);
colourgenbyte(pass, 1, (byte_vec4_t*)&shaderstate.passcolour, (byte_vec4_t*)&shaderstate.passcolour, meshlist);
alphagenbyte(pass, 1, (byte_vec4_t*)&shaderstate.passcolour, (byte_vec4_t*)&shaderstate.passcolour, meshlist);
IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, NULL, 0, 0);
colourgenbyte(pass, 1, (byte_vec4_t*)&shaderstate.passcolour, (byte_vec4_t*)&shaderstate.passcolour, m);
alphagenbyte(pass, 1, (byte_vec4_t*)&shaderstate.passcolour, (byte_vec4_t*)&shaderstate.passcolour, m);
/*FIXME: just because there's no rgba set, there's no reason to assume it should be a single colour (unshaded ents)*/
d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 1, NULL, 0, 0));
}
return ret;
*/
}
/*********************************************************************************************************/
/*========================================== texture coord generation =====================================*/
@ -864,38 +904,38 @@ static void tcmod(const tcmod_t *tcmod, int cnt, const float *src, float *dst, c
}
}
static void GenerateTCMods(const shaderpass_t *pass, float *dest, const mesh_t *meshlist)
static void GenerateTCMods(const shaderpass_t *pass, float *dest)
{
/*
unsigned int fvertex = 0;
for (; meshlist; meshlist = meshlist->next)
mesh_t *mesh;
unsigned int fvertex = 0, mno;
int i;
float *src;
for (mno = 0; mno < shaderstate.nummeshes; mno++)
{
int i;
float *src;
src = tcgen(pass, meshlist->numvertexes, dest, meshlist);
mesh = shaderstate.meshlist[mno];
src = tcgen(pass, mesh->numvertexes, dest, mesh);
//tcgen might return unmodified info
if (pass->numtcmods)
{
tcmod(&pass->tcmods[0], meshlist->numvertexes, src, dest, meshlist);
tcmod(&pass->tcmods[0], mesh->numvertexes, src, dest, mesh);
for (i = 1; i < pass->numtcmods; i++)
{
tcmod(&pass->tcmods[i], meshlist->numvertexes, dest, dest, meshlist);
tcmod(&pass->tcmods[i], mesh->numvertexes, dest, dest, mesh);
}
}
else if (src != dest)
{
memcpy(dest, src, 8*meshlist->numvertexes);
memcpy(dest, src, 8*mesh->numvertexes);
}
dest += meshlist->numvertexes*2;
dest += mesh->numvertexes*2;
}
*/
}
//end texture coords
/*******************************************************************************************************************/
/*does not do the draw call, does not consider indicies (except for billboard generation) */
static void BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcount, mesh_t *meshchain)
static void BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcount)
{
int vdec;
void *map;
@ -931,15 +971,15 @@ static void BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcoun
SelectPassTexture(passno, pass+passno);
vdec |= D3D_VDEC_ST0<<passno;
allocvertexbuffer(shaderstate.dynst_buff[passno], &shaderstate.dynst_offs[passno], &map, vertcount*sizeof(vec2_t));
GenerateTCMods(pass+passno, map, meshchain);
IDirect3DVertexBuffer9_Unlock(shaderstate.dynst_buff[passno]);
IDirect3DDevice9_SetStreamSource(pD3DDev9, 5+passno, shaderstate.dynst_buff[passno], shaderstate.dynst_offs[passno] - vertcount*sizeof(vec2_t), sizeof(vec2_t));
allocvertexbuffer(shaderstate.dynst_buff[passno], shaderstate.dynst_size, &shaderstate.dynst_offs[passno], &map, vertcount*sizeof(vec2_t));
GenerateTCMods(pass+passno, map);
d3dcheck(IDirect3DVertexBuffer9_Unlock(shaderstate.dynst_buff[passno]));
d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 5+passno, shaderstate.dynst_buff[passno], shaderstate.dynst_offs[passno] - vertcount*sizeof(vec2_t), sizeof(vec2_t)));
}
for (; passno < shaderstate.lastpasscount; passno++)
{
IDirect3DDevice9_SetStreamSource(pD3DDev9, 5+passno, NULL, 0, 0);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, passno, D3DTSS_COLOROP, D3DTOP_DISABLE);
d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 5+passno, NULL, 0, 0));
d3dcheck(IDirect3DDevice9_SetTextureStageState(pD3DDev9, passno, D3DTSS_COLOROP, D3DTOP_DISABLE));
}
shaderstate.lastpasscount = lastpass;
@ -951,7 +991,7 @@ static void BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcoun
if (vdec != shaderstate.curvertdecl)
{
shaderstate.curvertdecl = vdec;
IDirect3DDevice9_SetVertexDeclaration(pD3DDev9, vertexdecls[shaderstate.curvertdecl]);
d3dcheck(IDirect3DDevice9_SetVertexDeclaration(pD3DDev9, vertexdecls[shaderstate.curvertdecl]));
}
D3DBE_ApplyShaderBits(pass->shaderbits);
@ -959,61 +999,58 @@ static void BE_DrawMeshChain_SetupPass(shaderpass_t *pass, unsigned int vertcoun
static void BE_DrawMeshChain_Internal(void)
{
#ifdef FIXME
unsigned int vertcount, idxcount, idxfirst;
mesh_t *m;
void *map;
int i;
unsigned int mno;
unsigned int passno = 0;
shaderpass_t *pass = shaderstate.curshader->passes;
for (m = meshchain, vertcount = 0, idxcount = 0; m; m = m->next)
for (mno = 0, vertcount = 0, idxcount = 0; mno < shaderstate.nummeshes; mno++)
{
m = shaderstate.meshlist[mno];
vertcount += m->numvertexes;
idxcount += m->numindexes;
}
/*vertex buffers are common to all passes*/
allocvertexbuffer(shaderstate.dynxyz_buff, &shaderstate.dynxyz_offs, &map, vertcount*sizeof(vecV_t));
for (m = meshchain, vertcount = 0; m; vertcount += m->numvertexes, m = m->next)
allocvertexbuffer(shaderstate.dynxyz_buff, shaderstate.dynxyz_size, &shaderstate.dynxyz_offs, &map, vertcount*sizeof(vecV_t));
for (mno = 0, vertcount = 0; mno < shaderstate.nummeshes; mno++)
{
m = shaderstate.meshlist[mno];
/*fixme: no tcgen*/
memcpy((char*)map+vertcount*sizeof(vecV_t), m->xyz_array, m->numvertexes*sizeof(vecV_t));
vertcount += m->numvertexes;
}
IDirect3DVertexBuffer9_Unlock(shaderstate.dynxyz_buff);
IDirect3DDevice9_SetStreamSource(pD3DDev9, 0, shaderstate.dynxyz_buff, shaderstate.dynxyz_offs - vertcount*sizeof(vecV_t), sizeof(vecV_t));
d3dcheck(IDirect3DVertexBuffer9_Unlock(shaderstate.dynxyz_buff));
d3dcheck(IDirect3DDevice9_SetStreamSource(pD3DDev9, 0, shaderstate.dynxyz_buff, shaderstate.dynxyz_offs - vertcount*sizeof(vecV_t), sizeof(vecV_t)));
/*so are index buffers*/
idxfirst = allocindexbuffer(&map, idxcount);
for (m = meshchain, vertcount = 0; m; vertcount += m->numvertexes, m = m->next)
for (mno = 0, vertcount = 0; mno < shaderstate.nummeshes; mno++)
{
m = shaderstate.meshlist[mno];
for (i = 0; i < m->numindexes; i++)
((index_t*)map)[i] = m->indexes[i]+vertcount;
map = (char*)map + m->numindexes*sizeof(index_t);
vertcount += m->numvertexes;
}
IDirect3DIndexBuffer9_Unlock(shaderstate.dynidx_buff);
IDirect3DDevice9_SetIndices(pD3DDev9, shaderstate.dynidx_buff);
d3dcheck(IDirect3DIndexBuffer9_Unlock(shaderstate.dynidx_buff));
d3dcheck(IDirect3DDevice9_SetIndices(pD3DDev9, shaderstate.dynidx_buff));
/*now go through and flush each pass*/
for (passno = 0; passno < shaderstate.curshader->numpasses; passno += pass->numMergedPasses)
{
BE_DrawMeshChain_SetupPass(pass+passno, vertcount, meshchain);
IDirect3DDevice9_DrawIndexedPrimitive(pD3DDev9, D3DPT_TRIANGLELIST, 0, 0, vertcount, idxfirst, idxcount/3);
BE_DrawMeshChain_SetupPass(pass+passno, vertcount);
d3dcheck(IDirect3DDevice9_DrawIndexedPrimitive(pD3DDev9, D3DPT_TRIANGLELIST, 0, 0, vertcount, idxfirst, idxcount/3));
}
#endif
}
/*
void BE_DrawMeshChain(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, texnums_t *texnums)
{
shaderstate.curshader = shader;
shaderstate.curtexnums = texnums;
shaderstate.meshlist = meshchain;
shaderstate.nummeshes = 1;
BE_DrawMeshChain_Internal();
}*/
void BE_SelectMode(backendmode_t mode, unsigned int flags)
{
shaderstate.mode = mode;
shaderstate.flags = flags;
}
void _CrtCheckMemory(void);
@ -1174,66 +1211,23 @@ void BE_ClearVBO(vbo_t *vbo)
}
/*upload all lightmaps at the start to reduce lags*/
void BE_UploadAllLightmaps(void)
void BE_UploadLightmaps(qboolean force)
{
}
static void DrawSurfaceChain(msurface_t *s, shader_t *shader, vbo_t *vbo)
{ //doesn't merge surfaces, but tells gl to do each vertex arrayed surface individually, which means no vertex copying.
#ifdef FIXME
int i;
mesh_t *ml, *m;
if (!vbo)
return;
shaderstate.curshader = shader;
shaderstate.curtexnums = &shader->defaulttextures;
ml = NULL;
for (; s ; s=s->texturechain)
{
m = s->mesh;
if (!m) //urm.
continue;
if (m->numvertexes <= 1)
continue;
if (s->lightmaptexturenum < 0)
{
//pull out the surfaces with no lightmap info
m->next = ml;
ml = m;
}
else
{
//surfaces that do have a lightmap
m->next = lightmap[s->lightmaptexturenum]->meshchain;
lightmap[s->lightmaptexturenum]->meshchain = m;
}
}
if (ml)
{
//draw the lightmapless surfaces
BE_DrawMeshChain_Internal(ml);
}
//and then draw the lit chains
for (i = 0; i < numlightmaps; i++)
{
if (!lightmap[i] || !lightmap[i]->meshchain)
if (!lightmap[i])
continue;
if (force)
{
lightmap[i]->rectchange.l = 0;
lightmap[i]->rectchange.t = 0;
lightmap[i]->rectchange.w = LMBLOCK_WIDTH;
lightmap[i]->rectchange.h = LMBLOCK_HEIGHT;
}
if (lightmap[i]->modified)
{
IDirect3DTexture9 *tex = lightmap_textures[i].ptr;
@ -1261,57 +1255,196 @@ static void DrawSurfaceChain(msurface_t *s, shader_t *shader, vbo_t *vbo)
theRect->w = 0;
}
else
lightmap_textures[i] = D3D_AllocNewTexture(LMBLOCK_WIDTH, LMBLOCK_WIDTH);
/*
if (lightmap[i]->deluxmodified)
{
lightmap[i]->deluxmodified = false;
theRect = &lightmap[i]->deluxrectchange;
GL_Bind(deluxmap_textures[i]);
qglTexSubImage2D(GL_TEXTURE_2D, 0, 0, theRect->t,
LMBLOCK_WIDTH, theRect->h, GL_RGB, GL_UNSIGNED_BYTE,
lightmap[i]->deluxmaps+(theRect->t) *LMBLOCK_WIDTH*3);
theRect->l = LMBLOCK_WIDTH;
theRect->t = LMBLOCK_HEIGHT;
theRect->h = 0;
theRect->w = 0;
checkerror();
}
*/
lightmap_textures[i] = R_AllocNewTexture(LMBLOCK_WIDTH, LMBLOCK_HEIGHT);
}
}
}
shaderstate.curlightmap = lightmap_textures[i];
shaderstate.curdeluxmap = deluxmap_textures[i];
BE_DrawMeshChain_Internal(lightmap[i]->meshchain);
lightmap[i]->meshchain = NULL;
void BE_UploadAllLightmaps(void)
{
BE_UploadLightmaps(true);
}
qboolean BE_LightCullModel(vec3_t org, model_t *model)
{
#ifdef RTLIGHTS
if ((shaderstate.mode == BEM_LIGHT || shaderstate.mode == BEM_STENCIL))
{
/*true if hidden from current light*/
/*we have no rtlight support, so mneh*/
}
#endif
return false;
}
static void BE_BaseTextureChain(msurface_t *first)
batch_t *BE_GetTempBatch(void)
{
texture_t *t, *tex;
shader_t *shader;
t = first->texinfo->texture;
tex = R_TextureAnimation (t);
/*FIXME: utterly evil*/
return malloc(sizeof(batch_t));
}
//TEMP: use shader as an input parameter, not tex.
shader = tex->shader;
if (!shader)
static void BE_RotateForEntity (const entity_t *e, const model_t *mod)
{
float mv[16];
float m[16];
m[0] = e->axis[0][0];
m[1] = e->axis[0][1];
m[2] = e->axis[0][2];
m[3] = 0;
m[4] = e->axis[1][0];
m[5] = e->axis[1][1];
m[6] = e->axis[1][2];
m[7] = 0;
m[8] = e->axis[2][0];
m[9] = e->axis[2][1];
m[10] = e->axis[2][2];
m[11] = 0;
m[12] = e->origin[0];
m[13] = e->origin[1];
m[14] = e->origin[2];
m[15] = 1;
if (e->scale != 1 && e->scale != 0) //hexen 2 stuff
{
shader = R_RegisterShader_Lightmap(tex->name);
tex->shader = shader;
float z;
float escale;
escale = e->scale;
switch(e->drawflags&SCALE_TYPE_MASKIN)
{
default:
case SCALE_TYPE_UNIFORM:
VectorScale((m+0), escale, (m+0));
VectorScale((m+4), escale, (m+4));
VectorScale((m+8), escale, (m+8));
break;
case SCALE_TYPE_XYONLY:
VectorScale((m+0), escale, (m+0));
VectorScale((m+4), escale, (m+4));
break;
case SCALE_TYPE_ZONLY:
VectorScale((m+8), escale, (m+8));
break;
}
if (mod && (e->drawflags&SCALE_TYPE_MASKIN) != SCALE_TYPE_XYONLY)
{
switch(e->drawflags&SCALE_ORIGIN_MASKIN)
{
case SCALE_ORIGIN_CENTER:
z = ((mod->maxs[2] + mod->mins[2]) * (1-escale))/2;
VectorMA((m+12), z, e->axis[2], (m+12));
break;
case SCALE_ORIGIN_BOTTOM:
VectorMA((m+12), mod->mins[2]*(1-escale), e->axis[2], (m+12));
break;
case SCALE_ORIGIN_TOP:
VectorMA((m+12), -mod->maxs[2], e->axis[2], (m+12));
break;
}
}
}
else if (mod && !strcmp(mod->name, "progs/eyes.mdl"))
{
/*resize eyes, to make them easier to see*/
m[14] -= (22 + 8);
VectorScale((m+0), 2, (m+0));
VectorScale((m+4), 2, (m+4));
VectorScale((m+8), 2, (m+8));
}
if (mod && !ruleset_allow_larger_models.ival && mod->clampscale != 1)
{ //possibly this should be on a per-frame basis, but that's a real pain to do
Con_DPrintf("Rescaling %s by %f\n", mod->name, mod->clampscale);
VectorScale((m+0), mod->clampscale, (m+0));
VectorScale((m+4), mod->clampscale, (m+4));
VectorScale((m+8), mod->clampscale, (m+8));
}
if (e->flags & Q2RF_WEAPONMODEL && r_refdef.currentplayernum>=0)
{
float *Matrix4_NewRotation(float a, float x, float y, float z);
/*FIXME: no bob*/
float iv[16];
Matrix4_Invert(r_refdef.m_view, iv);
Matrix4_NewRotation(90, 1, 0, 0);
Matrix4_Multiply(iv, m, mv);
Matrix4_Multiply(mv, Matrix4_NewRotation(-90, 1, 0, 0), iv);
Matrix4_Multiply(iv, Matrix4_NewRotation(90, 0, 0, 1), mv);
m[2] *= 0.1;
m[6] *= 0.1;
m[10] *= 0.1;
IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_WORLD, (D3DMATRIX*)mv);
}
else
{
IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_WORLD, (D3DMATRIX*)m);
}
DrawSurfaceChain(first, shader, &t->vbo);
}
void BE_BaseEntTextures(void)
static void BE_SubmitBatch(batch_t *batch)
{
shaderstate.nummeshes = batch->meshes - batch->firstmesh;
if (!shaderstate.nummeshes)
return;
if (shaderstate.curentity != batch->ent)
{
shaderstate.curentity = batch->ent;
BE_RotateForEntity(batch->ent, batch->ent->model);
}
shaderstate.meshlist = batch->mesh + batch->firstmesh;
shaderstate.curshader = batch->shader;
shaderstate.curtexnums = batch->skin;
if (batch->lightmap < 0)
shaderstate.curlightmap = r_nulltex;
else
shaderstate.curlightmap = lightmap_textures[batch->lightmap];
BE_DrawMeshChain_Internal();
}
void BE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **meshlist, vbo_t *vbo, texnums_t *texnums)
{
shaderstate.curshader = shader;
shaderstate.curtexnums = texnums;
shaderstate.curlightmap = r_nulltex;
shaderstate.meshlist = meshlist;
shaderstate.nummeshes = nummeshes;
BE_DrawMeshChain_Internal();
}
void BE_DrawMesh_Single(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, texnums_t *texnums)
{
shaderstate.curshader = shader;
shaderstate.curtexnums = texnums?texnums:&shader->defaulttextures;
shaderstate.curlightmap = r_nulltex;
shaderstate.meshlist = &meshchain;
shaderstate.nummeshes = 1;
BE_DrawMeshChain_Internal();
}
qboolean BE_ShouldDraw(entity_t *e)
{
if (!r_refdef.externalview && (e->externalmodelview & (1<<r_refdef.currentplayernum)))
return false;
if (!Cam_DrawPlayer(r_refdef.currentplayernum, e->keynum-1))
return false;
return true;
}
static void BE_GenModelBatches(batch_t **batches)
{
extern model_t *currentmodel;
int i;
entity_t *ent;
/*clear the batch list*/
for (i = 0; i < SHADER_SORT_COUNT; i++)
batches[i] = NULL;
if (!r_drawentities.ival)
return;
@ -1323,50 +1456,84 @@ void BE_BaseEntTextures(void)
continue;
if (ent->model->needload)
continue;
// if (!PPL_ShouldDraw())
// continue;
if (!BE_ShouldDraw(ent))
continue;
switch(ent->model->type)
{
case mod_brush:
// BaseBrushTextures(ent);
if (r_drawentities.ival == 2)
continue;
Surf_GenBrushBatches(batches, ent);
break;
case mod_alias:
R_DrawGAliasModel (ent, BEM_STANDARD);
if (r_drawentities.ival == 3)
continue;
R_GAlias_GenerateBatches(ent, batches);
break;
}
}
}
void BE_SubmitMeshes (void)
static void BE_SubmitMeshesSortList(batch_t *sortlist)
{
texture_t *t;
msurface_t *s;
int i;
model_t *model = cl.worldmodel;
unsigned int fl;
for (i=0 ; i<model->numtextures ; i++)
batch_t *batch;
for (batch = sortlist; batch; batch = batch->next)
{
t = model->textures[i];
if (!t)
continue;
s = t->texturechain;
if (!s)
if (batch->meshes == batch->firstmesh)
continue;
fl = s->texinfo->texture->shader->flags;
BE_BaseTextureChain(s);
if (batch->buildmeshes)
batch->buildmeshes(batch);
else
{
batch->shader = R_TextureAnimation(batch->ent->framestate.g[FS_REG].frame[0], batch->texture)->shader;
batch->skin = &batch->shader->defaulttextures;
}
if (batch->shader->flags & SHADER_NODLIGHT)
if (shaderstate.mode == BEM_LIGHT || shaderstate.mode == BEM_SMAPLIGHT)
continue;
if (batch->shader->flags & SHADER_SKY)
{
// if (shaderstate.mode == BEM_STANDARD)
// R_DrawSkyChain (batch);
continue;
}
BE_SubmitBatch(batch);
}
}
BE_BaseEntTextures();
void BE_SubmitMeshes (qboolean drawworld, batch_t **blist)
{
model_t *model = cl.worldmodel;
int i;
for (i = SHADER_SORT_PORTAL; i < SHADER_SORT_COUNT; i++)
{
if (drawworld)
{
// if (i == SHADER_SORT_PORTAL && !r_noportals.ival && !r_refdef.recurse)
// BE_SubmitMeshesPortals(model->batches, blist[i]);
BE_SubmitMeshesSortList(model->batches[i]);
}
BE_SubmitMeshesSortList(blist[i]);
}
}
void BE_DrawWorld (qbyte *vis)
{
batch_t *batches[SHADER_SORT_COUNT];
RSpeedLocals();
BE_GenModelBatches(batches);
shaderstate.curtime = realtime;
BE_UploadLightmaps(false);
//make sure the world draws correctly
r_worldentity.shaderRGBAf[0] = 1;
r_worldentity.shaderRGBAf[1] = 1;
@ -1379,8 +1546,10 @@ void BE_DrawWorld (qbyte *vis)
BE_SelectMode(BEM_STANDARD, 0);
RSpeedRemark();
BE_SubmitMeshes();
BE_SubmitMeshes(true, batches);
RSpeedEnd(RSPEED_WORLD);
BE_RotateForEntity(&r_worldentity, NULL);
}

View file

@ -40,7 +40,7 @@ static d3dtexture_t *d3d_lookup_texture(char *ident)
extern cvar_t gl_picmip;
extern cvar_t gl_picmip2d;
texid_t D3D_AllocNewTexture(int width, int height)
texid_t D3D9_AllocNewTexture(int width, int height)
{
IDirect3DTexture9 *tx;
texid_t ret = r_nulltex;
@ -49,6 +49,12 @@ texid_t D3D_AllocNewTexture(int width, int height)
return ret;
}
void D3D9_DestroyTexture (texid_t tex)
{
IDirect3DTexture9 *tx = tex.ptr;
IDirect3DTexture9_Release(tx);
}
static void D3D9_RoundDimensions(int *scaled_width, int *scaled_height, qboolean mipmap)
{
// if (gl_config.arb_texture_non_power_of_two) //NPOT is a simple extension that relaxes errors.
@ -295,7 +301,7 @@ static LPDIRECT3DBASETEXTURE9 D3D9_LoadTexture_8(d3dtexture_t *tex, unsigned cha
return D3D9_LoadTexture_32(tex, trans, width, height, flags);
}
void D3D_UploadFmt(texid_t tex, char *name, enum uploadfmt fmt, void *data, int width, int height, unsigned int flags)
void D3D9_Upload (texid_t tex, char *name, enum uploadfmt fmt, void *data, void *palette, int width, int height, unsigned int flags)
{
switch (fmt)
{
@ -308,7 +314,7 @@ void D3D_UploadFmt(texid_t tex, char *name, enum uploadfmt fmt, void *data, int
}
}
texid_t D3D_LoadTextureFmt (char *identifier, int width, int height, enum uploadfmt fmt, void *data, unsigned int flags)
texid_t D3D9_LoadTexture (char *identifier, int width, int height, enum uploadfmt fmt, void *data, unsigned int flags)
{
texid_t tid;
d3dtexture_t *tex;
@ -333,23 +339,24 @@ texid_t D3D_LoadTextureFmt (char *identifier, int width, int height, enum upload
}
}
texid_t D3D_LoadCompressed(char *name)
texid_t D3D9_LoadCompressed (char *name)
{
return r_nulltex;
}
texid_t D3D_FindTexture (char *identifier)
texid_t D3D9_FindTexture (char *identifier)
{
d3dtexture_t *tex = d3d_lookup_texture(identifier);
return tex->tex;
}
texid_t D3D_LoadTexture8Pal32 (char *identifier, int width, int height, qbyte *data, qbyte *palette32, unsigned int flags)
texid_t D3D9_LoadTexture8Pal32 (char *identifier, int width, int height, qbyte *data, qbyte *palette32, unsigned int flags)
{
return r_nulltex;
}
texid_t D3D_LoadTexture8Pal24 (char *identifier, int width, int height, qbyte *data, qbyte *palette24, unsigned int flags)
texid_t D3D9_LoadTexture8Pal24 (char *identifier, int width, int height, qbyte *data, qbyte *palette24, unsigned int flags)
{
return r_nulltex;
}
#endif

View file

@ -1,10 +1,11 @@
#include "quakedef.h"
#include "gl_draw.h"
#include "shader.h"
#include "renderque.h"
#ifdef D3DQUAKE
#include "winquake.h"
//#include "d3d9quake.h"
#include "d3d9quake.h"
#include "d3d9.h"
@ -438,7 +439,7 @@ static void initD3D9(HWND hWnd, rendererstate_t *info)
d3dpp.BackBufferWidth = info->width;
d3dpp.BackBufferHeight = info->height;
d3dpp.MultiSampleType = info->multisample;
d3dpp.BackBufferCount = 3;
d3dpp.BackBufferCount = 1;
d3dpp.FullScreen_RefreshRateInHz = info->fullscreen?info->rate:0; //don't pass a rate if not fullscreen, d3d doesn't like it.
d3dpp.Windowed = !info->fullscreen;
@ -465,12 +466,13 @@ static void initD3D9(HWND hWnd, rendererstate_t *info)
memset(&inf, 0, sizeof(inf));
err = IDirect3D9_GetAdapterIdentifier(pD3D, i, 0, &inf);
pD3DDev9 = NULL;
// create a device class using this information and information from the d3dpp stuct
IDirect3D9_CreateDevice(pD3D,
err = IDirect3D9_CreateDevice(pD3D,
i,
D3DDEVTYPE_HAL,
hWnd,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_FPU_PRESERVE,
&d3dpp,
&pD3DDev9);
@ -510,12 +512,20 @@ static void initD3D9(HWND hWnd, rendererstate_t *info)
}
return; //successful
}
else
{
char *s;
switch(err)
{
default: s = "Unkown error"; break;
case D3DERR_DEVICELOST: s = "Device lost"; break;
case D3DERR_INVALIDCALL: s = "Invalid call"; break;
case D3DERR_NOTAVAILABLE: s = "Not available"; break;
case D3DERR_OUTOFVIDEOMEMORY: s = "Out of video memory"; break;
}
Con_Printf("IDirect3D9_CreateDevice failed: %s.\n", s);
}
}
Con_Printf("IDirect3D9_CreateDevice failed\n");
return;
}
@ -735,7 +745,7 @@ void D3D9_Set2D (void)
D3DVIEWPORT9 vport;
// IDirect3DDevice9_EndScene(pD3DDev9);
Matrix4_OrthographicD3D(m, 0 + (0.5*vid.width/vid.pixelwidth), vid.width + (0.5*vid.width/vid.pixelwidth), 0 + (0.5*vid.height/vid.pixelheight), vid.height + (0.5*vid.height/vid.pixelheight), -100, 100);
Matrix4_OrthographicD3D(m, 0 + (0.5*vid.width/vid.pixelwidth), vid.width + (0.5*vid.width/vid.pixelwidth), 0 + (0.5*vid.height/vid.pixelheight), vid.height + (0.5*vid.height/vid.pixelheight), 0, 100);
IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_PROJECTION, (D3DMATRIX*)m);
Matrix4_Identity(m);
@ -804,8 +814,8 @@ static void (D3D9_SCR_UpdateScreen) (void)
if (keydown['k'])
{
d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(rand()&255, rand()&255, rand()&255), 1.0f, 0));
d3d9error(IDirect3DDevice9_BeginScene(pD3DDev9));
d3d9error(IDirect3DDevice9_Clear(pD3DDev9, 0, NULL, D3DCLEAR_TARGET, D3DCOLOR_XRGB(rand()&255, rand()&255, rand()&255), 1.0f, 0));
d3d9error(IDirect3DDevice9_EndScene(pD3DDev9));
d3d9error(IDirect3DDevice9_Present(pD3DDev9, NULL, NULL, NULL, NULL));
@ -1083,11 +1093,10 @@ static void D3D9_SetupViewPort(void)
}
screenaspect = (float)r_refdef.vrect.width/r_refdef.vrect.height;
GL_InfinatePerspective(fov_x, fov_y, gl_mindist.value);
Matrix4_Projection_Inf(r_refdef.m_projection, fov_x, fov_y, gl_mindist.value);
Matrix4_ModelViewMatrixFromAxis(r_refdef.m_view, vpn, vright, vup, r_refdef.vieworg);
IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_PROJECTION, (D3DMATRIX*)r_refdef.m_projection);
IDirect3DDevice9_SetTransform(pD3DDev9, D3DTS_VIEW, (D3DMATRIX*)r_refdef.m_view);
}
@ -1100,6 +1109,7 @@ static void (D3D9_R_RenderView) (void)
if (!(r_refdef.flags & Q2RDF_NOWORLDMODEL))
Surf_DrawWorld();
P_DrawParticles ();
RQ_RenderBatchClear();
}
void (D3D9_R_NewMap) (void);
@ -1154,6 +1164,15 @@ rendererinfo_t d3drendererinfo =
R2D_Image,
R2D_ImageColours,
D3D9_LoadTexture,
D3D9_LoadTexture8Pal24,
D3D9_LoadTexture8Pal32,
D3D9_LoadCompressed,
D3D9_FindTexture,
D3D9_AllocNewTexture,
D3D9_Upload,
D3D9_DestroyTexture,
D3D9_R_Init,
D3D9_R_DeInit,
D3D9_R_RenderView,

View file

@ -12,33 +12,20 @@
// d3d9_draw.c
//
void D3D9_Draw_Alt_String (int x, int y, const qbyte *str);
void D3D9_Draw_BeginDisc (void);
mpic_t* D3D9_Draw_CachePic (char *path);
void D3D9_Draw_Character (int x, int y, unsigned int num);
void D3D9_Draw_ColouredCharacter (int x, int y, unsigned int num);
void D3D9_Draw_ConsoleBackground (int firstline, int lastline, qboolean forceopaque);
void D3D9_Draw_Crosshair (void);
void D3D9_Draw_DebugChar (qbyte num);
void D3D9_Draw_EditorBackground (int lines);
void D3D9_Draw_EndDisc (void);
void D3D9_Draw_FadeScreen (void);
void D3D9_Draw_Fill (int x, int y, int w, int h, unsigned int c);
void D3D9_Draw_Fill_Colours (int x, int y, int w, int h);
void D3D9_Draw_Fill_I (int x, int y, int w, int h, unsigned int imgcolour);
void D3D9_Draw_FillRGB (int x, int y, int w, int h, float r, float g, float b);
void D3D9_Draw_Image (float x, float y, float w, float h, float s1, float t1, float s2, float t2, mpic_t *pic);
void D3D9_Draw_ImageColours (float r, float g, float b, float a);
void D3D9_Draw_Init (void);
void D3D9_Draw_Pic (int x, int y, mpic_t *pic);
void D3D9_Draw_ReInit (void);
mpic_t* D3D9_Draw_SafeCachePic (char *path);
mpic_t* D3D9_Draw_SafePicFromWad (char *name);
void D3D9_Draw_ScalePic (int x, int y, int width, int height, mpic_t *pic);
void D3D9_Draw_String (int x, int y, const qbyte *str);
void D3D9_Draw_SubPic (int x, int y, int width, int height, mpic_t *pic, int srcx, int srcy, int srcwidth, int srcheight);
void D3D9_Draw_TileClear (int x, int y, int w, int h);
void D3D9_Draw_TransPic (int x, int y, mpic_t *pic);
void D3D9_Draw_TransPicTranslate (int x, int y, int w, int h, qbyte *pic, qbyte *translation);
void D3D9_InitParticleTexture (void);
LPDIRECT3DBASETEXTURE9 D3D9_LoadTexture_32 (char *name, unsigned int *data, int width, int height, int flags);
LPDIRECT3DBASETEXTURE9 D3D9_LoadTexture_8_Pal24 (char *name, unsigned char *data, int width, int height, int flags, unsigned char *palette, int transparentpix);
@ -54,7 +41,6 @@ static void Upload_Texture_32(LPDIRECT3DTEXTURE9 surf, unsigned int *data, in
//
// d3d9_mesh.c
//
static galiastexnum_t* D3D9_ChooseSkin (galiasinfo_t *inf, char *modelname, int surfnum, entity_t *e);
void D3D9_DrawAliasModel (void);
void D3D9_DrawMesh (mesh_t *mesh);
void d3d9_GAliasFlushSkinCache (void);
@ -74,16 +60,12 @@ void D3D9_DrawParticles (float ptime);
static void D3D9_DrawSpriteModel (entity_t *e);
void D3D9_DrawTextureChains (void);
void D3D9_DrawWorld (void);
void D3D9_R_DeInit (void);
void D3D9_R_DrawEntitiesOnList (void);
void D3D9_R_Init (void);
void D3D9_R_ReInit (void);
void D3D9_R_RenderScene (void);
void D3D9_R_RenderView (void);
static void D3D9_RecursiveQ2WorldNode (mnode_t *node);
static void D3D9_RecursiveWorldNode (mnode_t *node);
void D3D9_SetupFrame (void);
void D3D9_SetupViewPort (void);
qboolean D3D9_ShouldDraw (void);
void D3D9R_DrawSprite(int count, void **e, void *parm);
void IDirect3DDevice9_DrawIndexedPrimitive7 (LPDIRECT3DDEVICE9 pD3DDev9, int mode, int fvf, void *verts, int numverts, index_t *indicies, int numindicies, int wasted);
@ -106,7 +88,6 @@ void D3D9R_RenderDynamicLightmaps (msurface_t *fa, int shift);
//
void D3D9_D_BeginDirectRect (int x, int y, qbyte *pbitmap, int width, int height);
void D3D9_D_EndDirectRect (int x, int y, int width, int height);
void D3D9_GetBufferSize(int *width, int *height);
void D3D9_Mod_ClearAll (void);
void* D3D9_Mod_Extradata (struct model_s *mod);
struct model_s* D3D9_Mod_FindName (char *name);
@ -116,43 +97,22 @@ void D3D9_Mod_NowLoadExternal (void);
int D3D9_Mod_SkinForName (struct model_s *model, char *name);
void D3D9_Mod_Think (void);
void D3D9_Mod_TouchModel (char *name);
void D3D9_R_AddStain (vec3_t org, float red, float green, float blue, float radius);
qboolean D3D9_R_CheckSky (void);
void D3D9_R_LessenStains (void);
int D3D9_R_LightPoint (vec3_t point);
void D3D9_R_NewMap (void);
void D3D9_R_PreNewMap (void);
void D3D9_R_PushDlights (void);
void D3D9_SCR_UpdateScreen (void);
void D3D9_Set2D (void);
void D3D9_VID_DeInit (void);
void D3D9_VID_ForceLockState (int lk);
int D3D9_VID_ForceUnlockedAndReturnState (void);
void D3D9_VID_GenPaletteTables (unsigned char *palette);
char* D3D9_VID_GetRGBInfo (int prepad, int *truevidwidth, int *truevidheight);
qboolean D3D9_VID_Init (rendererstate_t *info, unsigned char *palette);
void D3D9_VID_LockBuffer (void);
void D3D9_VID_SetPalette (unsigned char *palette);
void D3D9_VID_SetWindowCaption (char *msg);
void D3D9_VID_ShiftPalette (unsigned char *palette);
void D3D9_VID_UnlockBuffer (void);
static LRESULT WINAPI D3D9_WindowProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
qboolean D3D9AppActivate (BOOL fActive, BOOL minimize);
int d3d9error (int i);
void initD3D9 (HWND hWnd, rendererstate_t *info);
void resetD3D9 (void);
#define D3D9_LoadTexture8Pal32(skinname,width,height,data,palette,usemips,alpha) (int)D3D9_LoadTexture_8_Pal32(skinname, data, width, height, (usemips?TF_MIPMAP:TF_NOMIPMAP) | (alpha?TF_ALPHA:TF_NOALPHA) | TF_NOTBUMPMAP, host_basepal)
#define D3D9_LoadTexture(skinname,width,height,data,usemips,alpha) (int)D3D9_LoadTexture_8_Pal24(skinname, data, width, height, (usemips?TF_MIPMAP:TF_NOMIPMAP) | (alpha?TF_ALPHA:TF_NOALPHA) | TF_NOTBUMPMAP, host_basepal, 255)
#define D3D9_LoadTexture32(skinname,width,height,data,usemips,alpha) (int)D3D9_LoadTexture_32(skinname, data, width, height, (usemips?TF_MIPMAP:TF_NOMIPMAP) | (alpha?TF_ALPHA:TF_NOALPHA) | TF_NOTBUMPMAP)
#define D3D9_LoadTextureFB(skinname,width,height,data,usemips,alpha) 0
#define D3D9_LoadTexture8Bump(skinname,width,height,data,usemips,alpha) 0
#define D3D9_FindTexture(name) -1
#define D3D9_LoadCompressed(name) 0
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 w, int h);
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);
extern LPDIRECT3DDEVICE9 pD3DDev9;

View file

@ -251,13 +251,12 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\client;../libs/freetype2/include;../common;../server;../gl;../sw;../qclib;../libs;../libs/dxsdk9/include;../libs/dxsdk7/include"
AdditionalIncludeDirectories="..\client;../libs/freetype2/include;../common;../server;../gl;../sw;../qclib;../libs;../d3d9;../libs/dxsdk9/include;../libs/dxsdk7/include"
PreprocessorDefinitions="_DEBUG;D3DQUAKE;WIN32;_WINDOWS"
RuntimeLibrary="1"
FloatingPointModel="2"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="quakedef.h"
PrecompiledHeaderFile=".\D3DDebug/qwcl.pch"
AssemblerListingLocation=".\D3DDebug/"
ObjectFile=".\D3DDebug/"
ProgramDataBaseFileName=".\D3DDebug/"
@ -355,13 +354,10 @@
AdditionalIncludeDirectories="..\client,../libs/freetype2/include,../common,../server,../gl,../sw,../qclib,../libs,../libs/dxsdk7/include,../d3d,../d3d9,../libs/dxsdk9/include"
PreprocessorDefinitions="_DEBUG;D3DQUAKE;WIN32;_WINDOWS"
RuntimeLibrary="1"
EnableFunctionLevelLinking="true"
FloatingPointModel="2"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="quakedef.h"
PrecompiledHeaderFile=".\D3DDebug/qwcl.pch"
AssemblerListingLocation=".\D3DDebug64/"
ObjectFile=".\D3DDebug64/"
ProgramDataBaseFileName=".\D3DDebug64/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
@ -382,10 +378,11 @@
<Tool
Name="VCLinkerTool"
AdditionalDependencies="comctl32.lib wsock32.lib winmm.lib odbc32.lib odbccp32.lib"
OutputFile="../../fted3dqw_dbg64.exe"
OutputFile="C:\Games\Quake\fte_wip\fted3dqw_dbg64.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="../libs/dxsdk7/lib"
GenerateManifest="false"
IgnoreDefaultLibraryNames="libc.lib;msvcrt.lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\D3DDebug/fted3dqw_dbg.pdb"
@ -399,6 +396,7 @@
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
@ -670,13 +668,10 @@
AdditionalIncludeDirectories="..\client,../libs/freetype2/include,../common,../server,../gl,../sw,../qclib,../libs,../libs/dxsdk7/include"
PreprocessorDefinitions="_DEBUG;GLQUAKE;WIN32;_WINDOWS;MULTITHREAD"
RuntimeLibrary="1"
EnableFunctionLevelLinking="true"
FloatingPointModel="2"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="quakedef.h"
PrecompiledHeaderFile=".\GLDebug/qwcl.pch"
AssemblerListingLocation=".\GLDebug/"
ObjectFile=".\GLDebug/"
ProgramDataBaseFileName=".\GLDebug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
@ -773,13 +768,10 @@
AdditionalIncludeDirectories="..\client,../libs/freetype2/include,../common,../server,../gl,../sw,../qclib,../libs,../libs/dxsdk7/include,../d3d,../d3d9,../libs/dxsdk9/include"
PreprocessorDefinitions="_DEBUG;GLQUAKE;WIN32;_WINDOWS;MULTITHREAD"
RuntimeLibrary="1"
EnableFunctionLevelLinking="true"
FloatingPointModel="2"
UsePrecompiledHeader="2"
PrecompiledHeaderThrough="quakedef.h"
PrecompiledHeaderFile=".\GLDebug/qwcl.pch"
AssemblerListingLocation=".\GLDebug/"
ObjectFile=".\GLDebug/"
ProgramDataBaseFileName=".\GLDebug/"
BrowseInformation="1"
WarningLevel="3"
SuppressStartupBanner="true"
@ -807,9 +799,7 @@
GenerateManifest="false"
IgnoreDefaultLibraryNames="libc.lib;msvcrt.lib"
GenerateDebugInformation="true"
ProgramDatabaseFile=".\GLDebug/fteglqw_dbg.pdb"
GenerateMapFile="true"
MapFileName=".\GLDebug/fteglqw_dbg.map"
SubSystem="2"
TargetMachine="17"
/>
@ -17058,6 +17048,7 @@
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
EnableFunctionLevelLinking="true"
/>
</FileConfiguration>
<FileConfiguration

View file

@ -14,9 +14,7 @@
#include "quakedef.h"
#ifdef GLQUAKE
#include "glquake.h"
#endif
#include "glquake.h"
#if defined(GLQUAKE) || defined(D3DQUAKE)
#ifdef _WIN32
@ -447,6 +445,11 @@ static texnums_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, int surfnum,
if (scaled_height > gl_max_size.value)
scaled_height = gl_max_size.value; //whoops, we made it too big
if (scaled_width < 4)
scaled_width = 4;
if (scaled_height < 4)
scaled_height = 4;
if (h2playertranslations && pc)
{
unsigned int color_offsets[5] = {2*14*256,0,1*14*256,2*14*256,2*14*256};
@ -908,15 +911,22 @@ void R_GAlias_DrawBatch(batch_t *batch)
nolightdir = R_CalcModelLighting(e, clmodel);
inf = RMod_Extradata (clmodel);
memset(&mesh, 0, sizeof(mesh));
for(surfnum=0; inf; ((inf->nextsurf)?(inf = (galiasinfo_t*)((char *)inf + inf->nextsurf)):(inf=NULL)), surfnum++)
if (inf)
{
if (batch->lightmap == surfnum)
memset(&mesh, 0, sizeof(mesh));
for(surfnum=0; inf; ((inf->nextsurf)?(inf = (galiasinfo_t*)((char *)inf + inf->nextsurf)):(inf=NULL)), surfnum++)
{
needrecolour = Alias_GAliasBuildMesh(&mesh, inf, e, e->shaderRGBAf[3], nolightdir);
batch->mesh = &meshl;
if (batch->surf_first == surfnum)
{
needrecolour = Alias_GAliasBuildMesh(&mesh, inf, e, e->shaderRGBAf[3], nolightdir);
batch->mesh = &meshl;
return;
}
}
}
batch->meshes = 0;
Con_Printf("Broken model surfaces mid-frame\n");
return;
}
void R_GAlias_GenerateBatches(entity_t *e, batch_t **batches)
@ -988,7 +998,10 @@ void R_GAlias_GenerateBatches(entity_t *e, batch_t **batches)
b->skin = skin;
b->texture = NULL;
b->shader = shader;
b->lightmap = surfnum;
b->lightmap = -1;
b->surf_first = surfnum;
b->flags = 0;
b->vbo = 0;
b->next = batches[shader->sort];
batches[shader->sort] = b;
}

View file

@ -824,7 +824,7 @@ void Shader_LightPass_Std(char *shortname, shader_t *s, const void *args)
{
char shadertext[8192*2];
sprintf(shadertext, LIGHTPASS_SHADER, defaultglsl2program);
FS_WriteFile("shader/lightpass.shader.builtin", shadertext, strlen(shadertext), FS_GAMEONLY);
// FS_WriteFile("shader/lightpass.shader.builtin", shadertext, strlen(shadertext), FS_GAMEONLY);
Shader_DefaultScript(shortname, s, shadertext);
}
void Shader_LightPass_PCF(char *shortname, shader_t *s, const void *args)
@ -939,6 +939,8 @@ static float *tcgen(const shaderpass_t *pass, int cnt, float *dst, const mesh_t
case TC_GEN_TVECTOR:
return (float*)mesh->tnormals_array;
case TC_GEN_ENVIRONMENT:
if (!mesh->normals_array)
return (float*)mesh->st_array;
tcgen_environment(dst, cnt, (float*)mesh->xyz_array, (float*)mesh->normals_array);
return dst;
@ -2612,176 +2614,6 @@ void BE_DrawMesh_Single(shader_t *shader, mesh_t *mesh, vbo_t *vbo, texnums_t *t
BE_DrawMesh_List(shader, 1, &mesh, NULL, texnums);
}
#if 0
static void BaseBrushTextures(entity_t *ent)
{
int i;
msurface_t *s, *chain;
model_t *model;
batch_t batch;
mesh_t *batchmeshes[64];
model = ent->model;
if (R_CullEntityBox (ent, model->mins, model->maxs))
return;
#ifdef RTLIGHTS
if (BE_LightCullModel(ent->origin, model))
return;
#endif
qglPushMatrix();
R_RotateForEntity(ent, model);
chain = NULL;
// calculate dynamic lighting for bmodel if it's not an
// instanced model
if (model->fromgame != fg_quake3)
{
int k;
int shift;
if (model->nummodelsurfaces != 0 && r_dynamic.value)
{
for (k=rtlights_first; k<RTL_FIRST; k++)
{
if (!cl_dlights[k].radius)
continue;
if (!(cl_dlights[k].flags & LFLAG_ALLOW_LMHACK))
continue;
model->funcs.MarkLights (&cl_dlights[k], 1<<k,
model->nodes + model->hulls[0].firstclipnode);
}
}
shift = Surf_LightmapShift(model);
if ((ent->drawflags & MLS_MASKIN) == MLS_ABSLIGHT)
{
//update lightmaps.
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
Surf_RenderAmbientLightmaps (s, shift, ent->abslight);
}
else if (ent->drawflags & DRF_TRANSLUCENT)
{
//update lightmaps.
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
Surf_RenderAmbientLightmaps (s, shift, 255);
}
else
{
//update lightmaps.
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
Surf_RenderDynamicLightmaps (s, shift);
}
}
memset(&batch, 0, sizeof(batch));
batch.maxmeshes = sizeof(batchmeshes)/sizeof(batchmeshes[0]);
batch.mesh = batchmeshes;
batch.lightmap = -1;
batch.texture = NULL;
batch.ent = ent;
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
{
if (batch.meshes == batch.maxmeshes || batch.lightmap != s->lightmaptexturenum || batch.texture != s->texinfo->texture)
{
if (batch.texture)
BE_SubmitBatch(&batch);
batch.texture = s->texinfo->texture;
batch.shader = R_TextureAnimation (batch.texture)->shader;
batch.lightmap = s->lightmaptexturenum;
batch.meshes = 0;
}
batch.mesh[batch.meshes++] = s->mesh;
}
if (batch.texture)
BE_SubmitBatch(&batch);
qglPopMatrix();
}
void BE_BaseEntShadowDepth(void)
{
int i;
entity_t *ent;
if (!r_drawentities.value)
return;
// draw sprites seperately, because of alpha blending
for (i=0 ; i<cl_numvisedicts ; i++)
{
ent = &cl_visedicts[i];
if (!ent->model)
continue;
if (ent->model->needload)
continue;
if (ent->flags & Q2RF_WEAPONMODEL)
continue;
switch(ent->model->type)
{
case mod_brush:
BaseBrushTextures(ent);
break;
case mod_alias:
R_DrawGAliasModel (ent, BEM_DEPTHONLY);
break;
}
}
}
/*void BE_BaseEntTextures(void)
{
int i;
unsigned int bef;
if (!r_drawentities.ival)
return;
// draw sprites seperately, because of alpha blending
for (i=0 ; i<cl_numvisedicts ; i++)
{
currententity = &cl_visedicts[i];
if (!currententity->model)
continue;
if (currententity->model->needload)
continue;
if (!R_ShouldDraw(currententity))
continue;
switch(currententity->model->type)
{
case mod_brush:
if (r_drawentities.ival == 2)
continue;
bef = BEF_PUSHDEPTH;
if (currententity->flags & Q2RF_ADDITIVE)
bef |= BEF_FORCEADDITIVE;
else if (currententity->drawflags & DRF_TRANSLUCENT && r_wateralpha.value != 1)
{
bef |= BEF_FORCETRANSPARENT;
currententity->shaderRGBAf[3] = r_wateralpha.value;
}
else if (currententity->shaderRGBAf[3] < 1 && cls.protocol != CP_QUAKE3)
bef |= BEF_FORCETRANSPARENT;
if (currententity->flags & RF_NODEPTHTEST)
bef |= BEF_FORCENODEPTH;
BE_SelectMode(shaderstate.mode, bef);
BaseBrushTextures(currententity);
break;
case mod_alias:
if (r_drawentities.ival == 3)
continue;
R_DrawGAliasModel (currententity, shaderstate.mode);
break;
}
}
}*/
#endif
void BE_DrawPolys(qboolean decalsset)
{
unsigned int i;
@ -3020,126 +2852,6 @@ static void BE_UpdateLightmaps(void)
}
}
static void BE_GenBrushBatches(batch_t **batches, entity_t *ent)
{
int i;
msurface_t *s;
model_t *model;
batch_t *b;
unsigned int bef;
model = ent->model;
if (R_CullEntityBox (ent, model->mins, model->maxs))
return;
#ifdef RTLIGHTS
if (BE_LightCullModel(ent->origin, model))
return;
#endif
// calculate dynamic lighting for bmodel if it's not an
// instanced model
if (model->fromgame != fg_quake3)
{
int k;
int shift;
currententity = ent;
currentmodel = ent->model;
if (model->nummodelsurfaces != 0 && r_dynamic.value)
{
for (k=rtlights_first; k<RTL_FIRST; k++)
{
if (!cl_dlights[k].radius)
continue;
if (!(cl_dlights[k].flags & LFLAG_ALLOW_LMHACK))
continue;
model->funcs.MarkLights (&cl_dlights[k], 1<<k,
model->nodes + model->hulls[0].firstclipnode);
}
}
shift = Surf_LightmapShift(model);
if ((ent->drawflags & MLS_MASKIN) == MLS_ABSLIGHT)
{
//update lightmaps.
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
Surf_RenderAmbientLightmaps (s, shift, ent->abslight);
}
else if (ent->drawflags & DRF_TRANSLUCENT)
{
//update lightmaps.
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
Surf_RenderAmbientLightmaps (s, shift, 255);
}
else
{
//update lightmaps.
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
Surf_RenderDynamicLightmaps (s, shift);
}
currententity = NULL;
}
bef = BEF_PUSHDEPTH;
if (ent->flags & Q2RF_ADDITIVE)
bef |= BEF_FORCEADDITIVE;
else if (ent->drawflags & DRF_TRANSLUCENT && r_wateralpha.value != 1)
{
bef |= BEF_FORCETRANSPARENT;
ent->shaderRGBAf[3] = r_wateralpha.value;
}
else if (ent->shaderRGBAf[3] < 1 && cls.protocol != CP_QUAKE3)
bef |= BEF_FORCETRANSPARENT;
if (ent->flags & RF_NODEPTHTEST)
bef |= BEF_FORCENODEPTH;
b = NULL;
for (s = model->surfaces+model->firstmodelsurface,i = 0; i < model->nummodelsurfaces; i++, s++)
{
if (!b || b->lightmap != s->lightmaptexturenum || b->texture != s->texinfo->texture)
{
if (shaderstate.wbatch >= shaderstate.maxwbatches)
{
shaderstate.wbatch++;
break; /*can't allocate any new ones!*/
}
b = &shaderstate.wbatches[shaderstate.wbatch++];
b->buildmeshes = NULL;
b->ent = ent;
b->texture = s->texinfo->texture;
b->shader = R_TextureAnimation(ent->framestate.g[FS_REG].frame[0], b->texture)->shader;
b->skin = &b->shader->defaulttextures;
b->flags = bef;
if (bef & BEF_FORCEADDITIVE)
{
b->next = batches[SHADER_SORT_ADDITIVE];
batches[SHADER_SORT_ADDITIVE] = b;
}
else if (bef & BEF_FORCETRANSPARENT)
{
b->next = batches[SHADER_SORT_BLEND];
batches[SHADER_SORT_BLEND] = b;
}
else
{
b->next = batches[b->shader->sort];
batches[b->shader->sort] = b;
}
b->mesh = shaderstate.wmeshes+shaderstate.wmesh;
b->meshes = 0;
b->lightmap = s->lightmaptexturenum;
}
shaderstate.wmesh++;
if (shaderstate.wmesh >= shaderstate.maxwmesh)
continue;
b->mesh[b->meshes++] = s->mesh;
}
}
batch_t *BE_GetTempBatch(void)
{
if (shaderstate.wbatch >= shaderstate.maxwbatches)
@ -3177,7 +2889,7 @@ void BE_GenModelBatches(batch_t **batches)
case mod_brush:
if (r_drawentities.ival == 2)
continue;
BE_GenBrushBatches(batches, ent);
Surf_GenBrushBatches(batches, ent);
break;
case mod_alias:
if (r_drawentities.ival == 3)

View file

@ -78,6 +78,10 @@ extern mesh_t nullmesh;
extern int gl_canbumpmap;
/*
batches are generated for each shader/ent as required.
once a batch is known to the backend for that frame, its shader, vbo, ent, lightmap, textures may not be changed until the frame has finished rendering. This is to potentially permit caching.
*/
typedef struct batch_s
{
mesh_t **mesh; /*list must be long enough for all surfaces that will form part of this batch times two, for mirrors/portals*/
@ -87,16 +91,25 @@ typedef struct batch_s
shader_t *shader;
struct vbo_s *vbo;
int lightmap;
entity_t *ent;
int lightmap; /*used for shader lightmap textures*/
entity_t *ent; /*used for shader properties*/
struct texture_s *texture;
struct texture_s *texture; /*is this used by the backend?*/
struct texnums_s *skin;
unsigned int maxmeshes;
unsigned int flags;
unsigned int maxmeshes; /*not used by backend*/
unsigned int flags; /*backend flags (force transparency etc)*/
void (*buildmeshes)(struct batch_s *b);
vec3_t normal; /*used only at load (for portal surfaces, so multiple planes are not part of the same batch)*/
/*caller-use, not interpreted by backend*/
union
{
struct
{
unsigned int surf_first;
unsigned int surf_count;
};
vec3_t normal; /*used only at load (for portal surfaces, so multiple planes are not part of the same batch)*/
};
} batch_t;
/*

View file

@ -70,20 +70,16 @@ int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2;
texture_t *r_notexture_mip;
cvar_t r_norefresh = SCVAR("r_norefresh","0");
cvar_t r_mirroralpha = SCVARF("r_mirroralpha","1", CVAR_CHEAT);
extern cvar_t gl_part_flame;
extern cvar_t r_bloom;
cvar_t gl_clear = SCVAR("gl_clear","0");
cvar_t gl_smoothmodels = SCVAR("gl_smoothmodels","1");
cvar_t gl_affinemodels = SCVAR("gl_affinemodels","0");
cvar_t gl_playermip = SCVAR("gl_playermip","0");
cvar_t gl_keeptjunctions = SCVAR("gl_keeptjunctions","1");
cvar_t gl_reporttjunctions = SCVAR("gl_reporttjunctions","0");
cvar_t gl_finish = SCVAR("gl_finish","0");
cvar_t gl_dither = SCVAR("gl_dither", "1");
cvar_t gl_maxdist = SCVAR("gl_maxdist", "8192");
cvar_t r_polygonoffset_submodel_factor = SCVAR("r_polygonoffset_submodel_factor", "0.05");
cvar_t r_polygonoffset_submodel_offset = SCVAR("r_polygonoffset_submodel_offset", "25");

View file

@ -27,11 +27,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
static void R_ReloadRTLights_f(void);
static void R_SaveRTLights_f(void);
#ifdef WATERLAYERS
cvar_t r_waterlayers = SCVAR("r_waterlayers","");
#endif
extern void R_InitBubble();
/*
@ -483,7 +478,6 @@ void GLR_DeInit (void)
Cvar_Unhook(&crosshaircolor);
Cvar_Unhook(&r_skyboxname);
Cvar_Unhook(&r_menutint);
Cvar_Unhook(&gl_font);
Cvar_Unhook(&vid_conautoscale);
Cvar_Unhook(&vid_conheight);
Cvar_Unhook(&vid_conwidth);
@ -526,7 +520,6 @@ void GLR_Init (void)
// Cvar_Hook(&r_drawflat, GLR_Drawflat_Callback);
Cvar_Hook(&v_gamma, GLV_Gamma_Callback);
Cvar_Hook(&v_contrast, GLV_Gamma_Callback);
Cvar_Hook(&gl_font, GL_Font_Callback);
R_InitBubble();
@ -903,17 +896,17 @@ static void R_SaveRTLights_f(void)
"%s%f %f %f "
"%f %f %f %f "
"%i "
/*"\"%s\" %f "
"\"%s\" %f "
"%f %f %f "
"%f %f %f %i "*/
"%f %f %f %i "
"\n"
,
(light->flags & LFLAG_NOSHADOWS)?"!":"", light->origin[0], light->origin[1], light->origin[2],
light->radius, light->color[0], light->color[1], light->color[2],
light->style-1
/*, "", 0,
light->style-1,
"", 0,
0, 0, 0,
0, 0, 0, light->flags&(LFLAG_NORMALMODE|LFLAG_REALTIMEMODE*/
0, 0, 0, light->flags&(LFLAG_NORMALMODE|LFLAG_REALTIMEMODE)
));
}
VFS_CLOSE(f);
@ -1015,21 +1008,46 @@ void GLR_TimeRefresh_f (void)
{
int i;
float start, stop, time;
qboolean finish;
int frames = 128;
qglDrawBuffer (GL_FRONT);
qglFinish ();
finish = atoi(Cmd_Argv(1));
frames = atoi(Cmd_Argv(2));
if (frames < 1)
frames = 128;
start = Sys_DoubleTime ();
for (i=0 ; i<128 ; i++)
#ifdef _WIN32
if (finish == 2)
{
r_refdef.viewangles[1] = i/128.0*360.0;
R_RenderView ();
extern HDC maindc;
qglFinish ();
start = Sys_DoubleTime ();
for (i=0 ; i<frames ; i++)
{
r_refdef.viewangles[1] = i/(float)frames*360.0;
R_RenderView ();
qSwapBuffers(maindc);
}
}
else
#endif
{
qglDrawBuffer (GL_FRONT);
qglFinish ();
start = Sys_DoubleTime ();
for (i=0 ; i<frames ; i++)
{
r_refdef.viewangles[1] = i/(float)frames*360.0;
R_RenderView ();
if (finish)
qglFinish ();
}
}
qglFinish ();
stop = Sys_DoubleTime ();
time = stop-start;
Con_Printf ("%f seconds (%f fps)\n", time, 128/time);
Con_Printf ("%f seconds (%f fps)\n", time, frames/time);
qglDrawBuffer (GL_BACK);
GL_EndRendering ();

View file

@ -112,15 +112,6 @@ void GLVID_Console_Resize(void)
#endif
}
void GL_Font_Callback(struct cvar_s *var, char *oldvalue)
{
if (font_conchar)
Font_Free(font_conchar);
font_conchar = Font_LoadFont(8*vid.pixelheight/vid.height, var->string);
if (!font_conchar && *var->string)
font_conchar = Font_LoadFont(8*vid.pixelheight/vid.height, "");
}
void GLVID_Conheight_Callback(struct cvar_s *var, char *oldvalue)
{
if (var->value > 1536) //anything higher is unreadable.

View file

@ -762,7 +762,10 @@ static void Shader_SLProgramName (shader_t *shader, shaderpass_t *pass, char **p
{
extern char *defaultglsl2program;
frag = Shader_ParseString(ptr);
Shader_LoadProgram(shader, defaultglsl2program, defaultglsl2program, qrtype);
#ifdef GLQUAKE
if (qrenderer == QR_OPENGL)
Shader_LoadProgram(shader, defaultglsl2program, defaultglsl2program, qrtype);
#endif
return;
}
FS_LoadFile(vert, &vert);
@ -798,8 +801,6 @@ static void Shader_ProgramParam ( shader_t *shader, shaderpass_t *pass, char **p
enum shaderprogparmtype_e parmtype = SP_BAD;
char *token;
qboolean silent = false;
int p;
qboolean foundone;
token = Shader_ParseString(ptr);
if (!Q_stricmp(token, "opt"))
@ -865,6 +866,8 @@ static void Shader_ProgramParam ( shader_t *shader, shaderpass_t *pass, char **p
#ifdef GLQUAKE
if (qrenderer == QR_OPENGL)
{
int p;
qboolean foundone;
unsigned int uniformloc;
if (!shader->programhandle[0].glsl)
{
@ -953,14 +956,14 @@ static void Shaderpass_Map (shader_t *shader, shaderpass_t *pass, char **ptr)
if (!Q_stricmp (token, "$lightmap"))
{
pass->tcgen = TC_GEN_LIGHTMAP;
pass->flags |= SHADER_PASS_LIGHTMAP;
pass->flags |= SHADER_PASS_LIGHTMAP | SHADER_PASS_NOMIPMAP;
pass->texgen = T_GEN_LIGHTMAP;
shader->flags |= SHADER_HASLIGHTMAP;
}
else if (!Q_stricmp (token, "$deluxmap"))
{
pass->tcgen = TC_GEN_LIGHTMAP;
pass->flags |= SHADER_PASS_DELUXMAP;
pass->flags |= SHADER_PASS_DELUXMAP | SHADER_PASS_NOMIPMAP;
pass->texgen = T_GEN_DELUXMAP;
}
else if (!Q_stricmp (token, "$diffuse"))
@ -1854,6 +1857,9 @@ void Shader_Readpass (shader_t *shader, char **ptr)
pass->numtcmods = 0;
pass->numMergedPasses = 1;
if (shader->flags & SHADER_NOMIPMAPS)
pass->flags |= SHADER_PASS_NOMIPMAP;
while ( *ptr )
{
token = COM_ParseExt (ptr, true);
@ -2478,7 +2484,7 @@ void Shader_DefaultBSPLM(char *shortname, shader_t *s, const void *args)
"}\n"
);
if (0&&!builtin && gl_config.arb_shader_objects)
/* if (0&&!builtin && gl_config.arb_shader_objects)
{
builtin = (
"{\n"
@ -2508,7 +2514,7 @@ void Shader_DefaultBSPLM(char *shortname, shader_t *s, const void *args)
"}\n"
);
}
*/
if (!builtin)
builtin = (
"{\n"
@ -3036,6 +3042,7 @@ void Shader_Default2D(char *shortname, shader_t *s, const void *genargs)
{
Shader_DefaultScript(shortname, s,
"{\n"
"nomipmaps\n"
"{\n"
"map $diffuse\n"
"rgbgen vertex\n"
@ -3047,6 +3054,11 @@ void Shader_Default2D(char *shortname, shader_t *s, const void *genargs)
);
s->defaulttextures.base = R_LoadHiResTexture(shortname, NULL, IF_NOPICMIP|IF_NOMIPMAP);
if (!TEXVALID(s->defaulttextures.base))
{
unsigned char data[4*4] = {0};
s->defaulttextures.base = R_LoadTexture8("black", 4, 4, data, 0, 0);
}
s->width = image_width;
s->height = image_height;
}

View file

@ -65,7 +65,6 @@ void R_SetSky(char *skyname)
GL_DrawSkyChain
=================
*/
#ifdef GLQUAKE
void R_DrawSkyChain (batch_t *batch)
{
shader_t *skyshader;
@ -76,6 +75,7 @@ void R_DrawSkyChain (batch_t *batch)
else
skyshader = batch->shader;
#ifdef GLQUAKE
if (skyshader->skydome)
skyboxtex = skyshader->skydome->farbox_textures;
else
@ -101,12 +101,12 @@ void R_DrawSkyChain (batch_t *batch)
GL_SkyForceDepth(batch);
}
else
#endif
{
GL_DrawSkySphere(batch, skyshader);
GL_SkyForceDepth(batch);
}
}
#endif
/*
=================================================================
@ -370,7 +370,6 @@ static int skymade;
static index_t skysphere_element3i[skysphere_numtriangles * 3];
static float skysphere_texcoord2f[skysphere_numverts * 2];
#ifdef GLQUAKE
static vecV_t skysphere_vertex3f[skysphere_numverts];
static mesh_t skymesh;
@ -459,7 +458,6 @@ static void GL_SkyForceDepth(batch_t *batch)
static void GL_DrawSkySphere (batch_t *batch, shader_t *shader)
{
extern cvar_t gl_maxdist;
float time = cl.gametime+realtime-cl.gametimemark;
float skydist = gl_maxdist.value;
@ -467,6 +465,7 @@ static void GL_DrawSkySphere (batch_t *batch, shader_t *shader)
skydist=gl_skyboxdist.value;
skydist/=16;
#ifdef GLQUAKE
BE_SelectEntity(&r_worldentity);
//scale sky sphere and place around view origin.
qglPushMatrix();
@ -477,8 +476,8 @@ static void GL_DrawSkySphere (batch_t *batch, shader_t *shader)
gl_skyspherecalc(2);
BE_DrawMesh_Single(shader, &skymesh, NULL, &batch->shader->defaulttextures);
qglPopMatrix();
#endif
}
#endif

View file

@ -229,6 +229,10 @@ extern const char *gl_version;
FTE_DEPRECATED void PPL_RevertToKnownState(void);
qboolean R_CullBox (vec3_t mins, vec3_t maxs);
qboolean R_CullEntityBox(entity_t *e, vec3_t modmins, vec3_t modmaxs);
qboolean R_CullSphere (vec3_t origin, float radius);
#ifdef GLQUAKE
void R_TranslatePlayerSkin (int playernum);
void GL_Bind (texid_t texnum);
@ -307,10 +311,7 @@ void GL_Set2D (void);
// gl_rmain.c
//
qboolean R_ShouldDraw(entity_t *e);
qboolean R_CullBox (vec3_t mins, vec3_t maxs);
#ifdef GLQUAKE
qboolean R_CullSphere (vec3_t origin, float radius);
qboolean R_CullEntityBox(entity_t *e, vec3_t modmins, vec3_t modmaxs);
void R_RotateForEntity (const entity_t *e, const model_t *mod);
void GL_InitSceneProcessingShaders (void);
@ -322,7 +323,6 @@ void GL_SetupSceneProcessingTextures (void);
//
#ifdef GLQUAKE
void R_DrawGAliasShadowVolume(entity_t *e, vec3_t lightpos, float radius);
void R_LightArrays(vecV_t *coords, vec4_t *colours, int vertcount, vec3_t *normals);
//misc model formats
void R_DrawHLModel(entity_t *curent);

View file

@ -210,6 +210,7 @@ typedef struct shaderpass_s {
} texgen;
enum {
SHADER_PASS_NOMIPMAP = 1<<1,
SHADER_PASS_NOCOLORARRAY = 1<< 3,
//FIXME: remove these

Binary file not shown.

View file

@ -45,6 +45,9 @@ extern int hunksize;
#include "progtype.h"
#include "progslib.h"
#pragma warning(disable : 4244)
#pragma warning(disable : 4267)
//extern progfuncs_t *progfuncs;
#define prinst progfuncs->prinst

View file

@ -640,6 +640,12 @@ pbool QCC_WriteData (int crc)
if (compressoutput) progs.blockscompressed |=128; //types
//include a type block?
types = debugtarget;//!!QCC_PR_CheckCompConstDefined("TYPES"); //useful for debugging and saving (maybe, anyway...).
if (sizeof(char *) != sizeof(string_t))
{
//qcc_typeinfo_t has a char* inside it, which changes size
printf("AMD64 builds cannot write typeinfo structures\n");
types = false;
}
if (verbose)
{
@ -1127,7 +1133,7 @@ strofs = (strofs+3)&~3;
qcc_typeinfo[i].aux_type = (QCC_type_t*)(qcc_typeinfo[i].aux_type - qcc_typeinfo);
if (qcc_typeinfo[i].next)
qcc_typeinfo[i].next = (QCC_type_t*)(qcc_typeinfo[i].next - qcc_typeinfo);
qcc_typeinfo[i].name = QCC_CopyDupBackString(qcc_typeinfo[i].name);
qcc_typeinfo[i].name = (char*)QCC_CopyDupBackString(qcc_typeinfo[i].name);
}
progs.ofsfiles = 0;

View file

@ -1206,7 +1206,6 @@ void SV_Cuff_f (void)
cl->iscuffed = false;
SV_ClientTPrintf (cl, PRINT_HIGH, STL_YOUARNTCUFFED);
}
return;
}
if (clnum == -1)

View file

@ -691,7 +691,7 @@ static void SVQ3_Adjust_Area_Portal_State(q3sharedEntity_t *ge, qboolean open)
}
#define VALIDATEPOINTER(o,l) if ((int)o + l >= mask || VM_POINTER(o) < offset) SV_Error("Call to game trap %i passes invalid pointer\n", fn); //out of bounds.
static int Q3G_SystemCallsEx(void *offset, unsigned int mask, int fn, const int *arg)
static qintptr_t Q3G_SystemCalls(void *offset, unsigned int mask, qintptr_t fn, const qintptr_t *arg)
{
int ret = 0;
switch(fn)
@ -1392,29 +1392,49 @@ static int Q3G_SystemCallsEx(void *offset, unsigned int mask, int fn, const int
return ret;
}
static int EXPORT_FN Q3G_SystemCalls(int arg, ...)
static int Q3G_SystemCallsVM(void *offset, unsigned int mask, int fn, const int *arg)
{
int args[13];
qintptr_t args[13];
args[0]=arg[0];
args[1]=arg[1];
args[2]=arg[2];
args[3]=arg[3];
args[4]=arg[4];
args[5]=arg[5];
args[6]=arg[6];
args[7]=arg[7];
args[8]=arg[8];
args[9]=arg[9];
args[10]=arg[10];
args[11]=arg[11];
args[12]=arg[12];
return Q3G_SystemCalls(NULL, ~0, fn, args);
}
static qintptr_t EXPORT_FN Q3G_SystemCallsNative(qintptr_t arg, ...)
{
qintptr_t args[13];
va_list argptr;
va_start(argptr, arg);
args[0]=va_arg(argptr, int);
args[1]=va_arg(argptr, int);
args[2]=va_arg(argptr, int);
args[3]=va_arg(argptr, int);
args[4]=va_arg(argptr, int);
args[5]=va_arg(argptr, int);
args[6]=va_arg(argptr, int);
args[7]=va_arg(argptr, int);
args[8]=va_arg(argptr, int);
args[9]=va_arg(argptr, int);
args[10]=va_arg(argptr, int);
args[11]=va_arg(argptr, int);
args[12]=va_arg(argptr, int);
args[0]=va_arg(argptr, qintptr_t);
args[1]=va_arg(argptr, qintptr_t);
args[2]=va_arg(argptr, qintptr_t);
args[3]=va_arg(argptr, qintptr_t);
args[4]=va_arg(argptr, qintptr_t);
args[5]=va_arg(argptr, qintptr_t);
args[6]=va_arg(argptr, qintptr_t);
args[7]=va_arg(argptr, qintptr_t);
args[8]=va_arg(argptr, qintptr_t);
args[9]=va_arg(argptr, qintptr_t);
args[10]=va_arg(argptr, qintptr_t);
args[11]=va_arg(argptr, qintptr_t);
args[12]=va_arg(argptr, qintptr_t);
va_end(argptr);
return Q3G_SystemCallsEx(NULL, ~0, arg, args);
return Q3G_SystemCalls(NULL, ~0, arg, args);
}
void SVQ3_ShutdownGame(void)
@ -1675,7 +1695,7 @@ qboolean SVQ3_InitGame(void)
SVQ3_ShutdownGame();
q3gamevm = VM_Create(NULL, "vm/qagame", Q3G_SystemCalls, Q3G_SystemCallsEx);
q3gamevm = VM_Create(NULL, "vm/qagame", Q3G_SystemCallsNative, Q3G_SystemCallsVM);
if (!q3gamevm)
return false;