combolek wrote on Friday, June 21, 2013:
Hi,
I am using GLFW from master 3be3f58a92 compiled for EGL/GLES2 (with GLFW_USE_EGL=ON and GLFW_CLIENT_LIBRARY=glesv2) on Linux/X11 (Fedora 18).
I have a short test program that tries to open a window. It works correctly when compiled for full OpenGL (FULL_GL defined, link with regular GL/GLX build of GLFW) but it fails in glfwCreateWindow() when compiled for EGL/GLES2 with the following X error:
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 72 (X_PutImage)
Serial number of failed request: 90
Current serial number in output stream: 94
Interestingly, I get the same error on AMD and Nvidia hardware, but the test works fine on Intel Ivy-Bridge!
The test program is pasted below. Does anyone know what I am missing here?
Many thanks,
Bolek
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#if defined(FULL_GL)
#include <GL/gl.h>
#else
#include <GLES2/gl2.h>
#endif
#define GLFW_INCLUDE_NONE 1
#include <GLFW/glfw3.h>
struct UserData
{
bool paused;
};
static void Key(GLFWwindow* window, int key, int scancode, int action, int mods)
{
if (action != GLFW_PRESS) {
return;
}
UserData *user_data = (UserData *)glfwGetWindowUserPointer(window);
switch (key) {
case GLFW_KEY_ESCAPE:
glfwSetWindowShouldClose(window, GL_TRUE);
return;
case GLFW_KEY_SPACE:
user_data->paused = !user_data->paused;
break;
default:
break;
}
}
static void Reshape(GLFWwindow* window, int width, int height)
{
printf("Reshape width = %d height = %d\n", width, height);
glViewport(0, 0, (GLint)width, (GLint)height);
}
static void Draw(GLFWwindow *window)
{
glClearColor(0.0, (sin(glfwGetTime() * 4.0) + 1.0) / 2.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glfwSwapBuffers(window);
}
static void Error(int err, const char *msg)
{
printf("GLFW Error 0x%x: %s\n", err, msg);
exit(EXIT_FAILURE);
}
int main(int argc, char **argv)
{
UserData user_data = {0};
glfwSetErrorCallback(Error);
glfwInit();
#if !defined(FULL_GL)
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2);
#endif
GLFWwindow *window = glfwCreateWindow(512, 512, argv[0], NULL, NULL);
glfwSetWindowUserPointer(window, &user_data);
glfwSetWindowSizeCallback(window, Reshape);
glfwSetKeyCallback(window, Key);
glfwSetWindowPos(window, 200, 100);
glfwMakeContextCurrent(window);
// fake initial resize callback
int width, height;
glfwGetWindowSize(window, &width, &height);
Reshape(window, width, height);
while (!glfwWindowShouldClose(window)) {
if (user_data.paused) {
glfwWaitEvents();
} else {
glfwPollEvents();
Draw(window);
}
}
glfwDestroyWindow(window);
glfwTerminate();
return 0;
}