error c0000:syntax error in vs
***I Have syntax error in my shader class: " error c0000:syntax error "***
this is my read function and i think my program can not read my file:
char* Shader::read(char* filename) {
string line;
std::ifstream file;
file.open(filename);
file.open("FragmentShader.frag");
file.open("vertexShader.frag");
if (file.is_open())
{
while ( getline (file,line) )
{
cout << line << endl;
}
file.close();
}
else cout << "Unable to open file";
return 0;
}
And this my initializ vertex shader and fragment shader:
void Shader::init()
{
createVertexShader();
createFragmentShader();
mp = glCreateProgram ();
glAttachShader (mp, fs);
glAttachShader (mp, vs);
glLinkProgram (mp);
//validateProgram(mp);
}
and this are create vertex shader and fragment shader and compile them:
void Shader::createVertexShader()
{
vs = glCreateShader (GL_VERTEX_SHADER);
const char* vertexSource = read("vertexShader.vert");
if(!vertexSource)
{
std::cout << "errrrroooorrrr"<< std::endl;
return; // age intori she nabaiad baghieie code ejra beshe vagarna
hamin
}
glShaderSource (vs, 1, &vertexSource, NULL);
glCompileShader (vs);
}
/////////////////////////////////////////////////////////////////////
void Shader::createFragmentShader()
{
fs = glCreateShader (GL_FRAGMENT_SHADER);
const char* FragmentSource = read("FragmentShader.frag");
if(!FragmentSource)
{
std::cout << "errrrroooorrrr"<< std::endl;
return;
}
glShaderSource (fs, 1, &FragmentSource, NULL);
glCompileShader (fs);
}
but after run the program I have syntax error and program can not read my
text file
I need help to solve it,help me.der.h"
No comments:
Post a Comment