Пример #1
0
/*
** RB_EndSurface
*/
void RB_EndSurface( void ) {
	shaderCommands_t *input;

	input = &tess;

	if (input->numIndexes == 0 || input->numVertexes == 0) {
		return;
	}

	if (input->indexes[SHADER_MAX_INDEXES-1] != 0) {
		ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit");
	}	
	if (input->xyz[SHADER_MAX_VERTEXES-1][0] != 0) {
		ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit");
	}

	if ( tess.shader == tr.shadowShader ) {
		RB_ShadowTessEnd();
		return;
	}

	// for debugging of sort order issues, stop rendering after a given sort value
	if ( r_debugSort->integer && r_debugSort->integer < tess.shader->sort ) {
		return;
	}

	//
	// update performance counters
	//
	backEnd.pc.c_shaders++;
	backEnd.pc.c_vertexes += tess.numVertexes;
	backEnd.pc.c_indexes += tess.numIndexes;
	backEnd.pc.c_totalIndexes += tess.numIndexes * tess.numPasses;

	//
	// call off to shader specific tess end function
	//
	tess.currentStageIteratorFunc();

	//
	// draw debugging stuff
	//
	if ( r_showtris->integer ) {
		DrawTris (input);
	}
	if ( r_shownormals->integer ) {
		DrawNormals (input);
	}
	// clear shader so we can tell we don't have any unclosed surfaces
	tess.numIndexes = 0;
	tess.numVertexes = 0;
	tess.firstIndex = 0;
	tess.multiDrawPrimitives = 0;

	GLimp_LogComment( "----------\n" );
}
Пример #2
0
/*
===================
RB_EndSurface
===================
*/
void RB_EndSurface(void)
{
	shaderCommands_t *input = &tess;

	if (input->numIndexes == 0)
	{
		return;
	}

	if (input->indexes[input->maxShaderIndicies - 1] != 0)
	{
		ri.Error(ERR_DROP, "RB_EndSurface() - input->maxShaderIndicies(%i) hit", input->maxShaderIndicies);
	}
	if (input->xyz[input->maxShaderVerts - 1].v[0] != 0)
	{
		ri.Error(ERR_DROP, "RB_EndSurface() - input->maxShaderVerts(%i) hit", input->maxShaderVerts);
	}

	if (tess.shader == tr.shadowShader)
	{
		RB_ShadowTessEnd();
		return;
	}

	// for debugging of sort order issues, stop rendering after a given sort value
	if (r_debugSort->integer && r_debugSort->integer < tess.shader->sort)
	{
		return;
	}

	// update performance counters
	backEnd.pc.c_shaders++;
	backEnd.pc.c_vertexes     += tess.numVertexes;
	backEnd.pc.c_indexes      += tess.numIndexes;
	backEnd.pc.c_totalIndexes += tess.numIndexes * tess.numPasses;

	// call off to shader specific tess end function
	tess.currentStageIteratorFunc();

	// draw debugging stuff
	if (r_showtris->integer)
	{
		DrawTris(input);
	}
	if (r_shownormals->integer)
	{
		DrawNormals(input);
	}

	// clear shader so we can tell we don't have any unclosed surfaces
	tess.numIndexes = 0;

	GLimp_LogComment("----------\n");
}
Пример #3
0
void quadsquare::DrawEnvmapTris() 
{
    if ( VertexArrayCounter > 0 && EnvmapTexId != 0 ) {
	
	glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );
	glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP );

	glBindTexture( GL_TEXTURE_2D, EnvmapTexId );

	DrawTris();

	glTexGeni( GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );
	glTexGeni( GL_T, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR );

    } 
}
Пример #4
0
/*
** RB_EndSurface
*/
void RB_EndSurface( qboolean forceDepth ) {
    shaderCommands_t *input;
    GLenum			 prog;
    int				 loc;
    int i,size;
    shaderStage_t	stage;
    image_t			image;
    char			tex[MAX_QPATH];

    input = &tess;

    if ( tess.shader == tr.maskEndShader ) {
        RB_MaskTessFinish();
        return;
    }

    if (input->numIndexes == 0) {
        return;
    }

    if (input->indexes[SHADER_MAX_INDEXES-1] != 0) {
        ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit");
    }
    if (input->xyz[SHADER_MAX_VERTEXES-1][0] != 0) {
        ri.Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit");
    }

    if ( tess.shader == tr.shadowShader ) {
        RB_ShadowTessEnd();
        return;
    }

    if ( tess.shader == tr.maskShader ) {
        RB_MaskTessEnd();
        return;
    }

    // for debugging of sort order issues, stop rendering after a given sort value
    if ( r_debugSort->integer && r_debugSort->integer < tess.shader->sort ) {
        return;
    }

    //
    // update performance counters
    //
    backEnd.pc.c_shaders++;
    backEnd.pc.c_vertexes += tess.numVertexes;
    backEnd.pc.c_indexes += tess.numIndexes;
    backEnd.pc.c_totalIndexes += tess.numIndexes * tess.numPasses;

    if(forceDepth) {
        //Force depth testing if we are rendering via draw.Start3D -Hxrmn
        size = sizeof(tess.xstages) / sizeof(tess.xstages[0]);
        for(i=0; i<size; i++) {
            if(tess.xstages[i] != NULL) {
                if(tess.xstages[i]->stateBits & GLS_DEPTHTEST_DISABLE) {
                    tess.xstages[i]->stateBits &= ~GLS_DEPTHTEST_DISABLE;
                }
            }
        }
    }

    //
    // call off to shader specific tess end function
    //

    if(tess.shader->GLSL) {
        prog = getShaderProgram(tess.shader->GLSLName);
        if(prog != -1) {
            qglUseProgramObjectARB(prog);

            if(qglUniform1fARB) {
                loc = qglGetUniformLocationARB(prog, "cgtime");
                qglUniform1fARB(loc, backEnd.refdef.floatTime);
            }

            if(qglUniform3fvARB) {
                loc = qglGetUniformLocationARB(prog, "viewPos");
                qglUniform3fARB(loc,
                                backEnd.refdef.vieworg[0],
                                backEnd.refdef.vieworg[1],
                                backEnd.refdef.vieworg[2]);
            }

            if(qglUniform3fvARB) {
                loc = qglGetUniformLocationARB(prog, "viewNormal");
                qglUniform3fARB(loc,
                                backEnd.refdef.viewaxis[0][0],
                                backEnd.refdef.viewaxis[0][1],
                                backEnd.refdef.viewaxis[0][2]);
            }

            if(qglUniform2fARB) {
                loc = qglGetUniformLocationARB(prog, "fov");
                qglUniform2fARB(loc,
                                backEnd.refdef.fov_x,
                                backEnd.refdef.fov_y);
            }
            /*
            loc = qglGetUniformLocationARB(prog, "texture_0");
            qglUniform1iARB(loc, 0);

            loc = qglGetUniformLocationARB(prog, "texture_1");
            qglUniform1iARB(loc, 1);*/
        }
    }

    //tess.shader->stages[0]->bundle[0].image

    tess.currentStageIteratorFunc();

    if(tess.shader->GLSL) {
        revertShaderProgram();
        qglDisable(GL_TEXTURE0_ARB);
        qglDisable(GL_TEXTURE1_ARB);
        qglDisable(GL_TEXTURE2_ARB);
        qglDisable(GL_TEXTURE3_ARB);
    }

    //
    // draw debugging stuff
    //
    if ( r_showtris->integer ) {
        DrawTris (input);
    }
    if ( r_shownormals->integer ) {
        DrawNormals (input);
    }
    // clear shader so we can tell we don't have any unclosed surfaces
    tess.numIndexes = 0;

    GLimp_LogComment( "----------\n" );
}
Пример #5
0
/*
** RB_EndSurface
*/
void RB_EndSurface( void ) {
	shaderCommands_t *input;

	input = &tess;

	if (input->numIndexes == 0) {
		return;
	}

	if (input->indexes[SHADER_MAX_INDEXES-1] != 0) {
		Com_Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_INDEXES hit");
	}
	if (input->xyz[SHADER_MAX_VERTEXES-1][0] != 0) {
		Com_Error (ERR_DROP, "RB_EndSurface() - SHADER_MAX_VERTEXES hit");
	}

	if ( tess.shader == tr.shadowShader ) {
		RB_ShadowTessEnd();
		return;
	}

	// for debugging of sort order issues, stop rendering after a given sort value
	if ( r_debugSort->integer && r_debugSort->integer < tess.shader->sort ) {
		return;
	}

	if ( skyboxportal )
	{
		// world
		if(!(backEnd.refdef.rdflags & RDF_SKYBOXPORTAL))
		{
			if(tess.currentStageIteratorFunc == RB_StageIteratorSky)
			{	// don't process these tris at all
				return;
			}
		}
		// portal sky
		else
		{
			if(!drawskyboxportal)
			{
				if( !(tess.currentStageIteratorFunc == RB_StageIteratorSky))
				{	// /only/ process sky tris
					return;
				}
			}
		}
	}

	//
	// update performance counters
	//
	backEnd.pc.c_shaders++;
	backEnd.pc.c_vertexes += tess.numVertexes;
	backEnd.pc.c_indexes += tess.numIndexes;
	backEnd.pc.c_totalIndexes += tess.numIndexes * tess.numPasses;
	if (tess.fogNum && tess.shader->fogPass && r_drawfog->value == 1)
	{
		backEnd.pc.c_totalIndexes += tess.numIndexes;
	}

	//
	// call off to shader specific tess end function
	//
	tess.currentStageIteratorFunc();

	//
	// draw debugging stuff
	//
	if ( r_showtris->integer ) {
		DrawTris (input);
	}
	if ( r_shownormals->integer ) {
		DrawNormals (input);
	}
	// clear shader so we can tell we don't have any unclosed surfaces
	tess.numIndexes = 0;

	GLimp_LogComment( "----------\n" );
}
Пример #6
0
void	quadsquare::Render(const quadcornerdata& cd, GLubyte *vnc_array)
// Draws the heightfield represented by this tree.
// Returns the number of triangles rendered.
{
    VNCArray = vnc_array;
    bool_t fog_on;
    unsigned int i, j;
    int nx, ny;
    get_course_divisions( &nx, &ny );


    /* Save fog state */
    fog_on = is_fog_on();


    /*
     * Draw the "normal" blended triangles ( <= 2 terrains textures )
     */
    for (j=0; j<NumTerrains; j++) {
	InitArrayCounters();
	
	RenderAux(cd, SomeClip, j);

        if ( VertexArrayCounter == 0 ) {
            continue;
        } 

	glBindTexture( GL_TEXTURE_2D, TexId[j] );
	DrawTris();

	if ( j == Ice && getparam_terrain_envmap() ) {
	    /* Render Ice with environment map */
	    glDisableClientState( GL_COLOR_ARRAY );
	    glColor4f( 1.0, 1.0, 1.0, ENV_MAP_ALPHA / 255.0 );

	    DrawEnvmapTris();

	    glEnableClientState( GL_COLOR_ARRAY );
	}

    }

    /*
     * Draw the "special" triangles that have different terrain types
     * at each of the corners 
     */
    if ( getparam_terrain_blending() &&
	 getparam_perfect_terrain_blending() ) {

	/*
	 * Get the "special" three-terrain triangles
	 */
	InitArrayCounters();
	RenderAux( cd, SomeClip, -1 );
	
	if ( VertexArrayCounter != 0 ) {
	    /* Render black triangles */
	    glDisable( GL_FOG );
	    
	    /* Set triangle vertices to black */
	    for (i=0; i<VertexArrayCounter; i++) {
		colorval( VertexArrayIndices[i], 0 ) = 0;
		colorval( VertexArrayIndices[i], 1 ) = 0;
		colorval( VertexArrayIndices[i], 2 ) = 0;
		colorval( VertexArrayIndices[i], 3 ) = 255;
	    }
	    
	    /* Draw the black triangles */
	    glBindTexture( GL_TEXTURE_2D, TexId[0] );
	    DrawTris();
	    
	    /* Now we draw the triangle once for each texture */
	    if (fog_on) {
		glEnable( GL_FOG );
	    }

	    /* Use additive blend function */
	    glBlendFunc( GL_SRC_ALPHA, GL_ONE );

	    /* First set triangle colours to white */
	    for (i=0; i<VertexArrayCounter; i++) {
		colorval( VertexArrayIndices[i], 0 ) = 255;
		colorval( VertexArrayIndices[i], 1 ) = 255;
		colorval( VertexArrayIndices[i], 2 ) = 255;
	    }

	    for (j=0; j<NumTerrains; j++) {
		glBindTexture( GL_TEXTURE_2D, TexId[j] );

		/* Set alpha values */
		for (i=0; i<VertexArrayCounter; i++) {
		    colorval( VertexArrayIndices[i], 3 ) = 
			(Terrain[VertexArrayIndices[i]] == (terrain_t)j ) ? 
			255 : 0;
		}

		DrawTris();
	    }


	    /* Render Ice with environment map */
	    if ( getparam_terrain_envmap() ) {
		glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
	    
		/* Need to set alpha values for ice */
		for (i=0; i<VertexArrayCounter; i++) {
		    colorval( VertexArrayIndices[i], 3 ) = 
			(Terrain[VertexArrayIndices[i]] == Ice) ? 
			ENV_MAP_ALPHA : 0;
		}
		DrawEnvmapTris();
	    }
	}
    }

    glBlendFunc( GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA );
}