Hi,
the program crashes on this line (by saying : the application has encountered a problem and have to close):
vsh = glCreateShader(GL_VERTEX_SHADER);
vsh is declared as a global variable
i have a radeon 9600 SE with 5.5 catalyst
this is my code :
class loadShader
{
private :
long int fileLength ;
char *content ;
public :
loadShader(char *fileName1, char *fileName2) ;
void loadStrings(char *fileName) ;
};
loadShader::loadShader(char *fileName1, char *fileName2)
{
vsh = glCreateShader(GL_VERTEX_SHADER);
fsh = glCreateShader(GL_FRAGMENT_SHADER);
loadStrings(fileName1) ;
const char *cContent = content ;
glShaderSource(vsh, 1, &cContent, NULL);
free((void*)content);
loadStrings(fileName2) ;
const char *cContent2 = content ;
glShaderSource(fsh, 1, &cContent2, NULL);
free((void*)content);
glCompileShader(vsh);
glCompileShader(fsh);
unsigned short int ph = glCreateProgram();//program handler
glAttachShader(ph, vsh);
glAttachShader(ph, fsh);
glLinkProgram(ph);
glUseProgram(ph);
}
void loadShader::loadStrings(char *fileName)
{
ifstream file ;
file.open(fileName);
file.seekg(0, ios::end);
fileLength = file.tellg();
content = (char *)malloc(sizeof(char) * (fileLength+1));
file.seekg(0, ios::beg);
file.read(content, fileLength);
content[fileLength] = '\0' ;
file.close();
}
this is the main function :
int main(int argc, char *argv[])
{
myLoader= new loader3ds() ;
glutInit (&argc, argv) ;
glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH) ;
glutInitWindowSize (640, 480) ;
glutInitWindowPosition (250,250) ;
glutCreateWindow (argv [0]) ;
glEnable( GL_DEPTH_TEST );
glClearColor(0, 0, 1, 0);
myLoader->loadTextures() ;
myLoader->lighting() ;
glutReshapeFunc (reshape) ;
glutKeyboardFunc (keyboard) ;
glutDisplayFunc (display) ;
loadShader *myShaderLoader = new loadShader("vertexShader.txt", "fragmentShader.txt");
glutMainLoop () ;
return 0 ;
}