my shader that work with renderMonkey don't work with my opengl program please help !

Started by
12 comments, last by TheSeb 18 years, 10 months ago
EDIT : my info log say this : Link successful. The GLSL vertex shader will run in hardware. The GLSL fragment shader will run in hardware. and i have tried with another shader(toon shading) and it works, the problem is for the other shader (per pixel lighting): i have no lighting... even not gouraud. so i suppose (can it be something else ?) that some variable which are in my shader are not in the opengl program. i use in my shader "gl_LightSource[0].halfVector". HalfVector is not present in my opengl program, is it generated by opengl or have i to do something ?if yes what ? in the shader or in the opengl program ? i put the code of the lighting part of my opengl program and the shader code (per pixel lighting): see the end of the page for a copy of that message + the code _______________________________________________________________________________ original first message : Hi, I have made a shader which works with renderMonkey, but when i add this shader to my opengl program the model appears in black. I have used glIntercept and i have these errors : GL ERROR - Function glAttachShader generated error GL_INVALID_VALUE GL ERROR - Function glAttachShader generated error GL_INVALID_VALUE GL ERROR - Function glLinkProgram generated error GL_INVALID_VALUE GL ERROR - Function glUseProgram generated error GL_INVALID_VALUE this is my code :
loadShader::loadShader(char *fileName1, char *fileName2)
{
	
	unsigned int vsh = glCreateShader(GL_VERTEX_SHADER);
	unsigned int 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);
}
	








[Edited by - TheSeb on June 4, 2005 5:30:10 PM]
Advertisement
Post the actual shader code please.
EDIT : i have changed the "unsigned int" by "GLuint" and now i have these errors :
GLDriver - Shutdown - Current OpenGL context 0x10000?
GLDriver - Shutdown - Outstanding OpenGL context 0x10000 ?




[Edited by - TheSeb on June 6, 2005 4:01:25 PM]
up !
GLint status=0 ;
glGetObjectParameterivARB(fsh, GL_OBJECT_LINK_STATUS_ARB, &status);
cout<<"status "<<dec<<status<<endl ;

this gives me the status equal to 0, so there is a link problem, but can i do ?
extract the logs for the shaders to see whats going on..
yes but with that code my file which contain the log is empty :
int infologLength = 0;	int charsWritten  = 0;	char *infoLog;	glGetObjectParameterivARB(vsh, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength);		    if (infologLength > 0)	    {			cout<<"shader "<<infologLength<<endl ;			infoLog = (char *)malloc(infologLength);			glGetInfoLogARB(vsh, infologLength, &charsWritten, infoLog);			ofstream oFile3("infoLogFile.txt");			oFile3<<infoLog ;			free(infoLog);	    }


i have also noticed that infologLength has a lenght of 1...

[Edited by - TheSeb on June 3, 2005 5:13:35 PM]
i have used gl intercept and it gives me that :
GL ERROR - Function glUseProgram(2147483649) generated error GL_INVALID_OPERATION
GL ERROR - Function glGetObjectParameterivARB(536870913,GL_LINK_STATUS,0x12fda4) generated error GL_INVALID_ENUM
GLDriver - Shutdown - Current OpenGL context 0x10000?
GLDriver - Shutdown - Outstanding OpenGL context 0x10000 ?
===================================================
Log End.

i don't understand what's wrong with my code... (i reput it here)

loadShader::loadShader(char *fileName1, char *fileName2){		GLuint vsh = glCreateShader(GL_VERTEX_SHADER);	GLuint fsh = glCreateShader(GL_FRAGMENT_SHADER);		loadStrings(fileName1) ;	const char *cContent = content ;		ofstream oFile1("sortie shader1.txt");	oFile1<<content ;		glShaderSource(vsh, 1, &cContent, NULL);	free((void*)content);	loadStrings(fileName2) ;	const char *cContent2 = content ;		ofstream oFile2("sortie shader2.txt");	oFile2<<content ;		glShaderSource(fsh, 1, &cContent2, NULL);	free((void*)content);	glCompileShader(vsh);	glCompileShader(fsh);	GLuint ph = glCreateProgram();//program handler	glAttachShader(ph, vsh);	glAttachShader(ph, fsh);	glLinkProgram(ph);	glUseProgram(ph);		GLint status=0 ;	glGetObjectParameterivARB(fsh, GL_OBJECT_LINK_STATUS_ARB, &status);	cout<<"status "<<dec<<status<<endl ;	GLint infologLength = 0;	GLint charsWritten  = 0;	GLchar *infoLog;	glGetObjectParameterivARB(vsh, GL_OBJECT_INFO_LOG_LENGTH_ARB, &infologLength);		    if (infologLength > 0)	    {			cout<<"shader "<<infologLength<<endl ;			infoLog = (char *)malloc(infologLength);			glGetInfoLogARB(vsh, infologLength, &charsWritten, infoLog);			ofstream oFile3("infoLogFile.txt");			oFile3<<infoLog ;			//free(infoLog);	    }
ok thanks, my info log say this :
Link successful. The GLSL vertex shader will run in hardware. The GLSL fragment shader will run in hardware.

and i have tried with another shader(toon shading) and it works, the problem is for the other shader (per pixel lighting): i have no lighting... even not gouraud.
so i suppose (can it be something else ?) that some variable which are in my shader are not in the opengl program.
i use in my shader "gl_LightSource[0].halfVector". HalfVector is not present in my opengl program, is it generated by opengl or have i to do something ?if yes what ? in the shader or in the opengl program ?
i put the code of the lighting part of my opengl program and the shader code (per pixel lighting):


[Edited by - TheSeb on June 6, 2005 4:30:52 PM]
how do you enable texturing?

This topic is closed to new replies.

Advertisement