Error& EnumParam(Enum_ param) { #if !OALPLUS_ERROR_NO_AL_SYMBOL _enumpar = ALenum(param); _enumpar_name = EnumValueName(param).c_str(); #endif (void)param; return *this; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(800, 600); glutInitWindowPosition(100,100); glutCreateWindow("OGLplus+GLUT+GLEW"); if(glewInit() == GLEW_OK) try { glGetError(); oglplus::Context context; // std::cout << "Limits:" << std::endl; // std::size_t w = 0; for(auto r=oglplus::EnumValueRange<oglplus::LimitQuery>(); !r.Empty(); r.Next()) { std::size_t n = EnumValueName(r.Front()).size(); if(w < n) w = n; } for(auto r=oglplus::EnumValueRange<oglplus::LimitQuery>(); !r.Empty(); r.Next()) { auto ev = r.Front(); std::cout << std::setw(w) << EnumValueName(ev).c_str() << ": "; try { std::cout << context.FloatLimit(ev); } catch(...){ std::cout << "N/A"; } std::cout << std::endl; } return 0; } catch(oglplus::Error& err) { std::cerr << "Error (in " << err.GLSymbol() << ", " << err.ClassName() << ": '" << err.ObjectDescription() << "'): " << err.what() << " [" << err.File() << ":" << err.Line() << "] "; std::cerr << std::endl; err.Cleanup(); } return 1; }
static void ThrowIfOverLimit( LimitQuery limit, GLint value, GLint max_limit ) { OGLPLUS_HANDLE_ERROR_IF( value > max_limit, GL_INVALID_VALUE, LimitError::Message(), LimitError, GLFunc(EnumValueName(limit).c_str()) ); }
void run_example_loop( const x11::Display& display, const x11::Window& win, const glx::Context& ctx, std::unique_ptr<Example>& example, ExampleThreadData::Common& common, ExampleClock& clock, GLuint width, GLuint height ) { std::cout << "-+-[Begin]" << std::endl; #if GL_ARB_debug_output && !OGLPLUS_NO_LAMBDAS ARB_debug_output dbg; ARB_debug_output::LogSink sink( [](const ARB_debug_output::CallbackData& data) -> void { std::cout << " |" << std::endl; std::cout << " +-+-[" << data.id << "] '" << data.message << "'" << std::endl; std::cout << " | +---[source] '" << EnumValueName(data.source).c_str() << "'" << std::endl; std::cout << " | +---[type] '" << EnumValueName(data.type).c_str() << "'" << std::endl; std::cout << " | `---[severity] '" << EnumValueName(data.severity).c_str() << "'" << std::endl; } ); dbg.Control( DebugOutputARBSource::DontCare, DebugOutputARBType::DontCare, DebugOutputARBSeverity::Low, true ); dbg.InsertMessage( DebugOutputARBSource::Application, DebugOutputARBType::Other, 0, DebugOutputARBSeverity::Low, "Starting main loop" ); #endif // GL_ARB_debug_output win.SelectInput( StructureNotifyMask| PointerMotionMask| KeyPressMask ); ::Atom wmDelete = ::XInternAtom(display, "WM_DELETE_WINDOW", True); ::XSetWMProtocols(display, win, &wmDelete, 1); XEvent event; os::steady_clock os_clock; bool done = false; while(!done && !common.failure) { while(display.NextEvent(event)) { switch(event.type) { case ClientMessage: case DestroyNotify: done = true; break; case ConfigureNotify: width = event.xconfigure.width; height = event.xconfigure.height; example->Reshape( width, height ); case MotionNotify: example->MouseMove( event.xmotion.x, height- event.xmotion.y, width, height ); break; case KeyPress: if(::XLookupKeysym( &event.xkey, 0 ) == XK_Escape) done = true; break; default:; } } clock.Update(os_clock.seconds()); if(!example->Continue(clock)) break; example->Render(clock); ctx.SwapBuffers(win); } std::cout << " `-[Done]" << std::endl; }
int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); glutInitWindowSize(800, 600); glutInitWindowPosition(100,100); glutCreateWindow("OGLplus+GLUT+GLEW"); if(glewInit() == GLEW_OK) try { glGetError(); namespace se = oglplus::smart_enums; oglplus::Context gl; oglplus::AMD_performance_monitor apm; const char* f1[2] = {" +--", " `--"}; const char* f2[2] = {" |", " "}; const char* f3[2] = {" +--", " `--"}; const char* f4[2] = {" |", ""}; auto groups = apm.GetGroups(); auto gi=groups.begin(), ge=groups.end(); std::cout << "--+-{Performance monitor groups}" << std::endl; if(gi != ge) std::cout << " |" << std::endl; while(gi != ge) { auto group = *gi; ++gi; const int fgi = (gi == ge)?1:0; std::cout << f1[fgi] << "+-["; std::cout << group.GetString(); std::cout << "]" << std::endl; std::cout << f2[fgi] << f4[0] << std::endl; GLint max; auto counters = group.GetCounters(max); auto ci=counters.begin(), ce=counters.end(); while(ci != ce) { auto counter = *ci; ++ci; const int fci = (ci == ce)?1:0; std::cout << f2[fgi] << f3[fci] << "("; std::cout << counter.GetString(); std::cout << ") ["; std::cout << EnumValueName(counter.Type()); std::cout << "]" << std::endl; std::cout << f2[fgi] << f4[fci] << std::endl; } if(fgi != 0) { oglplus::PerfMonitorAMD mon; mon.SelectCounters(true, counters); mon.Begin(); // Imagine some heavy duty rendering here gl.Clear().ColorBuffer(); mon.End(); if(mon.ResultAvailable()) { std::vector<oglplus::PerfMonitorAMDResult> values; mon.Result(values); auto ri=values.begin(), re=values.end(); while(ri != re) { auto counter = ri->Counter(); auto type = counter.Type(); std::cout << counter.GetString(); std::cout << " ["; std::cout << EnumValueName(type); std::cout << "] = "; if(type == se::UnsignedInt()) std::cout << ri->Low(); else if(type == se::Float()) std::cout << ri->Float(); else if(type == se::Percentage()) std::cout << ri->Float() << "%"; else if(type == se::UnsignedInt64()) std::cout << "too big"; std::cout << std::endl; ++ri; } } } } return 0; } catch(oglplus::Error& err) { std::cerr << "Error (in " << err.GLFunc() << "'): " << err.what() << " [" << err.SourceFile() << ":" << err.SourceLine() << "] " << std::endl; } return 1; }