Hello Guest

Certain glfwWindowHints cause screen to go black?

  • 3 Replies
  • 2016 Views
Certain glfwWindowHints cause screen to go black?
« on: February 26, 2015, 01:19:38 »
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.

*

Offline SHC

  • **
  • 94
    • GoHarsha.com
Re: Certain glfwWindowHints cause screen to go black?
« Reply #1 on: February 26, 2015, 03:48:35 »
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?

*

Offline quew8

  • *****
  • 569
  • Because Square Eyes Look More Real
Re: Certain glfwWindowHints cause screen to go black?
« Reply #2 on: February 26, 2015, 13:00:04 »
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?

Re: Certain glfwWindowHints cause screen to go black?
« Reply #3 on: February 27, 2015, 02:55:02 »
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.
Code: [Select]
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);
}