GLSL weird '<' syntax error in vertex shader

Started by
14 comments, last by SetsudanHana 10 years ago

Can you show your entire manager.loadTextFile() function? It may be in entirety up above, but it is best to show the whole thing, function header and all, so we can be confident that there are no lines that we aren't seeing.

Also, what does


std::cout << vertex_shader;

output?

Advertisement

@mhagain

yes it is set up to unicode

Try switching to multibyte and see if the problem reproduces.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

loadTextFile function:


std::string ResourceManager::loadTextFile(const std::string& path)
{
	std::ifstream file(path);

	if(!file.good())
	{
		OutputDebugStringA("File not found");
		return nullptr;
	}

	std::stringstream stream ;
	stream << file.rdbuf();

	file.close();

	return stream.str();
}

i cant use cout, becuase i dont have console, but OutputDebugStringA on each of them gives this:

#version 400
in vec3 vector_position;
void main()
{
gl_Position = vec4(vector_position, 1.0f);
}#version 400
out vec4 color;
void main()
{
color = vec4(1.0f, 0.0f, 0.0f, 1.0f);
}

last line dont have '\n', thats why they looked merged

EDIT:

changing to multibyte, didnt do anything

@mhagain

yes it is set up to unicode

Try switching to multibyte and see if the problem reproduces.

I looked again, and using OutputDebugStringA() with UTF-16 flags defined for Windows seems dubious, but I'll leave that be since that's a different topic.

Also, check the info for #5: http://en.cppreference.com/w/cpp/string/basic_string/basic_string
Return nullptr as a string is undefined behavior, since passing an invalid pointer to basic_string's constructor is undefined behavior.

I'll try to think of other troubleshooting steps in the meantime.

OH!


    container = manager.loadTextFile(file + ".vs");
    const char* vertex_shader = container.c_str();
    container = manager.loadTextFile(file + ".fs");
    const char* fragment_shader = container.c_str();

You're returning a pointer to a string's contents, then overwriting its contents! Try putting them in separate strings, or interleave loading and compiling them.

it works, i knew that it is something so simple... I'm just dumb

This topic is closed to new replies.

Advertisement