本文整理汇总了C++中R_AddDrawSurf函数的典型用法代码示例。如果您正苦于以下问题:C++ R_AddDrawSurf函数的具体用法?C++ R_AddDrawSurf怎么用?C++ R_AddDrawSurf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了R_AddDrawSurf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: sizeof
/*
================
EmitSurface
================
*/
void idGuiModel::EmitSurface( guiModelSurface_t *surf, float modelMatrix[16], float modelViewMatrix[16], bool depthHack ) {
srfTriangles_t *tri;
if( surf->numVerts == 0 ) {
return; // nothing in the surface
}
// copy verts and indexes
tri = ( srfTriangles_t * )R_ClearedFrameAlloc( sizeof( *tri ) );
tri->numIndexes = surf->numIndexes;
tri->numVerts = surf->numVerts;
tri->indexes = ( glIndex_t * )R_FrameAlloc( tri->numIndexes * sizeof( tri->indexes[0] ) );
memcpy( tri->indexes, &indexes[surf->firstIndex], tri->numIndexes * sizeof( tri->indexes[0] ) );
// we might be able to avoid copying these and just let them reference the list vars
// but some things, like deforms and recursive
// guis, need to access the verts in cpu space, not just through the vertex range
tri->verts = ( idDrawVert * )R_FrameAlloc( tri->numVerts * sizeof( tri->verts[0] ) );
memcpy( tri->verts, &verts[surf->firstVert], tri->numVerts * sizeof( tri->verts[0] ) );
// move the verts to the vertex cache
tri->ambientCache = vertexCache.AllocFrameTemp( tri->verts, tri->numVerts * sizeof( tri->verts[0] ) );
// if we are out of vertex cache, don't create the surface
if( !tri->ambientCache ) {
return;
}
renderEntity_t renderEntity;
memset( &renderEntity, 0, sizeof( renderEntity ) );
memcpy( renderEntity.shaderParms, surf->color, sizeof( surf->color ) );
viewEntity_t *guiSpace = ( viewEntity_t * )R_ClearedFrameAlloc( sizeof( *guiSpace ) );
memcpy( guiSpace->modelMatrix, modelMatrix, sizeof( guiSpace->modelMatrix ) );
memcpy( guiSpace->modelViewMatrix, modelViewMatrix, sizeof( guiSpace->modelViewMatrix ) );
guiSpace->weaponDepthHack = depthHack;
// add the surface, which might recursively create another gui
R_AddDrawSurf( tri, guiSpace, &renderEntity, surf->material, tr.viewDef->scissor );
}
示例2: AddDecalSurface
/*
AddDecalSurface()
adds a decal surface to the scene
*/
void R_AddDecalSurface(decal_t *decal)
{
int dlightMap;
srfDecal_t *srf;
srfGeneric_t *gen;
/* early outs */
if (decal->shader == NULL || decal->parent->viewCount != tr.viewCount || r_firstSceneDecal + tr.refdef.numDecals >= MAX_DECALS)
{
return;
}
/* get decal surface */
srf = &tr.refdef.decals[tr.refdef.numDecals];
tr.refdef.numDecals++;
/* set it up */
srf->surfaceType = SF_DECAL;
srf->numVerts = decal->numVerts;
Com_Memcpy(srf->verts, decal->verts, srf->numVerts * sizeof(*srf->verts));
/* fade colors */
if (decal->fadeStartTime < tr.refdef.time && decal->fadeStartTime < decal->fadeEndTime)
{
int i;
float fade = (float) (decal->fadeEndTime - tr.refdef.time) /
(float) (decal->fadeEndTime - decal->fadeStartTime);
for (i = 0; i < decal->numVerts; i++)
{
decal->verts[i].modulate[0] *= fade;
decal->verts[i].modulate[1] *= fade;
decal->verts[i].modulate[2] *= fade;
decal->verts[i].modulate[3] *= fade;
}
}
/* dynamic lights? */
if (decal->parent != NULL)
{
gen = (srfGeneric_t *) decal->parent->data;
dlightMap = (gen->dlightBits != 0);
}
else
{
dlightMap = 0;
}
/* add surface to scene */
R_AddDrawSurf((void *) srf, decal->shader, decal->fogIndex, 0, dlightMap);
tr.pc.c_decalSurfaces++;
/* free temporary decal */
if (decal->fadeEndTime <= tr.refdef.time)
{
decal->shader = NULL;
}
}
示例3: AddDecalSurface
/*
AddDecalSurface()
adds a decal surface to the scene
*/
void R_AddDecalSurface(decal_t *decal)
{
int i; //, dlightMap;
float fade;
srfDecal_t *srf;
//srfGeneric_t *gen;
// early outs
if (decal->shader == NULL || decal->parent->viewCount != tr.viewCountNoReset || tr.refdef.numDecals >= MAX_DECALS)
{
return;
}
// get decal surface
srf = &tr.refdef.decals[tr.refdef.numDecals];
tr.refdef.numDecals++;
// set it up
srf->surfaceType = SF_DECAL;
srf->numVerts = decal->numVerts;
Com_Memcpy(srf->verts, decal->verts, srf->numVerts * sizeof(*srf->verts));
// fade colors
if (decal->fadeStartTime < tr.refdef.time && decal->fadeStartTime < decal->fadeEndTime)
{
fade = (float)(decal->fadeEndTime - tr.refdef.time) / (float)(decal->fadeEndTime - decal->fadeStartTime);
for (i = 0; i < decal->numVerts; i++)
{
decal->verts[i].modulate[0] *= fade;
decal->verts[i].modulate[1] *= fade;
decal->verts[i].modulate[2] *= fade;
decal->verts[i].modulate[3] *= fade;
}
}
// dynamic lights?
/*
if(decal->parent != NULL)
{
gen = (srfGeneric_t *) decal->parent->data;
dlightMap = (gen->dlightBits[tr.smpFrame] != 0);
}
else
{
dlightMap = 0;
}
*/
// add surface to scene
//R_AddDrawSurf((void *)srf, decal->shader, decal->fogIndex, 0, dlightMap);
R_AddDrawSurf((surfaceType_t *)srf, decal->shader, -1, decal->fogIndex);
tr.pc.c_decalSurfaces++;
// free temporary decal
if (decal->fadeEndTime <= tr.refdef.time)
{
decal->shader = NULL;
}
}
示例4: R_AddPolygonSurfaces
void R_AddPolygonSurfaces()
{
tr.currentEntityNum = ENTITYNUM_WORLD;
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;
const srfPoly_t* poly = tr.refdef.polys;
for (int i = 0; i < tr.refdef.numPolys; ++i, ++poly) {
R_AddDrawSurf( (const surfaceType_t*)poly, R_GetShaderByHandle( poly->hShader ), poly->fogIndex );
}
}
示例5: R_AddPolygonSurfaces
/*
=====================
R_AddPolygonSurfaces
Adds all the scene's polys into this view's drawsurf list
=====================
*/
void R_AddPolygonSurfaces( void ) {
int i;
shader_t *sh;
srfPoly_t *poly;
tr.currentEntityNum = ENTITYNUM_WORLD;
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;
for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) {
sh = R_GetShaderByHandle( poly->hShader );
R_AddDrawSurf( ( surfaceType_t * )poly, sh, poly->fogIndex, qfalse ); // ***GREGS_VC9_PORT_MOD*** -- changed typecast; was void *
}
}
示例6: R_AddPolygonSurfaces
/*
=====================
R_AddPolygonSurfaces
Adds all the scene's polys into this view's drawsurf list
=====================
*/
void R_AddPolygonSurfaces( void ) {
int i;
shader_t *sh;
srfPoly_t *poly;
tr.currentEntityNum = REFENTITYNUM_WORLD;
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT;
for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) {
sh = R_GetShaderByHandle( poly->hShader );
R_AddDrawSurf( ( void * )poly, sh, poly->fogIndex, qfalse );
}
}
示例7: R_AddPolygonSurfaces
/*
=====================
R_AddPolygonSurfaces
Adds all the scene's polys into this view's drawsurf list
=====================
*/
void R_AddPolygonSurfaces( void ) {
int i;
shader_t *sh;
srfPoly_t *poly;
tr.currentEntityNum = ENTITYNUM_WORLD;
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;
for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) {
sh = R_GetShaderByHandle( poly->hShader );
R_AddDrawSurf( reinterpret_cast<surfaceType_t*>(poly), sh, poly->fogIndex, false );
}
}
示例8: R_AddPolygonBufferSurfaces
/*
=====================
R_AddPolygonSurfaces
Adds all the scene's polys into this view's drawsurf list
=====================
*/
void R_AddPolygonBufferSurfaces() {
int i;
shader_t* sh;
srfPolyBuffer_t* polybuffer;
tr.currentEntity = &tr.worldEntity;
for (i = 0, polybuffer = tr.refdef.polybuffers; i < tr.refdef.numPolybuffers;
i++, polybuffer++) {
sh = R_GetShaderByHandle(polybuffer->pPolyBuffer->shader);
R_AddDrawSurf((surfaceType_t*) polybuffer, sh, -1, polybuffer->fogIndex);
}
}
示例9: R_AddPolygonBufferSurfaces
/*
=====================
R_AddPolygonSurfaces
Adds all the scene's polys into this view's drawsurf list
=====================
*/
void R_AddPolygonBufferSurfaces( void ) {
int i;
shader_t *sh;
srfPolyBuffer_t *polybuffer;
tr.currentEntityNum = ENTITYNUM_WORLD;
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT;
for ( i = 0, polybuffer = tr.refdef.polybuffers; i < tr.refdef.numPolyBuffers ; i++, polybuffer++ ) {
sh = R_GetShaderByHandle( polybuffer->pPolyBuffer->shader );
R_AddDrawSurf( ( void * )polybuffer, sh, R_PolyBufferFogNum( polybuffer ), qfalse );
}
}
示例10: R_AddPolygonSurfaces
/*
=====================
R_AddPolygonSurfaces
Adds all the scene's polys into this view's drawsurf list
=====================
*/
void R_AddPolygonSurfaces( void ) {
int i;
shader_t *sh;
srfPoly_t *poly;
int fogMask;
tr.currentEntityNum = REFENTITYNUM_WORLD;
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_REFENTITYNUM_SHIFT;
fogMask = -((tr.refdef.rdflags & RDF_NOFOG) == 0);
for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) {
sh = R_GetShaderByHandle( poly->hShader );
R_AddDrawSurf( ( void * )poly, sh, poly->fogIndex & fogMask, qfalse, qfalse, 0 /*cubeMap*/ );
}
}
示例11: R_AddPolygonSurfaces
/*
=====================
R_AddPolygonSurfaces
Adds all the scene's polys into this view's drawsurf list
=====================
*/
void R_AddPolygonSurfaces() {
int i;
shader_t* sh;
srfPoly_t* poly;
if (!r_drawpolies->integer) {
return;
}
tr.currentEntity = &tr.worldEntity;
for (i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys; i++, poly++) {
sh = R_GetShaderByHandle(poly->hShader);
R_AddDrawSurf((surfaceType_t*) poly, sh, -1, poly->fogIndex);
}
}
示例12: R_AddAnimSurfaces
/*
==============
R_AddAnimSurfaces
==============
*/
void R_AddAnimSurfaces( trRefEntity_t *ent ) {
md4Header_t *header;
md4Surface_t *surface;
md4LOD_t *lod;
shader_t *shader;
int i;
header = tr.currentModel->md4;
lod = (md4LOD_t *)( (byte *)header + header->ofsLODs );
surface = (md4Surface_t *)( (byte *)lod + lod->ofsSurfaces );
for ( i = 0 ; i < lod->numSurfaces ; i++ ) {
shader = R_GetShaderByHandle( surface->shaderIndex );
R_AddDrawSurf( (void *)surface, shader, 0 /*fogNum*/, qfalse );
surface = (md4Surface_t *)( (byte *)surface + surface->ofsEnd );
}
}
示例13: R_AddDecalSurface
// adds a decal surface to the scene
static void R_AddDecalSurface( mbrush46_decal_t* decal ) {
// early outs
if ( decal->shader == NULL || decal->parent->viewCount != tr.viewCount || tr.refdef.numDecals >= MAX_DECALS ) {
return;
}
// get decal surface
idSurfaceDecal* srf = &tr.refdef.decals[ tr.refdef.numDecals ];
tr.refdef.numDecals++;
// set it up
srf->surf.numVerts = decal->numVerts;
Com_Memcpy( srf->surf.verts, decal->verts, srf->surf.numVerts * sizeof ( *srf->surf.verts ) );
// fade colors
if ( decal->fadeStartTime < tr.refdef.time && decal->fadeStartTime < decal->fadeEndTime ) {
float fade = ( float )( decal->fadeEndTime - tr.refdef.time ) /
( float )( decal->fadeEndTime - decal->fadeStartTime );
for ( int i = 0; i < decal->numVerts; i++ ) {
decal->verts[ i ].modulate[ 0 ] *= fade;
decal->verts[ i ].modulate[ 1 ] *= fade;
decal->verts[ i ].modulate[ 2 ] *= fade;
decal->verts[ i ].modulate[ 3 ] *= fade;
}
}
// dynamic lights?
int dlightMap;
if ( decal->parent != NULL ) {
dlightMap = decal->parent->dlightBits[ tr.smpFrame ] != 0;
} else {
dlightMap = 0;
}
// add surface to scene
R_AddDrawSurf( srf, decal->shader, decal->fogIndex, dlightMap, 0, 0, 0 );
tr.pc.c_decalSurfaces++;
// free temporary decal
if ( decal->fadeEndTime <= tr.refdef.time ) {
decal->shader = NULL;
}
}
示例14: R_AddPolygonSurfaces
/*
=====================
R_AddPolygonSurfaces
Adds all the scene's polys into this view's drawsurf list
=====================
*/
void R_AddPolygonSurfaces( void ) {
int i;
shader_t *sh;
srfPoly_t *poly;
tr.currentEntityNum = ENTITYNUM_WORLD;
tr.shiftedEntityNum = tr.currentEntityNum << QSORT_ENTITYNUM_SHIFT;
for ( i = 0, poly = tr.refdef.polys; i < tr.refdef.numPolys ; i++, poly++ ) {
sh = R_GetShaderByHandle( poly->hShader );
//sortSL{
// a hack to get the SprayLogo-"Level" into the Engine
// without changing the vm-interface-functions
if(poly->verts->st[0]>=10.0f)
poly->lvl = ((int)poly->verts->st[0]/10);
else
poly->lvl = 0;
//sortSL}
R_AddDrawSurf( ( void * )poly, sh, poly->fogIndex, qfalse );
}
}
示例15: R_MDRAddAnimSurfaces
//.........这里部分代码省略.........
// This will write directly into the entity structure, so
// when the surfaces are rendered, they don't need to be
// range checked again.
//
if ((ent->e.frame >= header->numFrames)
|| (ent->e.frame < 0)
|| (ent->e.oldframe >= header->numFrames)
|| (ent->e.oldframe < 0) )
{
ri->Printf( PRINT_DEVELOPER, "R_MDRAddAnimSurfaces: no such frame %d to %d for '%s'\n",
ent->e.oldframe, ent->e.frame, tr.currentModel->name );
ent->e.frame = 0;
ent->e.oldframe = 0;
}
//
// cull the entire model if merged bounding box of both frames
// is outside the view frustum.
//
cull = R_MDRCullModel (header, ent);
if ( cull == CULL_OUT ) {
return;
}
// figure out the current LOD of the model we're rendering, and set the lod pointer respectively.
lodnum = R_ComputeLOD(ent);
// check whether this model has as that many LODs at all. If not, try the closest thing we got.
if(header->numLODs <= 0)
return;
if(header->numLODs <= lodnum)
lodnum = header->numLODs - 1;
lod = (mdrLOD_t *)( (byte *)header + header->ofsLODs);
for(i = 0; i < lodnum; i++)
{
lod = (mdrLOD_t *) ((byte *) lod + lod->ofsEnd);
}
// set up lighting
if ( !personalModel || r_shadows->integer > 1 )
{
R_SetupEntityLighting( &tr.refdef, ent );
}
// fogNum?
fogNum = R_MDRComputeFogNum( header, ent );
surface = (mdrSurface_t *)( (byte *)lod + lod->ofsSurfaces );
for ( i = 0 ; i < lod->numSurfaces ; i++ )
{
if(ent->e.customShader)
shader = R_GetShaderByHandle(ent->e.customShader);
else if(ent->e.customSkin > 0 && ent->e.customSkin < tr.numSkins)
{
skin = R_GetSkinByHandle(ent->e.customSkin);
shader = tr.defaultShader;
for(j = 0; j < skin->numSurfaces; j++)
{
if (!strcmp(skin->surfaces[j]->name, surface->name))
{
shader = skin->surfaces[j]->shader;
break;
}
}
}
else if(surface->shaderIndex > 0)
shader = R_GetShaderByHandle( surface->shaderIndex );
else
shader = tr.defaultShader;
// we will add shadows even if the main object isn't visible in the view
// stencil shadows can't do personal models unless I polyhedron clip
if ( !personalModel
&& r_shadows->integer == 2
&& fogNum == 0
&& !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) )
&& shader->sort == SS_OPAQUE )
{
R_AddDrawSurf( (void *)surface, tr.shadowShader, 0, qfalse );
}
// projection shadows work fine with personal models
if ( r_shadows->integer == 3
&& fogNum == 0
&& (ent->e.renderfx & RF_SHADOW_PLANE )
&& shader->sort == SS_OPAQUE )
{
R_AddDrawSurf( (void *)surface, tr.projectionShadowShader, 0, qfalse );
}
if (!personalModel)
R_AddDrawSurf( (void *)surface, shader, fogNum, qfalse );
surface = (mdrSurface_t *)( (byte *)surface + surface->ofsEnd );
}
}