Certain glfwWindowHints cause screen to go black?

Started by Andrew_3ds, February 26, 2015, 01:19:38

Previous topic - Next topic

Andrew_3ds

I am trying to use modern OpenGL(3.3), but trying to use glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3) and glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3) cause the screen to go black instead of rendering the quad. Setting the version to 3.1 and less make it work, I don't know why 3.3 doesn't work. Also GLFW_OPENGL_FORWARD_COMPAT and GLFW_OPENGL_CORE_PROFILE cause it to go black.

SHC

What is your operating system? And you GPU? What driver version are you having? Did you try to print out OpenGL errors if any in your loop?

quew8

Quite likely, you are doing something like trying to render using Vertex Arrays under core or forward compatible OpenGL 3. There are a few features which are not supported in core OpenGL 3 but which don't have their own functions. So calling the function is fine but it will cause an unusual OpenGL error (since it isn't listed in the docs).

So what rendering techniques are you using?

Andrew_3ds

My OS is Windows 7 x64, GPU is NVidia gts 250, driver is version 341.44.

I am using Vertex Array Objects and vbos to draw.
Here's the code I use to create and draw the vaos.
public class VAO {
    public static List<Integer> vaos = new ArrayList<Integer>();
    public static List<Integer> vbos = new ArrayList<Integer>();

    public int vaoID;
    public int vAmount;

    public VAO(float[] vertices) {
        this.vaoID = createVAO();
        vAmount = vertices.length/3;
        storeDataInVAO(0, 3, vertices);
//        storeDataInVAO(1, 2, texCoords);
        unbindVAO();
    }

    private int createVAO() {
        int vao = glGenVertexArrays();
        vaos.add(vao);
        glBindVertexArray(vao);
        return vao;
    }

    private void unbindVAO() {
        glBindVertexArray(0);
    }

    private void storeDataInVAO(int slot, int size, float[] data) {
        int vbo = glGenBuffers();
        vbos.add(vbo);
        glBindBuffer(GL_ARRAY_BUFFER, vbo);
        FloatBuffer bufferedData = asFloatBuffer(data);
        glBufferData(GL_ARRAY_BUFFER, bufferedData, GL_STATIC_DRAW);
        glVertexAttribPointer(slot, size, GL_FLOAT, false, 0, 0);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
    }

    public static void cleanUp() {
        for(int i : vaos) {
            glDeleteVertexArrays(i);
            System.out.println(String.format("Deleted VAO #%1s", i));
        }
        for(int i : vbos) {
            glDeleteBuffers(i);
        }
    }

    public int getVaoID() {
        return this.vaoID;
    }

   //Render code
   glBindVertexArray(vao.getVaoID());
        glEnableVertexAttribArray(0);
        glDrawArrays(GL_TRIANGLES, 0, vao.vAmount);
        glDisableVertexAttribArray(0);
        glBindVertexArray(0);
}