Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Program::Build not catchable on error? #142

Open
thegrb93 opened this issue Apr 23, 2018 · 3 comments
Open

Program::Build not catchable on error? #142

thegrb93 opened this issue Apr 23, 2018 · 3 comments

Comments

@thegrb93
Copy link

thegrb93 commented Apr 23, 2018

I have a program with a shader that fails to compile, but when I try to catch the CompileError, it is uncatchable. I just get terminate called after throwing an instance of 'oglplus::ObjectError' what(): OpenGL numeric argument out of range.

try
{
	std::cout << "Test1\n";
	//throw std::runtime_error("");
	prog.Build();
	std::cout << "Test2\n";
}
catch(oglplus::CompileError err)
{
	std::cout << "Test3\n";
	std::cout << prog.GetInfoLog() << std::endl;
}
catch(...)
{
	std::cout << "Test4\n";
}

try{
	prog.Use();
}
catch(...)
{
	std::cout << "Test5\n";
	return;
}

With this code, 'Test1' is printed and then the terminate message and the program terminates.

If I uncomment the 'throw' then I get
Test1
Test4
Test5

@thegrb93
Copy link
Author

thegrb93 commented Apr 23, 2018

I found out that it's because program.Build builds the shaders with shader.Compile(std::nothrow). If I compile the shaders myself, I think it should work

@thegrb93
Copy link
Author

Yeah, it works when I do

try
{fs.Compile();}
catch(oglplus::CompileError)
{
	std::cout << fs.GetInfoLog() << std::endl;
	return;
}

@thegrb93
Copy link
Author

thegrb93 commented Apr 23, 2018

Same thing happens with prog.Build when it tries to link. I've replaced prog.Build with this and it works now.

try
{vs.Compile();}
catch(oglplus::CompileError)
{
	std::cout << vs.GetInfoLog() << std::endl;
	return;
}
try
{fs.Compile();}
catch(oglplus::CompileError)
{
	std::cout << fs.GetInfoLog() << std::endl;
	return;
}
try
{prog.Link();}
catch(oglplus::LinkError)
{
	std::cout << prog.GetInfoLog() << std::endl;
	return;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant