void OpenMDLmodel::EnableMaterial( OpenMDL::Material* material )
{
	OpenMDL::String fullname;

	if( material->HasDiffuseMap() )
	{
		glActiveTextureARB( GL_TEXTURE0_ARB );
		glEnable( GL_TEXTURE_2D );
		char tmps[256];
		sprintf( tmps, "Textures/%s",  material->GetDiffuseMap().GetBuffer() );
		BindTextureByName( tmps );
	}

	glActiveTextureARB( GL_TEXTURE1_ARB );
	if( material->HasSpecularMap() )
	{
		glEnable( GL_TEXTURE_2D );
		fullname = OpenMDL::String("Textures/") + material->GetSpecularMap();
		BindTextureByName( fullname.GetBuffer() );
		cgSetParameter1i( m_UberShader_bSpecularMapping, 1 );
	}
	else
	{
		glDisable( GL_TEXTURE_2D );
		cgSetParameter1i( m_UberShader_bSpecularMapping, 0 );
	}

/*
	glActiveTextureARB( GL_TEXTURE2_ARB );
	if( material->HasNormalMap() )
	{
		glEnable( GL_TEXTURE_2D );
		fullname = OpenMDL::String("Textures/") + material->GetNormalMap();
		BindTextureByName( fullname.GetBuffer() );
		cgSetParameter1i( m_UberShader_bNormalMapping, 1 );
	}
	else
	{
		glDisable( GL_TEXTURE_2D );
		cgSetParameter1i( m_UberShader_bNormalMapping, 0 );
	}
*/

	glActiveTextureARB( GL_TEXTURE0_ARB );

	cgGLSetStateMatrixParameter( m_UberShader_ModelCamProj, CG_GL_MODELVIEW_PROJECTION_MATRIX, CG_GL_MATRIX_IDENTITY );
	cgGLSetStateMatrixParameter( m_UberShader_ModelCam, CG_GL_MODELVIEW_MATRIX, CG_GL_MATRIX_IDENTITY );
	cgGLSetParameter3f( m_UberShader_Lightpos_Pixel, m_LightInWorldSpace.x, m_LightInWorldSpace.y, m_LightInWorldSpace.z );
	cgGLSetParameter1f( m_UberShader_Ambient, m_Ambient );
	cgGLSetParameter3f( m_UberShader_CamPos, m_CamPos.x, m_CamPos.y, m_CamPos.z );
	cgGLSetParameter3f( m_UberShader_LightColor, m_LightColor.x, m_LightColor.y, m_LightColor.z );
	cgGLSetMatrixParameterfc( m_UberShader_WorldCam, m_WorldCam );
	cgGLSetParameter1f( m_UberShader_SpecularPower, material->GetSpecularCoeff() );
	cgGLSetParameter3f( m_UberShader_ClipPlane_Point, m_ClipPlane_Point.x, m_ClipPlane_Point.y, m_ClipPlane_Point.z );
	cgGLSetParameter3f( m_UberShader_ClipPlane_Normal, m_ClipPlane_Normal.x, m_ClipPlane_Normal.y, m_ClipPlane_Normal.z );

	m_UberShader.EnablePrograms();
}
Example #2
0
	//--
	void
	CgShaderCel::SetParamComputeOutline(bool bEnabled)
	{
		if(bEnabled)
		{
			cgSetParameter1i(m_cgParamComputeOutline, 1);
		}
		else
		{
			cgSetParameter1i(m_cgParamComputeOutline, 0);
		}
	}
