go-gl-legacy/glfw

Hinting OpenGL version number generates GL errors

SaxonDouglass opened this issue · 4 comments

The following program will not terminate because glGetError keeps returning gl.INVALID_ENUM

But when the window hint for OpenGL version is removed, glGetError returns gl.NO_ERROR and the program will correctly terminate.

I am running this code on a Toshiba Sattelite L650 laptop with Crunchbang 11 "Waldorf" and proprietary AMD graphics driver version 9.012.

I apologise if this is my error in how I am using your packages.

package main

import (
    "fmt"

    "github.com/go-gl/gl"
    "github.com/go-gl/glfw"
)

func main() {
    if err := glfw.Init(); err != nil {
        fmt.Println(err)
    }
    defer glfw.Terminate()

    glfw.OpenWindowHint(glfw.OpenGLVersionMajor, 3) // comment out
    glfw.OpenWindowHint(glfw.OpenGLVersionMinor, 2) // these 2 lines
    if err := glfw.OpenWindow(800, 600, 0, 0, 0, 0,
            16, 0, glfw.Windowed); err != nil {
        fmt.Println(err)
    }
    defer glfw.CloseWindow()

    if err := gl.Init(); err != gl.NO_ERROR {
        fmt.Println("gl.Init() failed")
    }

    for err := gl.GetError(); err != gl.NO_ERROR; {
        fmt.Println(err) // 1280 = gl.INVALID_ENUM
    }

    fmt.Println("All good")
}

for err := gl.GetError(); err != gl.NO_ERROR; err = gl.GetError() { ... }

Your version of the for loop will set err only once and keep using the same value forever.

@tajtiattila is correct. Have a look at the specification for the for statement. Closing this as not a glfw issue.

Ah! Thank you for correcting my newbie mistake so nicely.

I guess the INVALID_ENUM error comes from glew and I just need to swallow it.

Cheers

A little more details about the origin of this error: go-gl/glfw#50 .