Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

GoLang OpenGL VBO issues?

82 views
Skip to first unread message

efeld...@gmail.com

unread,
May 14, 2013, 11:59:34 PM5/14/13
to
I know I'm cross posting here - I was not sure whether this goes under GoLang or OpenGL but once I posted under golang, I realized maybe it was the wrong place...

So lately I've been messing around with opengl libraries for Go. And one of the libraries I have gotten to display textures and primitives such as triangles. I used the fixed pipeline (glbegin,end) to draw. I recently switched to a more go-ified library and decided to do some VBO drawing but seem to be having issues. I guess this this is an opengl / go question for anyone who has some experience in these two fields. My current code looks like the following and displays a white window with ortho2d set. However; this window has nothing on it which is surprising, given I have populated and bound my VBO as below:

These are snippets from my code please let me know if it's not enough detail:

var (
array = [...]int32{
1, 20, 0, 40, 30, 0, 10, 6,
0}
slice = array[:]
)

func newBuffer(bytes int) Buffer {

buf := GenBuffer()

buf.Bind(ARRAY_BUFFER)

BufferData(ARRAY_BUFFER, bytes, slice, STATIC_READ)

return buf

}


func Test_GraphicsVBO(t *testing.T) {


w := Window.NewWindowedWindow("test", 800, 600) // inits glfw


w.Open() // glfw method to open window


w.Clear() // simple glclear


buf := newBuffer(9 * 4)

defer buf.Delete()


BufferData(ARRAY_BUFFER, 9*4, &array, STATIC_READ)

if GetError() != NO_ERROR {

t.Error("pointer to array failed")

}


BufferData(ARRAY_BUFFER, 9*4, slice, STATIC_READ)

if GetError() != NO_ERROR {

t.Error("slice failed")

}


EnableClientState(VERTEX_ARRAY)

VertexPointer(3, INT, 0, slice)


indices := []uint32{0, 1, 2}

DrawElements(TRIANGLE_STRIP, 3, UNSIGNED_INT, indices)

if GetError() != NO_ERROR {

t.Error("slice failed")

}


DisableClientState(VERTEX_ARRAY)

w.Refresh() // all this does is glfw swap buffer

time.Sleep(3 * 10e8)

}


My window setup looks like this:

The only transforms I'm using is when I open a window. I'm pretty sure this works as I was able to draw using the fixed pipeline:

using the following golang library:
gl "github.com/go-gl/gl"


So my window code is as follows...

func (w window) init() error {
if err := gl.Init(); err != 0 {
return errors.New("Cannot initialize OGL: ")
}
gl.MatrixMode(gl.PROJECTION)
gl.Disable(gl.DEPTH_TEST)
gl.Ortho(0, w.width, w.height, 0, -1, 1)
return nil
}

func (w window) Clear() {

gl.ClearColor(1.0, 1.0, 1.0, 1.0)

gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)

}


func (w window) Refresh() {

glfw.SwapBuffers()

}

Now am I missing something fundamental here in terms of opengl?? I have not used VBO's in quite some time but thought I would catch up on them as that is the way of opengl 3/4...
0 new messages