int readShaderSource(char *fileName, GLchar **vertexShader, GLchar **fragmentShader) { int vSize, gSize, fSize; // // Allocate memory to hold the source of our shaders. // vSize = shaderSize(fileName, EVertexShader); fSize = shaderSize(fileName, EFragmentShader); if ((vSize == -1) || (fSize == -1)) { printf("Cannot determine size of the shader %s\n", fileName); exit(0); } *vertexShader = (GLchar *) malloc(vSize); *fragmentShader = (GLchar *) malloc(fSize); // // Read the source code // if (!readShader(fileName, EVertexShader, *vertexShader, vSize)) { printf("Cannot read the file %s.vert\n", fileName); return 0; } if (!readShader(fileName, EFragmentShader, *fragmentShader, fSize)) { printf("Cannot read the file %s.frag\n", fileName); return 0; } return 1; }
bool Shader::readShaderSource() { // Alocar memoria para o source code dos shaders m_VertShdStrLen = shaderSize(VERT_SHD); m_FragShdStrLen = shaderSize(FRAG_SHD); if (m_VertShdStrLen == -1) { // console->printfAndRender(1.0f, 0.0f, 0.0f, "Vertex Shader '%s.vert' not found", m_FileName); return false; } if (m_FragShdStrLen == -1) { // console->printfAndRender(1.0f, 0.0f, 0.0f, "Fragment Shader '%s.frag' not found", m_FileName); return false; } m_VertShdStr = (GLcharARB *) malloc(m_VertShdStrLen); m_FragShdStr = (GLcharARB *) malloc(m_FragShdStrLen); // Ler o source code dos shaders if (!readShader(VERT_SHD)) { // console->printfAndRender(1.0f, 0.0f, 0.0f, "Error reading '%s.vert'", m_FileName); return false; } if (!readShader(FRAG_SHD)) { // console->printfAndRender(1.0f, 0.0f, 0.0f, "Error reading '%s.frag'", m_FileName); return false; } return true; }