Aeon Engine c550894
AeonGames Open Source Game Engine
Loading...
Searching...
No Matches
OpenGLFunctions.cpp
1/*
2Copyright (C) 2016-2019,2025,2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#include "OpenGLFunctions.hpp"
18#include <cstring>
19#include <iostream>
20#include <string>
21#include <sstream>
22#include <stdexcept>
23
24#ifdef WIN32
25#include <GL/wglext.h>
26#define GLGETPROCADDRESS(glFunctionType,glFunction) \
27 if(glFunction==nullptr) { \
28 glFunction = (glFunctionType)wglGetProcAddress(#glFunction); \
29 if (glFunction == nullptr) \
30 { \
31 std::ostringstream stream; \
32 stream << "OpenGL: Unable to load " #glFunction " function."; \
33 throw std::runtime_error(stream.str().c_str()); \
34 } \
35 }
36#elif defined(ANDROID)
37#define GLGETPROCADDRESS(glFunctionType,glFunction) \
38 if(glFunction==nullptr) { \
39 glFunction = ( glFunctionType ) eglGetProcAddress ( (const char*) #glFunction "OES" ); \
40 if (glFunction == nullptr) \
41 { \
42 std::ostringstream stream; \
43 stream << "OpenGL: Unable to load " #glFunction " function."; \
44 throw std::runtime_error(stream.str().c_str()); \
45 } \
46 }
47#else
48#include <GL/gl.h>
49#include <GL/glx.h>
50#define GLGETPROCADDRESS(glFunctionType,glFunction) \
51 if(glFunction==nullptr) { \
52 glFunction = ( glFunctionType ) glXGetProcAddress ( (const GLubyte*) #glFunction ); \
53 if (glFunction == nullptr) \
54 { \
55 std::ostringstream stream; \
56 stream << "OpenGL: Unable to load " #glFunction " function."; \
57 throw std::runtime_error(stream.str().c_str()); \
58 } \
59 }
60#endif
61
62namespace AeonGames
63{
64#include "glDefinitions.h"
67 {
68#include "glAssignments.h"
69 // Provide some information regarding OpenGL Drivers.
70 std::cout << LogLevel::Info << "OpenGL Version " << glGetString ( GL_VERSION ) << std::endl;
71 std::cout << LogLevel::Info << "GLSL Version " << glGetString ( GL_SHADING_LANGUAGE_VERSION ) << std::endl;
72 std::cout << LogLevel::Info << "OpenGL Vendor " << glGetString ( GL_VENDOR ) << std::endl;
73 GLint texSize = 0;
74 glGetIntegerv ( GL_MAX_TEXTURE_SIZE, &texSize );
75 std::cout << LogLevel::Info << "Maximum Texture Size: " << texSize << std::endl;
76 GLint glInteger;
77#ifdef ANDROID
78 glGetIntegerv ( GL_MAX_VERTEX_UNIFORM_VECTORS, &glInteger );
79 std::cout << LogLevel::Info << "GLSLES Max Vertex Uniform Vectors " << glInteger << std::endl;
80 glGetIntegerv ( GL_MAX_FRAGMENT_UNIFORM_VECTORS, &glInteger );
81 std::cout << LogLevel::Info << "GLSLES Max Fragment Uniform Vectors " << glInteger << std::endl;
82 std::cout << glGetString ( GL_EXTENSIONS );
83#else
84 glGetIntegerv ( GL_MAX_VERTEX_UNIFORM_COMPONENTS, &glInteger );
85 std::cout << LogLevel::Info << "GLSL Max Vertex Uniform Components " << glInteger << std::endl;
86 glGetIntegerv ( GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, &glInteger );
87 std::cout << LogLevel::Info << "GLSL Max Fragment Uniform Components " << glInteger << std::endl;
88 glGetIntegerv ( GL_MAX_VERTEX_ATTRIBS, &glInteger );
89 std::cout << LogLevel::Info << "GLSL Max Vertex Attributes " << glInteger << std::endl;
90 glGetIntegerv ( GL_MAX_UNIFORM_BLOCK_SIZE, &glInteger );
91 std::cout << LogLevel::Info << "GLSL Max Uniform Block Size " << glInteger << std::endl;
92 GLint extension_count;
93 glGetIntegerv ( GL_NUM_EXTENSIONS, &extension_count );
94 for ( GLint i = 0; i < extension_count; ++i )
95 {
96 std::cout << LogLevel::Info << glGetStringi ( GL_EXTENSIONS, i ) << std::endl;
97 }
98#endif
99 return true;
100 }
101}
Defines log severity levels and stream output for the AeonGames engine.
<- This is here just for the literals
Definition AABB.hpp:31
bool LoadOpenGLAPI()
Load all OpenGL function pointers and log driver information.
@ Info
General informational messages.
Definition LogLevel.hpp:30