mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-25 03:08:54 +01:00
internal/graphicsdriver/opengl/gl: refactoring: replace some *iv functions with *i
This commit is contained in:
parent
098fed65d5
commit
49fc1cfdc0
@ -288,9 +288,7 @@ func (c *context) newShader(shaderType uint32, source string) (shader, error) {
|
|||||||
c.ctx.ShaderSource(s, source)
|
c.ctx.ShaderSource(s, source)
|
||||||
c.ctx.CompileShader(s)
|
c.ctx.CompileShader(s)
|
||||||
|
|
||||||
v := make([]int32, 1)
|
if c.ctx.GetShaderi(s, gl.COMPILE_STATUS) == gl.FALSE {
|
||||||
c.ctx.GetShaderiv(v, s, gl.COMPILE_STATUS)
|
|
||||||
if v[0] == gl.FALSE {
|
|
||||||
log := c.ctx.GetShaderInfoLog(s)
|
log := c.ctx.GetShaderInfoLog(s)
|
||||||
return 0, fmt.Errorf("opengl: shader compile failed: %s", log)
|
return 0, fmt.Errorf("opengl: shader compile failed: %s", log)
|
||||||
}
|
}
|
||||||
@ -316,9 +314,7 @@ func (c *context) newProgram(shaders []shader, attributes []string) (program, er
|
|||||||
}
|
}
|
||||||
|
|
||||||
c.ctx.LinkProgram(p)
|
c.ctx.LinkProgram(p)
|
||||||
v := make([]int32, 1)
|
if c.ctx.GetProgrami(p, gl.LINK_STATUS) == gl.FALSE {
|
||||||
c.ctx.GetProgramiv(v, p, gl.LINK_STATUS)
|
|
||||||
if v[0] == gl.FALSE {
|
|
||||||
info := c.ctx.GetProgramInfoLog(p)
|
info := c.ctx.GetProgramInfoLog(p)
|
||||||
return 0, fmt.Errorf("opengl: program error: %s", info)
|
return 0, fmt.Errorf("opengl: program error: %s", info)
|
||||||
}
|
}
|
||||||
|
@ -585,33 +585,35 @@ func (c *defaultContext) GetError() uint32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetInteger(pname uint32) int {
|
func (c *defaultContext) GetInteger(pname uint32) int {
|
||||||
dst := make([]int32, 1)
|
var dst int32
|
||||||
C.glowGetIntegerv(c.gpGetIntegerv, (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(&dst[0])))
|
C.glowGetIntegerv(c.gpGetIntegerv, (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(&dst)))
|
||||||
return int(dst[0])
|
return int(dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetProgramInfoLog(program uint32) string {
|
func (c *defaultContext) GetProgramInfoLog(program uint32) string {
|
||||||
var bufSize [1]int32
|
bufSize := c.GetProgrami(program, INFO_LOG_LENGTH)
|
||||||
c.GetProgramiv(bufSize[:], program, INFO_LOG_LENGTH)
|
infoLog := make([]byte, bufSize)
|
||||||
infoLog := make([]byte, bufSize[0])
|
C.glowGetProgramInfoLog(c.gpGetProgramInfoLog, (C.GLuint)(program), (C.GLsizei)(bufSize), nil, (*C.GLchar)(unsafe.Pointer(&infoLog[0])))
|
||||||
C.glowGetProgramInfoLog(c.gpGetProgramInfoLog, (C.GLuint)(program), (C.GLsizei)(bufSize[0]), nil, (*C.GLchar)(unsafe.Pointer(&infoLog[0])))
|
|
||||||
return string(infoLog)
|
return string(infoLog)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetProgramiv(dst []int32, program uint32, pname uint32) {
|
func (c *defaultContext) GetProgrami(program uint32, pname uint32) int {
|
||||||
C.glowGetProgramiv(c.gpGetProgramiv, (C.GLuint)(program), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(&dst[0])))
|
var dst int32
|
||||||
|
C.glowGetProgramiv(c.gpGetProgramiv, (C.GLuint)(program), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(&dst)))
|
||||||
|
return int(dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetShaderInfoLog(shader uint32) string {
|
func (c *defaultContext) GetShaderInfoLog(shader uint32) string {
|
||||||
var bufSize [1]int32
|
bufSize := c.GetShaderi(shader, INFO_LOG_LENGTH)
|
||||||
c.GetShaderiv(bufSize[:], shader, INFO_LOG_LENGTH)
|
infoLog := make([]byte, bufSize)
|
||||||
infoLog := make([]byte, bufSize[0])
|
C.glowGetShaderInfoLog(c.gpGetShaderInfoLog, (C.GLuint)(shader), (C.GLsizei)(bufSize), nil, (*C.GLchar)(unsafe.Pointer(&infoLog[0])))
|
||||||
C.glowGetShaderInfoLog(c.gpGetShaderInfoLog, (C.GLuint)(shader), (C.GLsizei)(bufSize[0]), nil, (*C.GLchar)(unsafe.Pointer(&infoLog[0])))
|
|
||||||
return string(infoLog)
|
return string(infoLog)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetShaderiv(dst []int32, shader uint32, pname uint32) {
|
func (c *defaultContext) GetShaderi(shader uint32, pname uint32) int {
|
||||||
C.glowGetShaderiv(c.gpGetShaderiv, (C.GLuint)(shader), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(&dst[0])))
|
var dst int32
|
||||||
|
C.glowGetShaderiv(c.gpGetShaderiv, (C.GLuint)(shader), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(&dst)))
|
||||||
|
return int(dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetUniformLocation(program uint32, name string) int32 {
|
func (c *defaultContext) GetUniformLocation(program uint32, name string) int32 {
|
||||||
|
@ -284,33 +284,35 @@ func (c *defaultContext) GetError() uint32 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetInteger(pname uint32) int {
|
func (c *defaultContext) GetInteger(pname uint32) int {
|
||||||
dst := make([]int32, 1)
|
var dst int32
|
||||||
purego.SyscallN(c.gpGetIntegerv, uintptr(pname), uintptr(unsafe.Pointer(&dst[0])))
|
purego.SyscallN(c.gpGetIntegerv, uintptr(pname), uintptr(unsafe.Pointer(&dst)))
|
||||||
return int(dst[0])
|
return int(dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetProgramInfoLog(program uint32) string {
|
func (c *defaultContext) GetProgramInfoLog(program uint32) string {
|
||||||
var bufSize [1]int32
|
bufSize := c.GetProgrami(program, INFO_LOG_LENGTH)
|
||||||
c.GetProgramiv(bufSize[:], program, INFO_LOG_LENGTH)
|
infoLog := make([]byte, bufSize)
|
||||||
infoLog := make([]byte, bufSize[0])
|
purego.SyscallN(c.gpGetProgramInfoLog, uintptr(program), uintptr(bufSize), 0, uintptr(unsafe.Pointer(&infoLog[0])))
|
||||||
purego.SyscallN(c.gpGetProgramInfoLog, uintptr(program), uintptr(bufSize[0]), 0, uintptr(unsafe.Pointer(&infoLog[0])))
|
|
||||||
return string(infoLog)
|
return string(infoLog)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetProgramiv(dst []int32, program uint32, pname uint32) {
|
func (c *defaultContext) GetProgrami(program uint32, pname uint32) int {
|
||||||
purego.SyscallN(c.gpGetProgramiv, uintptr(program), uintptr(pname), uintptr(unsafe.Pointer(&dst[0])))
|
var dst int32
|
||||||
|
purego.SyscallN(c.gpGetProgramiv, uintptr(program), uintptr(pname), uintptr(unsafe.Pointer(&dst)))
|
||||||
|
return int(dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetShaderInfoLog(shader uint32) string {
|
func (c *defaultContext) GetShaderInfoLog(shader uint32) string {
|
||||||
var bufSize [1]int32
|
bufSize := c.GetShaderi(shader, INFO_LOG_LENGTH)
|
||||||
c.GetShaderiv(bufSize[:], shader, INFO_LOG_LENGTH)
|
infoLog := make([]byte, bufSize)
|
||||||
infoLog := make([]byte, bufSize[0])
|
purego.SyscallN(c.gpGetShaderInfoLog, uintptr(shader), uintptr(bufSize), 0, uintptr(unsafe.Pointer(&infoLog[0])))
|
||||||
purego.SyscallN(c.gpGetShaderInfoLog, uintptr(shader), uintptr(bufSize[0]), 0, uintptr(unsafe.Pointer(&infoLog[0])))
|
|
||||||
return string(infoLog)
|
return string(infoLog)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetShaderiv(dst []int32, shader uint32, pname uint32) {
|
func (c *defaultContext) GetShaderi(shader uint32, pname uint32) int {
|
||||||
purego.SyscallN(c.gpGetShaderiv, uintptr(shader), uintptr(pname), uintptr(unsafe.Pointer(&dst[0])))
|
var dst int32
|
||||||
|
purego.SyscallN(c.gpGetShaderiv, uintptr(shader), uintptr(pname), uintptr(unsafe.Pointer(&dst)))
|
||||||
|
return int(dst)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *defaultContext) GetUniformLocation(program uint32, name string) int32 {
|
func (c *defaultContext) GetUniformLocation(program uint32, name string) int32 {
|
||||||
|
@ -226,16 +226,16 @@ func (g *gomobileContext) GetProgramInfoLog(program uint32) string {
|
|||||||
return g.ctx.GetProgramInfoLog(gmProgram(program))
|
return g.ctx.GetProgramInfoLog(gmProgram(program))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gomobileContext) GetProgramiv(dst []int32, program uint32, pname uint32) {
|
func (g *gomobileContext) GetProgrami(program uint32, pname uint32) int {
|
||||||
dst[0] = int32(g.ctx.GetProgrami(gmProgram(program), gl.Enum(pname)))
|
return g.ctx.GetProgrami(gmProgram(program), gl.Enum(pname))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gomobileContext) GetShaderInfoLog(shader uint32) string {
|
func (g *gomobileContext) GetShaderInfoLog(shader uint32) string {
|
||||||
return g.ctx.GetShaderInfoLog(gl.Shader{Value: shader})
|
return g.ctx.GetShaderInfoLog(gl.Shader{Value: shader})
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gomobileContext) GetShaderiv(dst []int32, shader uint32, pname uint32) {
|
func (g *gomobileContext) GetShaderi(shader uint32, pname uint32) int {
|
||||||
dst[0] = int32(g.ctx.GetShaderi(gl.Shader{Value: shader}, gl.Enum(pname)))
|
return g.ctx.GetShaderi(gl.Shader{Value: shader}, gl.Enum(pname))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g *gomobileContext) GetUniformLocation(program uint32, name string) int32 {
|
func (g *gomobileContext) GetUniformLocation(program uint32, name string) int32 {
|
||||||
|
@ -60,9 +60,9 @@ type Context interface {
|
|||||||
GetError() uint32
|
GetError() uint32
|
||||||
GetInteger(pname uint32) int
|
GetInteger(pname uint32) int
|
||||||
GetProgramInfoLog(program uint32) string
|
GetProgramInfoLog(program uint32) string
|
||||||
GetProgramiv(dst []int32, program uint32, pname uint32)
|
GetProgrami(program uint32, pname uint32) int
|
||||||
GetShaderInfoLog(shader uint32) string
|
GetShaderInfoLog(shader uint32) string
|
||||||
GetShaderiv(dst []int32, shader uint32, pname uint32)
|
GetShaderi(shader uint32, pname uint32) int
|
||||||
GetUniformLocation(program uint32, name string) int32
|
GetUniformLocation(program uint32, name string) int32
|
||||||
IsFramebuffer(framebuffer uint32) bool
|
IsFramebuffer(framebuffer uint32) bool
|
||||||
IsProgram(program uint32) bool
|
IsProgram(program uint32) bool
|
||||||
|
Loading…
Reference in New Issue
Block a user