Example #3
0
bool GLCgShader::SetConstant(const str_type::string& name, const int n)
{
	CGparameter param = SeekParameter(name, m_params);
	if (!param)
		return ShowInvalidParameterWarning(m_shaderName, name);

	cgSetParameter1i(param, n);
	if (CheckForError("Shader::SetConstant1I setting parameter", m_shaderName))
		return false;
	return true;
}
bool CgShaderProgramGL::setConstant(const io::stringc &Name, const f32* Buffer, s32 Count)
{
    if (!Buffer)
        return false;

    /* Get top-level parameter */
    CGparameter Param = cgGetNamedParameter(cgProgram_, Name.c_str());

    if (!Param)
        return false;

    /* Get array parameter */
    if (cgGetParameterType(Param) != CG_ARRAY)
        return false;

    s32 ArraySize = cgGetArraySize(Param, 0);

    for (s32 i = 0; i < ArraySize; ++i)
    {
        /* Get array element parameter */
        CGparameter ElementParam = cgGetArrayParameter(Param, i);

        switch (cgGetParameterType(ElementParam))
        {
        case CG_FLOAT:
            cgGLSetParameterArray1f(Param, 0, Count, Buffer);
            return true;
        case CG_FLOAT2:
            cgGLSetParameterArray2f(Param, 0, Count/2, Buffer);
            return true;
        case CG_FLOAT3:
            cgGLSetParameterArray3f(Param, 0, Count/3, Buffer);
            return true;
        case CG_FLOAT4:
            cgGLSetParameterArray4f(Param, 0, Count/4, Buffer);
            return true;
        case CG_FLOAT4x4:
            cgGLSetMatrixParameterArrayfc(Param, 0, Count/16, Buffer);
            return true;

        case CG_STRUCT:
        {
            /* Get structure field parameter */
            CGparameter FieldParam = cgGetFirstStructParameter(ElementParam);

            while (FieldParam)
            {
                switch (cgGetParameterType(FieldParam))
                {
                case CG_FLOAT:
                    cgGLSetParameter1f(FieldParam, *Buffer);
                    Buffer += 1;
                    break;
                case CG_FLOAT2:
                    cgGLSetParameter2fv(FieldParam, Buffer);
                    Buffer += 2;
                    break;
                case CG_FLOAT3:
                    cgGLSetParameter3fv(FieldParam, Buffer);
                    Buffer += 3;
                    break;
                case CG_FLOAT4:
                    cgGLSetParameter4fv(FieldParam, Buffer);
                    Buffer += 4;
                    break;
                case CG_FLOAT4x4:
                    cgGLSetMatrixParameterfc(FieldParam, Buffer);
                    Buffer += 16;
                    break;
                case CG_INT:
                    cgSetParameter1i(FieldParam, *((s32*)Buffer));
                    Buffer += 1;
                    break;
                default:
                    break;
                }

                FieldParam = cgGetNextParameter(FieldParam);
            }
        }
        break;

        default:
            break;
        }
    }

    return true;
}
Example #5
0
void CgEffect::SetBool(const char* name, bool b)
{
    cgSetParameter1i(this->retrieveParameter(name), b ? 1 : 0);
}
Example #6
0
void CgEffect::SetInt(const char* name, int i)
{
    cgSetParameter1i(this->retrieveParameter(name), i);
}
Example #7
0
int Skydome::Render()
{
    cgGLEnableProfile(psSkydomeProfile);
    cgGLBindProgram(psSkydomeProgram);

    cgSetParameter1f(dayTime, mDayTime);
	cgSetParameter1i(transition, stage);

    cgGLEnableTextureParameter(text1);
    cgGLEnableTextureParameter(text2);
	cgGLEnableTextureParameter(text3);

	glPushMatrix();
	//glTranslatef(0.0f, -100.0f, 0.0f);
	glRotatef(rotTheta,0.0f, 1.0f, 0.0f);
	glRotatef(270, 1.0f, 0.0f, 0.0f);

	glEnable(GL_TEXTURE_2D);

	//glBindTexture(GL_TEXTURE_2D, cloudTexture.TextureID);

	glBegin(GL_TRIANGLE_STRIP);

	for (int i=0; i < NumVertices; i++)
	{
		glColor3f(1.0f, 1.0f, 1.0f);

		glTexCoord2f(Vertices[i].u, Vertices[i].v);
		glVertex3f(Vertices[i].x, Vertices[i].y, Vertices[i].z);
	}

	glEnd();

	glPopMatrix();

	cgGLDisableTextureParameter(text1);
	cgGLDisableTextureParameter(text2);
	cgGLDisableTextureParameter(text3);

    cgGLDisableProfile(psSkydomeProfile);

	
	cgGLEnableProfile(psSkydomeSunProfile);
    cgGLBindProgram(psSkydomeSunProgram);

	cgGLEnableTextureParameter(suntext1);
    cgGLEnableTextureParameter(suntext2);

	/*glPushMatrix();
	glRotatef(mSunPhi-90.0, 0.0, 0.0, 1.0);
	//glTranslatef(-mSunPos.GetX(), -mSunPos.GetY(), 0.0);*/

	glPushMatrix();
	glEnable(GL_TEXTURE_2D);
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glTranslatef(mSunPos.GetX(), mSunPos.GetY(), 0.0);
	//glTranslatef(0.0, 1.0, 0.0);
	glRotatef(60 * mSunPhi + 90.0f, 0, 0, 1.0f);
	glScalef(10.0, 10.0, 10.0);
	glBegin(GL_QUADS);
		glTexCoord2f(0.0, 0.0);
		glVertex3f(-1.0, 0.0, 1.0);
		glTexCoord2f(0.0, 1.0);
		glVertex3f(-1.0, 0.0, -1.0);
		glTexCoord2f(1.0, 1.0);
		glVertex3f(1.0, 0.0, -1.0);
		glTexCoord2f(1.0, 0.0);
		glVertex3f(1.0, 0.0, 1.0);
	glEnd();
	glPopMatrix();

	//glPopMatrix();

	cgGLDisableTextureParameter(suntext1);
	cgGLDisableTextureParameter(suntext2);

	cgGLDisableProfile(psSkydomeSunProfile);
	
    return 1;
}
Example #8
0
void CCgUniform1i::update(const void* data, const SMaterial& material) const
{
	s32* Data = (s32*)data;
	cgSetParameter1i(Parameter, *Data);
}
Example #9
0
 void ShaderParameterCg::Set(int value)
 {
     cgSetParameter1i(this->_param, value);
 }
Example #10
0
 void ShaderParameterCg::Set(bool value)
 {
     cgSetParameter1i(this->_param, value ? 1 : 0);
 }
 //
 // SetInt
 //
 void CCgUniform::SetInt( 
                         GLint x 
                         )
 {
     cgSetParameter1i( m_Parameter, x );
 }
 //
 // SetBool
 //
 void CCgUniform::SetBool( 
                          bool x 
                          )
 {
     cgSetParameter1i( m_Parameter, x ? CG_TRUE : CG_FALSE );
 }