Replaced glLoadGen loader with glad loader and dynamically load EGL and GLES extensions as is done for desktop GL.
This commit is contained in:
parent
f2b8e6397b
commit
2eb70c6537
44 changed files with 35003 additions and 3965 deletions
|
@ -4,7 +4,10 @@
|
|||
////////////////////////////////////////////////////////////
|
||||
#include <SFML/Window.hpp>
|
||||
#include <SFML/System/Err.hpp>
|
||||
#include <SFML/OpenGL.hpp>
|
||||
|
||||
#define GLAD_GL_IMPLEMENTATION
|
||||
#include "gl.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
#include <iostream>
|
||||
#include <cmath>
|
||||
|
@ -23,7 +26,13 @@ void initialize(sf::Window& window)
|
|||
|
||||
// Setup OpenGL states
|
||||
// Set color and depth clear value
|
||||
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glClearDepthf(1.f);
|
||||
#else
|
||||
glClearDepth(1.f);
|
||||
#endif
|
||||
|
||||
glClearColor(0.f, 0.5f, 0.5f, 0.f);
|
||||
|
||||
// Enable Z-buffer read and write
|
||||
|
@ -33,9 +42,14 @@ void initialize(sf::Window& window)
|
|||
// Setup a perspective projection
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
static const double pi = 3.141592654;
|
||||
GLdouble extent = std::tan(90.0 * pi / 360.0);
|
||||
glFrustum(-extent, extent, -extent, extent, 1.0, 500.0);
|
||||
static const float pi = 3.141592654f;
|
||||
float extent = std::tan(90.0f * pi / 360.0f);
|
||||
|
||||
#ifdef SFML_OPENGL_ES
|
||||
glFrustumf(-extent, extent, -extent, extent, 1.0f, 500.0f);
|
||||
#else
|
||||
glFrustum(-extent, extent, -extent, extent, 1.0f, 500.0f);
|
||||
#endif
|
||||
|
||||
// Enable position and texture coordinates vertex components
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
@ -177,6 +191,15 @@ int main()
|
|||
// Create a clock for measuring elapsed time
|
||||
sf::Clock clock;
|
||||
|
||||
// Load OpenGL or OpenGL ES entry points using glad
|
||||
sfmlView1.setActive();
|
||||
|
||||
#ifdef SFML_OPENGL_ES
|
||||
gladLoadGLES1(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||
#else
|
||||
gladLoadGL(reinterpret_cast<GLADloadfunc>(sf::Context::getFunction));
|
||||
#endif
|
||||
|
||||
// Initialize our views
|
||||
initialize(sfmlView1);
|
||||
initialize(sfmlView2);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue