| 41 | } |
| 42 | |
| 43 | int main() |
| 44 | { |
| 45 | glfwSetErrorCallback(error); |
| 46 | |
| 47 | if (!glfwInit()) |
| 48 | return 1; |
| 49 | |
| 50 | glfwDefaultWindowHints(); |
| 51 | glfwWindowHint(GLFW_VISIBLE, false); |
| 52 | |
| 53 | #ifdef SYSTEM_DARWIN |
| 54 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); |
| 55 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 2); |
| 56 | glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, true); |
| 57 | glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); |
| 58 | #endif |
| 59 | |
| 60 | GLFWwindow * window = glfwCreateWindow(320, 240, "", nullptr, nullptr); |
| 61 | if (!window) |
| 62 | { |
| 63 | glfwTerminate(); |
| 64 | return -1; |
| 65 | } |
| 66 | |
| 67 | glbinding::addContextSwitchCallback([](ContextHandle handle){ |
| 68 | std::cout << "Activating context " << handle << std::endl; |
| 69 | }); |
| 70 | |
| 71 | glfwMakeContextCurrent(window); |
| 72 | |
| 73 | // print some gl infos (query) |
| 74 | |
| 75 | glbinding::initialize(glfwGetProcAddress, false); // only resolve functions that are actually used (lazy) |
| 76 | |
| 77 | std::cout << std::endl |
| 78 | << "OpenGL Version: " << aux::ContextInfo::version() << std::endl |
| 79 | << "OpenGL Vendor: " << aux::ContextInfo::vendor() << std::endl |
| 80 | << "OpenGL Renderer: " << aux::ContextInfo::renderer() << std::endl << std::endl; |
| 81 | |
| 82 | glbinding::setCallbackMask(CallbackMask::After | CallbackMask::ParametersAndReturnValue); |
| 83 | |
| 84 | glbinding::setAfterCallback([](const glbinding::FunctionCall & call) { |
| 85 | std::cout << call.function->name() << "("; |
| 86 | |
| 87 | for (unsigned i = 0; i < call.parameters.size(); ++i) |
| 88 | { |
| 89 | std::cout << call.parameters[i].get(); |
| 90 | if (i < call.parameters.size() - 1) |
| 91 | std::cout << ", "; |
| 92 | } |
| 93 | |
| 94 | std::cout << ")"; |
| 95 | |
| 96 | if (call.returnValue) |
| 97 | { |
| 98 | std::cout << " -> " << call.returnValue.get(); |
| 99 | } |
| 100 |
nothing calls this directly
no test coverage detected