I’m having some trouble getting started with GLFW and Angle.
Angle builds and the samples run. I have copied libGLESv2.so and libEGL.so to my project directory as well as the includes as advised from the Angle dev documentation.
If I build the following code with:
gcc main.c /usr/local/lib/libglfw3.a -o main -I./include -ldl -lpthread -lm -lGLESv2 -lEGL
It works as expected and glGetString functions for vendor, etc. all show correct output for the Nvidia ES3.2 implementation.
I’m trying to build for Angle with the following:
gcc main.c /usr/local/lib/libglfw3.a -o main -I./include -L./ -Wl,-rpath=./ -ldl -lpthread -lm -l:libEGL.so -l:libGLESv2.so
ldd shows that the two commands link the system and local versions of libGLESv2.so respectively, but the Angle build shows a black window and glGetString returns null. (libEGL.so does not appear to link in either case)
GLFW was pulled from the git repo a couple of days ago and I built Angle around the same time.
If someone could get me pointed in the correct direction I would really appreciate it.
#include <stdio.h>
#include <stdlib.h>
#define GLFW_INCLUDE_NONE
#include "angle_gl.h"
#include <GLFW/glfw3.h>
static void error_callback(int error, const char* description)
{
fprintf(stderr, "Error: %s\n", description);
}
static void key_callback(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (key == GLFW_KEY_ESCAPE && action == GLFW_PRESS)
glfwSetWindowShouldClose(window, GLFW_TRUE);
}
int main()
{
GLFWwindow* window;
glfwSetErrorCallback(error_callback);
glfwInitHint(GLFW_ANGLE_PLATFORM_TYPE, GLFW_ANGLE_PLATFORM_TYPE_OPENGL);
if (!glfwInit())
{
exit(EXIT_FAILURE);
}
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
glfwWindowHint(GLFW_CONTEXT_CREATION_API, GLFW_EGL_CONTEXT_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0);
glfwWindowHint(GLFW_SAMPLES, 4);
glfwWindowHint(GLFW_RESIZABLE, GLFW_FALSE);
window = glfwCreateWindow(640, 480, "Test GLES", NULL, NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwSetKeyCallback(window, key_callback);
glfwMakeContextCurrent(window);
glfwSwapInterval(1);
const GLubyte* renderer = glGetString(GL_RENDERER);
const GLubyte* version = glGetString(GL_VERSION);
const GLubyte* vendor = glGetString(GL_VENDOR);
printf("Renderer: %s\n", renderer);
printf("OpenGL version supported %s\n", version);
printf("OpenGL vendor: %s\n", vendor);
while (!glfwWindowShouldClose(window))
{
float ratio;
int width, height;
glfwGetFramebufferSize(window, &width, &height);
ratio = width / (float) height;
glViewport(0, 0, width, height);
glClearColor(0.6f, 0.8f, 0.4f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glfwSwapBuffers(window);
glfwPollEvents();
}
glfwDestroyWindow(window);
glfwTerminate();
exit(EXIT_SUCCESS);
}