Copyright 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 <GL/glew.h>
#include <GLFW/glfw3.h>
#include <iostream>
#include <stdexcept>
static void run() {
using namespace eagine::oglp;
}
std::cout <<
"Renderer: " <<
extract(
info) << std::endl;
}
std::cout <<
"Version: " <<
extract(
info) << std::endl;
}
std::cout <<
"Major version: " <<
extract(
info) << std::endl;
}
std::cout <<
"Minor version: " <<
extract(
info) << std::endl;
}
std::cout <<
"GLSL Version: " <<
extract(
info) << std::endl;
}
std::cout << "Extensions:" << std::endl;
if(
ok extensions{gl.
get_extensions()}) {
for(auto name : extensions) {
std::cout << " " << name << std::endl;
}
} else {
std::cerr << "failed to get GL extension list: "
<< (!extensions).
message() << std::endl;
}
}
static void init_and_run() {
if(!glfwInit()) {
throw std::runtime_error("GLFW initialization error");
} else {
glfwWindowHint(GLFW_DOUBLEBUFFER, GL_TRUE);
int width = 800, height = 600;
GLFWwindow* window =
glfwCreateWindow(width, height, "OGLplus example", nullptr, nullptr);
if(!window) {
throw std::runtime_error("Error creating GLFW window");
} else {
glfwMakeContextCurrent(window);
glewExperimental = GL_TRUE;
GLenum init_result = glewInit();
glGetError();
if(init_result != GLEW_OK) {
throw std::runtime_error("OpenGL/GLEW initialization error.");
} else {
run();
}
}
}
}
auto main() -> int {
try {
init_and_run();
return 0;
} catch(std::runtime_error& sre) {
std::cerr << "Runtime error: " << sre.what() << std::endl;
} catch(std::exception& se) {
std::cerr << "Unknown error: " << se.what() << std::endl;
}
return 1;
}
Common code is placed in this namespace.
Definition: eagine.hpp:21
static constexpr auto extract(api_result_value< Result, api_result_validity::never > &) noexcept -> Result &
Overload of extract for api_result_value.
Definition: c_api_wrap.hpp:270
@ info
Informational log entries.
opt_c_api_constant< mp_list< string_query >, enum_type_i > shading_language_version
Definition: constants.hpp:6093
opt_c_api_constant< mp_list< integer_query >, enum_type_i > minor_version
Definition: constants.hpp:5111
opt_c_api_constant< mp_list< integer_query >, enum_type_i > major_version
Definition: constants.hpp:5100
opt_c_api_constant< mp_list< string_query >, enum_type_i > version
Definition: constants.hpp:6082
Value typically wrapping function call result and success indicator.
Definition: extract.hpp:128
static auto finally(Func func) -> func_on_scope_exit< Func >
Function constructing on-scope-exit actions.
Definition: scope_exit.hpp:144
@ message
Message protocol.
opt_c_api_constant< mp_list< string_query >, enum_type_i > renderer
Definition: constants.hpp:6071
Combined wrapper for the GL API operations and constants.
Definition: basic_gl_api.hpp:27
opt_c_api_constant< mp_list< string_query >, enum_type_i > vendor
Definition: constants.hpp:6060