Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualD.V.D

Posted 12 November 2012 - 09:23 PM

My bad I thought I posted in the GL forum.

Okay but what do I do with the buffer if I want to compile the shader? My compile function only takes GLenum ShaderType and const GLchar* pShaderText. Since the buffer holds the text for the object, do I convert it to a GLchar? My compile code looks like this:

EDIT: Woops I thought the buffer was of class buffer not std::string. I think I understand this better now, Ill simply convert it to GLchar and see if it works.

EDIT2: Woops, Im still confused with how to do this, any help?

[source lang="cpp"]bool ShaderManager::AddShaderFile(GLenum ShaderType, const GLchar* pShaderText){ GLuint ShaderObj = glCreateShader(ShaderType); if (ShaderObj == 0) { fprintf(stderr, "Error creating shader type %d\n", ShaderType); Sleep(10000); return false; } // Save the shader object - will be deleted in the destructor shaderObjList.push_back(ShaderObj); const GLchar* p[1]; p[0] = pShaderText; GLint Lengths[1]; Lengths[0]= strlen(pShaderText); glShaderSource(ShaderObj, 1, p, Lengths); glCompileShader(ShaderObj); GLint success; glGetShaderiv(ShaderObj, GL_COMPILE_STATUS, &success); if (!success) { GLchar InfoLog[1024]; glGetShaderInfoLog(ShaderObj, 1024, NULL, InfoLog); fprintf(stderr, "Error compiling shader type %d: '%s'\n", ShaderType, InfoLog); Sleep(10000); return false; } glAttachShader(shaderProgram, ShaderObj); return true;}[/source]

#3D.V.D

Posted 12 November 2012 - 09:23 PM

My bad I thought I posted in the GL forum.

Okay but what do I do with the buffer if I want to compile the shader? My compile function only takes GLenum ShaderType and const GLchar* pShaderText. Since the buffer holds the text for the object, do I convert it to a GLchar? My compile code looks like this:

EDIT: Woops I thought the buffer was of class buffer not std::string. I think I understand this better now, Ill simply convert it to GLchar and see if it works.

EDIT2: Woops, Im still confused with how to do this, any help?

[source lang="cpp"]bool ShaderManager::AddShaderFile(GLenum ShaderType, const GLchar* pShaderText){ GLuint ShaderObj = glCreateShader(ShaderType); if (ShaderObj == 0) { fprintf(stderr, "Error creating shader type %d\n", ShaderType); Sleep(10000); return false; } // Save the shader object - will be deleted in the destructor shaderObjList.push_back(ShaderObj); const GLchar* p[1]; p[0] = pShaderText; GLint Lengths[1]; Lengths[0]= strlen(pShaderText); glShaderSource(ShaderObj, 1, p, Lengths); glCompileShader(ShaderObj); GLint success; glGetShaderiv(ShaderObj, GL_COMPILE_STATUS, &success); if (!success) { GLchar InfoLog[1024]; glGetShaderInfoLog(ShaderObj, 1024, NULL, InfoLog); fprintf(stderr, "Error compiling shader type %d: '%s'\n", ShaderType, InfoLog); Sleep(10000); return false; } glAttachShader(shaderProgram, ShaderObj); return true;}[/source]

#2D.V.D

Posted 12 November 2012 - 09:19 PM

My bad I thought I posted in the GL forum.

Okay but what do I do with the buffer if I want to compile the shader? My compile function only takes GLenum ShaderType and const GLchar* pShaderText. Since the buffer holds the text for the object, do I convert it to a GLchar? My compile code looks like this:

EDIT: Woops I thought the buffer was of class buffer not std::string. I think I understand this better now, Ill simply convert it to GLchar and see if it works.

[source lang="cpp"]bool ShaderManager::AddShaderFile(GLenum ShaderType, const GLchar* pShaderText){ GLuint ShaderObj = glCreateShader(ShaderType); if (ShaderObj == 0) { fprintf(stderr, "Error creating shader type %d\n", ShaderType); Sleep(10000); return false; } // Save the shader object - will be deleted in the destructor shaderObjList.push_back(ShaderObj); const GLchar* p[1]; p[0] = pShaderText; GLint Lengths[1]; Lengths[0]= strlen(pShaderText); glShaderSource(ShaderObj, 1, p, Lengths); glCompileShader(ShaderObj); GLint success; glGetShaderiv(ShaderObj, GL_COMPILE_STATUS, &success); if (!success) { GLchar InfoLog[1024]; glGetShaderInfoLog(ShaderObj, 1024, NULL, InfoLog); fprintf(stderr, "Error compiling shader type %d: '%s'\n", ShaderType, InfoLog); Sleep(10000); return false; } glAttachShader(shaderProgram, ShaderObj); return true;}[/source]

#1D.V.D

Posted 12 November 2012 - 09:14 PM

My bad I thought I posted in the GL forum.

Okay but what do I do with the buffer if I want to compile the shader? My compile function only takes GLenum ShaderType and const GLchar* pShaderText. Since the buffer holds the text for the object, do I convert it to a GLchar? My compile code looks like this:

[source lang="cpp"]bool ShaderManager::AddShaderFile(GLenum ShaderType, const GLchar* pShaderText){ GLuint ShaderObj = glCreateShader(ShaderType); if (ShaderObj == 0) { fprintf(stderr, "Error creating shader type %d\n", ShaderType); Sleep(10000); return false; } // Save the shader object - will be deleted in the destructor shaderObjList.push_back(ShaderObj); const GLchar* p[1]; p[0] = pShaderText; GLint Lengths[1]; Lengths[0]= strlen(pShaderText); glShaderSource(ShaderObj, 1, p, Lengths); glCompileShader(ShaderObj); GLint success; glGetShaderiv(ShaderObj, GL_COMPILE_STATUS, &success); if (!success) { GLchar InfoLog[1024]; glGetShaderInfoLog(ShaderObj, 1024, NULL, InfoLog); fprintf(stderr, "Error compiling shader type %d: '%s'\n", ShaderType, InfoLog); Sleep(10000); return false; } glAttachShader(shaderProgram, ShaderObj); return true;}[/source]

PARTNERS