xst_astring	CCGShaderSystem::CreateShaderCode(u32 uiVSInput, u32 uiPSInput)
{
    xst_astring strCode;
    strCode.reserve( 1024 );

    //strCode += GetShaderCode( ShaderCodes::PER_FRAME_CBUFFER ) + xst_endl;
    //strCode += GetShaderCode( ShaderCodes::PER_OBJECT_CBUFFER ) + xst_endl;

    //Vertex shader
    xst_stringstream ssVS;
    ssVS<< "struct VS_INPUT{" << xst_endl
        << "	float4 pos : POSITION;" << xst_endl
        << GetShaderCode( ShaderCodes::PER_FRAME_VS_CBUFFER ) << xst_endl
        << GetShaderCode( ShaderCodes::PER_DRAWCALL_VS_CBUFFER ) << xst_endl;

    if( uiVSInput & ILE::COLOR )
    {
        ssVS << "	float4 color : COLOR0;" << xst_endl;
    }

    ssVS<< "};" << xst_endl
        << "struct PS_INPUT{" << xst_endl
        << "	float4 pos : SV_POSITION" << xst_endl;

    if( uiPSInput & ILE::COLOR )
    {
        ssVS << "	float4 color : COLOR0;" << xst_endl;
    }

    ssVS<< "};" << xst_endl
        << "PS_INPUT vs_main(VS_INPUT In)" << xst_endl
        << "{" << xst_endl
        << "	PS_INPUT Out = (PS_INPUT)0;" << xst_endl
        << "	Out.pos = mul( In.pos, " << GetConstantName( ShaderConstants::MTX_OBJ_WORLD_VIEW_PROJECTION ) << " );" <<xst_endl
        << "	Out.color = In.color;" << xst_endl
        << "	return Out;" << xst_endl
        << "}" << xst_endl;

    strCode += ssVS.str() + xst_endl;

    xst_stringstream ssPS;
    ssPS<< "float4 ps_main(PS_INPUT In) : COLOR" << xst_endl
        << "{" << xst_endl
        << "	return In.color;" << xst_endl
        << "}";

    strCode += ssPS.str();

    return strCode;
}
示例#2
0
void CGLShader::Load(std::string &&filename)
{
  std::string shaderCode = GetShaderCode(filename);
  GLint length = shaderCode.size();
	
  m_shader = glCreateShader(m_shaderType);

  const char *code = shaderCode.c_str();
  glShaderSource(m_shader, 1, &code, &length);
}
示例#3
0
eMaterialShaderParamType MaterialShader::GetShaderOutputType() const {
	std::vector<MaterialShaderParameter> params;
	eMaterialShaderParamType ret;
	ExtractShaderParameters(GetShaderCode(), "main", ret, params);
	return ret;
}