From eeea25f20268b53a78a055e58f68efcbfd9f6af3 Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Sun, 3 Dec 2017 19:21:59 +0900 Subject: [PATCH] opengl: Remove 'normalize' argument from VertexAttribPointer --- internal/graphics/program.go | 37 +++++++++++++----------------- internal/opengl/context_desktop.go | 4 ++-- internal/opengl/context_js.go | 4 ++-- internal/opengl/context_mobile.go | 4 ++-- internal/opengl/types.go | 18 ++++++++------- 5 files changed, 32 insertions(+), 35 deletions(-) diff --git a/internal/graphics/program.go b/internal/graphics/program.go index 9a063703d..adf73c38b 100644 --- a/internal/graphics/program.go +++ b/internal/graphics/program.go @@ -24,10 +24,9 @@ import ( // arrayBufferLayoutPart is a part of an array buffer layout. type arrayBufferLayoutPart struct { // TODO: This struct should belong to a program and know it. - name string - dataType opengl.DataType - num int - normalize bool + name string + dataType opengl.DataType + num int } // arrayBufferLayout is an array buffer layout. @@ -65,7 +64,7 @@ func (a *arrayBufferLayout) enable(program opengl.Program) { total := a.totalBytes() offset := 0 for _, p := range a.parts { - opengl.GetContext().VertexAttribPointer(program, p.name, p.num, p.dataType, p.normalize, total, offset) + opengl.GetContext().VertexAttribPointer(program, p.name, p.num, p.dataType, total, offset) offset += p.dataType.SizeInBytes() * p.num } } @@ -84,28 +83,24 @@ var ( // Note that GL_MAX_VERTEX_ATTRIBS is at least 16. parts: []arrayBufferLayoutPart{ { - name: "vertex", - dataType: opengl.Float, - num: 2, - normalize: false, + name: "vertex", + dataType: opengl.Float, + num: 2, }, { - name: "tex_coord", - dataType: opengl.Float, - num: 4, - normalize: false, + name: "tex_coord", + dataType: opengl.Float, + num: 4, }, { - name: "geo_matrix_body", - dataType: opengl.Float, - num: 4, - normalize: false, + name: "geo_matrix_body", + dataType: opengl.Float, + num: 4, }, { - name: "geo_matrix_translation", - dataType: opengl.Float, - num: 2, - normalize: false, + name: "geo_matrix_translation", + dataType: opengl.Float, + num: 2, }, }, } diff --git a/internal/opengl/context_desktop.go b/internal/opengl/context_desktop.go index 47674a03b..87c6c7b23 100644 --- a/internal/opengl/context_desktop.go +++ b/internal/opengl/context_desktop.go @@ -427,10 +427,10 @@ func (c *Context) getAttribLocationImpl(p Program, location string) attribLocati return attrib } -func (c *Context) VertexAttribPointer(p Program, location string, size int, dataType DataType, normalize bool, stride int, offset int) { +func (c *Context) VertexAttribPointer(p Program, location string, size int, dataType DataType, stride int, offset int) { _ = c.runOnContextThread(func() error { l := c.locationCache.GetAttribLocation(c, p, location) - gl.VertexAttribPointer(uint32(l), int32(size), uint32(dataType), normalize, int32(stride), gl.PtrOffset(offset)) + gl.VertexAttribPointer(uint32(l), int32(size), uint32(dataType), false, int32(stride), gl.PtrOffset(offset)) return nil }) } diff --git a/internal/opengl/context_js.go b/internal/opengl/context_js.go index f42f6107b..0e393e255 100644 --- a/internal/opengl/context_js.go +++ b/internal/opengl/context_js.go @@ -362,10 +362,10 @@ func (c *Context) getAttribLocationImpl(p Program, location string) attribLocati return attribLocation(gl.GetAttribLocation(p.Object, location)) } -func (c *Context) VertexAttribPointer(p Program, location string, size int, dataType DataType, normalize bool, stride int, offset int) { +func (c *Context) VertexAttribPointer(p Program, location string, size int, dataType DataType, stride int, offset int) { gl := c.gl l := c.locationCache.GetAttribLocation(c, p, location) - gl.VertexAttribPointer(int(l), size, int(dataType), normalize, stride, offset) + gl.VertexAttribPointer(int(l), size, int(dataType), false, stride, offset) } func (c *Context) EnableVertexAttribArray(p Program, location string) { diff --git a/internal/opengl/context_mobile.go b/internal/opengl/context_mobile.go index 43c13a735..10d31a4c0 100644 --- a/internal/opengl/context_mobile.go +++ b/internal/opengl/context_mobile.go @@ -335,10 +335,10 @@ func (c *Context) getAttribLocationImpl(p Program, location string) attribLocati return a } -func (c *Context) VertexAttribPointer(p Program, location string, size int, dataType DataType, normalize bool, stride int, offset int) { +func (c *Context) VertexAttribPointer(p Program, location string, size int, dataType DataType, stride int, offset int) { gl := c.gl l := c.locationCache.GetAttribLocation(c, p, location) - gl.VertexAttribPointer(mgl.Attrib(l), size, mgl.Enum(dataType), normalize, stride, offset) + gl.VertexAttribPointer(mgl.Attrib(l), size, mgl.Enum(dataType), false, stride, offset) } func (c *Context) EnableVertexAttribArray(p Program, location string) { diff --git a/internal/opengl/types.go b/internal/opengl/types.go index 9557985e6..81be11d9f 100644 --- a/internal/opengl/types.go +++ b/internal/opengl/types.go @@ -14,12 +14,14 @@ package opengl -type Filter int -type ShaderType int -type BufferType int -type BufferUsage int -type Mode int -type operation int +type ( + Filter int + ShaderType int + BufferType int + BufferUsage int + Mode int + operation int +) type CompositeMode int @@ -69,7 +71,7 @@ func operations(mode CompositeMode) (src operation, dst operation) { case CompositeModeLighter: return one, one default: - panic("not reach") + panic("not reached") } } @@ -82,6 +84,6 @@ func (d DataType) SizeInBytes() int { case Float: return 4 default: - panic("not reach") + panic("not reached") } }