9 #ifndef OGLPLUS_EXAMPLE_EXAMPLE_MAIN_1119071146_HPP
10 #define OGLPLUS_EXAMPLE_EXAMPLE_MAIN_1119071146_HPP
17 #include <oglplus/os/semaphore.hpp>
20 #include <system_error>
26 inline void example_print_std_error_common(
27 std::exception& error,
31 errstr <<
"Message: '"
37 inline void example_print_error_common(
42 if(error.SourceFile())
44 errstr <<
"Source file: '"
50 if(error.SourceLine())
52 errstr <<
"Source line: "
57 if(error.SourceFunc())
59 errstr <<
"Source function: '"
64 example_print_std_error_common(error, errstr);
67 errstr <<
"GL function: '";
71 errstr << error.GLLib();
74 errstr << error.GLFunc()
80 if(error.EnumParam() || error.EnumParamName())
82 errstr <<
"GL constant: ";
83 if(error.EnumParamName())
86 << error.EnumParamName()
99 if(error.BindTarget() || error.TargetName())
101 errstr <<
"Binding point: ";
102 if(error.TargetName())
105 << error.TargetName()
112 << error.BindTarget()
118 if(error.ObjectTypeName() || error.ObjectType())
120 errstr <<
"Object type: ";
121 if(error.ObjectTypeName())
124 << error.ObjectTypeName()
131 << error.ObjectType()
137 if((!error.ObjectDesc().empty()) || (error.ObjectName() >= 0))
139 errstr <<
"Object: ";
140 if(!error.ObjectDesc().empty())
143 << error.ObjectDesc()
149 << error.ObjectName()
155 if(error.SubjectTypeName() || error.SubjectType())
157 errstr <<
"Subject type: ";
158 if(error.SubjectTypeName())
161 << error.SubjectTypeName()
168 << error.SubjectType()
174 if((!error.SubjectDesc().empty()) || (error.SubjectName() >= 0))
176 errstr <<
"Subject: ";
177 if(!error.SubjectDesc().empty())
180 << error.SubjectDesc()
186 << error.SubjectName()
192 if(error.Identifier())
194 errstr <<
"Identifier: '"
195 << error.Identifier()
200 if(error.Index() >= 0)
208 if(error.Value() != 0)
216 if(error.Limit() != 0)
224 if(!error.Log().empty())
233 template <
typename Func>
234 inline int example_guarded_exec(Func func, std::ostream& errstr)
240 catch(ProgVarError& pve)
242 errstr <<
"Program variable error" << std::endl;
243 example_print_error_common(pve, errstr);
245 catch(ProgramBuildError& pbe)
247 errstr <<
"Program build error" << std::endl;
248 example_print_error_common(pbe, errstr);
250 catch(LimitError& le)
252 errstr <<
"Limit error" << std::endl;
253 example_print_error_common(le, errstr);
255 catch(ObjectError& oe)
257 errstr <<
"Object error" << std::endl;
258 example_print_error_common(oe, errstr);
262 errstr <<
"GL error" << std::endl;
263 example_print_error_common(err, errstr);
265 catch(std::system_error& sye)
267 errstr <<
"System error" << std::endl;
268 example_print_std_error_common(sye, errstr);
269 errstr <<
"Error code: " << sye.code() << std::endl;
272 catch(std::runtime_error& rte)
274 errstr <<
"Runtime error" << std::endl;
275 example_print_std_error_common(rte, errstr);
278 catch(std::exception& se)
280 errstr <<
"Error" << std::endl;
281 example_print_std_error_common(se, errstr);
287 inline int example_main(
288 int (*main_func)(
int,
char**),
295 int (*main_func)(int,
char**);
299 int operator()(
void)
const
301 os::CriticalSection cs(
"OGLplus example");
302 Application::ParseCommandLineOptions(argc, argv);
303 return main_func(argc, argv);
305 } wrapped_main = {main_func, argc, argv};
307 return example_guarded_exec(wrapped_main, std::cerr);
312 #endif // include guard
Declaration of OGLplus program-variable-related error.
Application/startup options-related declarations unrelated to OpenGL.