コード例 #1
0
ファイル: Shader.cpp プロジェクト: teodorplop/OpenGL-Engine
void Shader::SetUniformDirectionalLight(const char* name, const DirectionalLight& light) {
	string baseName = name;
	SetUniform3f((baseName + ".color").c_str(), light.color.ToVector3());
	SetUniform1f((baseName + ".ambientIntensity").c_str(), light.ambientIntensity);
	SetUniform3f((baseName + ".direction").c_str(), light.direction);
	SetUniform1f((baseName + ".diffuseIntensity").c_str(), light.diffuseIntensity);
}
コード例 #2
0
ファイル: Shader.cpp プロジェクト: Enigma0960/Sparky
	void Shader::ResolveAndSetUniform(ShaderUniformDeclaration* uniform, byte* data, int offset)
	{
		switch (uniform->GetType())
		{
			case ShaderUniformDeclaration::Type::FLOAT32:
				SetUniform1f(uniform->GetLocation(), *(float*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::SAMPLER2D:
			case ShaderUniformDeclaration::Type::INT32:
				SetUniform1i(uniform->GetLocation(), *(int*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::VEC2:
				SetUniform2f(uniform->GetLocation(), *(maths::vec2*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::VEC3:
				SetUniform3f(uniform->GetLocation(), *(maths::vec3*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::VEC4:
				SetUniform4f(uniform->GetLocation(), *(maths::vec4*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::MAT3:
				// TODO: SetUniformMat3(uniform->GetLocation(), *(maths::mat3*)&data[offset]);
				break;
			case ShaderUniformDeclaration::Type::MAT4:
				SetUniformMat4(uniform->GetLocation(), *(maths::mat4*)&data[offset]);
				break;
			default:
				SP_ASSERT(false, "Unknown type!");
		}
	}
コード例 #3
0
ファイル: wes_state.c プロジェクト: Solexid/gl-wes-v2
GLvoid wes_state_init()
{
    int i;

    u_activetex = 0;
    SetUniform1i(uEnableRescaleNormal, 0);
    SetUniform1i(uEnableNormalize, 0);
    for(i = 0; i != WES_CLIPPLANE_NUM; i++){
        SetUniform4i(uEnableTextureGen[i], 0, 0, 0, 0);
    }
    for(i = 0; i != WES_CLIPPLANE_NUM; i++){
        SetUniform1i(uEnableClipPlane[i], 0);
    }
    SetUniform1i(uEnableLighting, 0);
    SetUniform1i(uEnableColorMaterial, 0);
    SetUniform1i(uEnableFog, 0);
    SetUniform1i(uEnableFogCoord, 0);

    for(i = 0; i != WES_LIGHT_NUM; i++){
        SetUniform1i(uEnableLight[i], 0);
        SetUniform4f(uLight[i].Position, 0.0, 0.0, 1.0, 0.0);
        SetUniform3f(uLight[i].Attenuation, 1.0, 0.0, 0.0);
        SetUniform4f(uLight[i].ColorAmbient, 0.0, 0.0, 0.0, 1.0);
        SetUniform4f(uLight[i].ColorDiffuse, 0.0, 0.0, 0.0, 1.0);
        SetUniform4f(uLight[i].ColorSpec, 0.0, 0.0, 0.0, 1.0);
        SetUniform3f(uLight[i].SpotDir, 0.0, 0.0, -1.0);
        SetUniform2f(uLight[i].SpotVar, 0.0, 180.0);
    }
    /* GL_LIGHT0's default parameters differ in these cases: */
    SetUniform4f(uLight[0].ColorDiffuse, 1.0, 1.0, 1.0, 1.0);
    SetUniform4f(uLight[0].ColorSpec, 1.0, 1.0, 1.0, 1.0);

    SetUniform1f(uRescaleFactor, 1.0);

    for(i = 0; i != WES_FACE_NUM; i++){
        SetUniform4f(uMaterial[i].ColorAmbient, 0.2, 0.2, 0.2, 1.0);
        SetUniform4f(uMaterial[i].ColorDiffuse, 0.8, 0.8, 0.8, 1.0);
        SetUniform4f(uMaterial[i].ColorSpec, 0.0, 0.0, 0.0, 1.0);
        SetUniform4f(uMaterial[i].ColorEmissive, 0.0, 0.0, 0.0, 1.0);
        SetUniform1f(uMaterial[i].SpecExponent, 0.0);
        SetUniform1i(uMaterial[i].ColorMaterial, 0);
    }

    SetUniform4f(uLightModel.ColorAmbient, 0.0, 0.0, 0.0, 1.0);
    SetUniform1i(uLightModel.TwoSided, GL_FALSE);
    SetUniform1i(uLightModel.LocalViewer, GL_FALSE);
    SetUniform1i(uLightModel.ColorControl, 0);

    SetUniform1i(uFogMode, 1);
    SetUniform1f(uFogDensity, 1.0);
    SetUniform1f(uFogStart, 0.0);
    SetUniform1f(uFogEnd, 1.0);
    SetUniform4f(uFogColor, 0.0, 0.0, 0.0, 0.0);

    for(i = 0; i < WES_MULTITEX_NUM; i++){
        SetUniform1i(uTexUnit[i], i);
        SetUniform4f(uTexEnvColor[i], 0.0f, 0.0f, 0.0f, 0.0f);
    }
    SetUniform1f(uAlphaRef, 0.0);

    u_progstate.uEnableAlphaTest = 0;
    u_progstate.uEnableFog = 0;
    u_progstate.uEnableClipPlane = 0;
    u_progstate.uAlphaFunc = 8;
    for(i = 0; i < WES_MULTITEX_NUM; i++){
        u_progstate.uTexture[i].Enable = 0;
        u_progstate.uTexture[i].Mode = WES_FUNC_MODULATE;
        u_progstate.uTexture[i].RGBCombine = WES_FUNC_MODULATE;
        u_progstate.uTexture[i].AlphaCombine = WES_FUNC_MODULATE;
        u_progstate.uTexture[i].Arg[0].RGBSrc = WES_SRC_TEXTURE;
        u_progstate.uTexture[i].Arg[1].RGBSrc = WES_SRC_PREVIOUS;
        u_progstate.uTexture[i].Arg[2].RGBSrc = WES_SRC_CONSTANT;
        u_progstate.uTexture[i].Arg[0].AlphaSrc = WES_SRC_TEXTURE;
        u_progstate.uTexture[i].Arg[1].AlphaSrc = WES_SRC_PREVIOUS;
        u_progstate.uTexture[i].Arg[2].AlphaSrc = WES_SRC_CONSTANT;
        u_progstate.uTexture[i].Arg[0].RGBOp = WES_OP_COLOR;
        u_progstate.uTexture[i].Arg[1].RGBOp = WES_OP_COLOR;
        u_progstate.uTexture[i].Arg[2].RGBOp = WES_OP_ALPHA;
        u_progstate.uTexture[i].Arg[0].AlphaOp = WES_OP_ALPHA;
        u_progstate.uTexture[i].Arg[1].AlphaOp = WES_OP_ALPHA;
        u_progstate.uTexture[i].Arg[2].AlphaOp = WES_OP_ALPHA;
    }
    u_progstate.uTexture[0].Enable = 1;

    //wes_state_update();
}
コード例 #4
0
ファイル: Shader.cpp プロジェクト: Enigma0960/Sparky
	void Shader::SetUniform3f(const String& name, const maths::vec3& vector)
	{
		SetUniform3f(GetUniformLocation(name), vector);
	}