Exemple #1
0
void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t v)
{
	GLint *uniforms = program->uniforms;
	vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]);

	if (uniforms[uniformNum] == -1)
		return;

	if (uniformsInfo[uniformNum].type != GLSL_VEC2)
	{
		ri.Printf( PRINT_WARNING, "GLSL_SetUniformVec2: wrong type for uniform %i in program %s\n", uniformNum, program->name);
		return;
	}

	if (v[0] == compare[0] && v[1] == compare[1])
	{
		return;
	}

	compare[0] = v[0];
	compare[1] = v[1];

	qglUniform2fARB(uniforms[uniformNum], v[0], v[1]);
}
Exemple #2
0
GLvoid APIENTRY GLDSA_ProgramUniform2f(GLuint program, GLint location,
	GLfloat v0, GLfloat v1)
{
	GL_UseProgramObject(program);
	qglUniform2fARB(location, v0, v1);
}
/*
** 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" );
}