Shows simple usage of the AMD_performance_monitor extensionCopyright 2008-2014 Matus Chochlik. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
#include <cassert>
#include <iostream>
#include <GL/glew.h>
#include <GL/glut.h>
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;
const char* f1[2] = {" +--", " `--"};
const char* f2[2] = {" |", " "};
const char* f3[2] = {" +--", " `--"};
const char* f4[2] = {" |", ""};
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 << "]" << std::endl;
std::cout << f2[fgi] << f4[fci] << std::endl;
}
if(fgi != 0)
{
mon.SelectCounters(true, counters);
mon.Begin();
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 << "] = ";
std::cout << ri->Low();
std::cout << ri->Float();
std::cout << ri->Float() << "%";
std::cout << "too big";
std::cout << std::endl;
++ri;
}
}
}
}
return 0;
}
{
std::cerr
<< "Error (in "
<< "'): "
<< err.what()
<< " ["
<< ":"
<< "] "
<< std::endl;
}
return 1;
}