Exemple #1
0
	void __fastcall FindComponentClass(TReader *Reader, String ClassName, TComponentClass &ComponentClass)
	{
		if(ComponentClass == NULL)
		{
			TTypeInfo *TypeInfo = LookUpClass(ClassName);
			if(TypeInfo != NULL && TypeInfo->Kind == tkClass)
				ComponentClass = GetTypeData(TypeInfo)->ClassType;
		}
	}
bool ShaderUtilsGLSL::GetUniformData(GLuint programHandle, UniformDataArray &retData) const
{
  //Empty the return array
  retData.clear();  

  //Get if OpenGL calls can be made
  if(!gliCallBacks->GetGLInternalCallState())
  {
    return false;
  }

  //Get the number of uniforms for the program
  GLint numUniforms = 0;
  iglGetProgramiv(programHandle, GL_ACTIVE_UNIFORMS, &numUniforms);
  if(numUniforms <= 0)
  {
    return true;
  }

  //Get the max uniform string size
  GLint maxUniformSize = 0;
  iglGetProgramiv(programHandle, GL_ACTIVE_UNIFORM_MAX_LENGTH, &maxUniformSize);
  if(maxUniformSize <= 0)
  {
    return false;
  }

  //Allocate the array to get the uniform strings
  GLchar * readUniformName = new GLchar[maxUniformSize+1];

  //Loop for the number of uniforms in the program
  for(uint i=0;i<(uint)numUniforms;i++)
  {
    GLint  typeSize=0;
    GLenum type;
    GLsizei lengthWritten=0;
    string  newUniformName;

    //Call GetActiveUniform to get the name,type and size of the type
    iglGetActiveUniform(programHandle,i,maxUniformSize,&lengthWritten,&typeSize,&type,readUniformName);

    if(lengthWritten > 0)
    {
      //Convert to a string
      newUniformName = (char*)readUniformName;


      //Nvidia/ATI Hack ======================================
      // Nvidia (in 69.xx drivers) and ATI Cat 5.9 return a uniform for every element of arrays.
      // Only take note of the first one and ignore the rest
      bool ignoreUniform = false;
      if(newUniformName.length() > 3 &&
         newUniformName[newUniformName.length()-1] == ']')
      {
        //If the characters end with "[0]"
        if(newUniformName[newUniformName.length()-2] == '0' &&
           newUniformName[newUniformName.length()-3] == '[')
        {
          //Erase the last three characters
          newUniformName.erase(newUniformName.length()-3, 3);
          LOGERR(("Nvidia/ATI uniform array workaround for %s",newUniformName.c_str()));
        }
        else
        {
          //Don't process this uniform
          ignoreUniform = true;
        }
      }
      //End Hack ======================================


      //Ignore built in gl types
      if(newUniformName.find("gl_") != 0 && !ignoreUniform)
      {
        //Loop for the array size for the type
        vector<uint> indexDataArray;
        for(GLint s=0; s<typeSize; s++)
        {
          string testUniformName = newUniformName;
          if(s > 0)
          {
            //If it is an array type, get the index of each component
            string strBuffer;             
            StringPrintF(strBuffer, "[%u]",s);
            testUniformName += strBuffer;
          }

          //Get the location of the uniform
          GLint uniLocation = iglGetUniformLocation(programHandle,(const GLchar*)testUniformName.c_str());
          if(uniLocation < 0)
          {
            LOGERR(("GetUniformData - Uniform %s does not exist?",testUniformName.c_str()));

            //Clean up the uniform name
            delete [] readUniformName;
            return false;
          }

          //Add to the index data array
          indexDataArray.push_back(uniLocation);
        }

        UniformData newData;
        newData.indexData  = indexDataArray;
        newData.remapIndex = 0;

        newData.name = newUniformName;
        newData.size = typeSize;
        newData.type = type;

        //Check that the type is known
        if(!GetTypeData(newData.type, newData.numTypeElements, newData.baseFormat))
        {
          LOGERR(("GetUniformData - %s - Uniform is not a known type: 0x%x\n", newData.name.c_str(), newData.type));

          //Clean up the uniform name
          delete [] readUniformName;
          return false;
        }

        //Add the new data to the return array
        retData.push_back(newData);
      }
    }

  }

  //Clean up the uniform name
  delete [] readUniformName;

  return true;

}
Exemple #3
0
int TPropertyHandler::PropertyCount(TComponent* comp)
{
	PTypeInfo TypeInfo = (PTypeInfo)comp->ClassInfo();
	PTypeData TypeData = GetTypeData(TypeInfo);
	return (int)TypeData->PropCount;
}