mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
graphicsdriver/opengl: Add program error info to the error
This commit is contained in:
parent
a4334c5464
commit
38dcadb233
@ -305,11 +305,12 @@ func (c *context) newShader(shaderType shaderType, source string) (shader, error
|
|||||||
var v int32
|
var v int32
|
||||||
gl.GetShaderiv(s, gl.COMPILE_STATUS, &v)
|
gl.GetShaderiv(s, gl.COMPILE_STATUS, &v)
|
||||||
if v == gl.FALSE {
|
if v == gl.FALSE {
|
||||||
log := []byte{}
|
var l int32
|
||||||
gl.GetShaderiv(uint32(s), gl.INFO_LOG_LENGTH, &v)
|
var log []byte
|
||||||
if v != 0 {
|
gl.GetShaderiv(uint32(s), gl.INFO_LOG_LENGTH, &l)
|
||||||
log = make([]byte, int(v))
|
if l != 0 {
|
||||||
gl.GetShaderInfoLog(uint32(s), v, nil, (*uint8)(gl.Ptr(log)))
|
log = make([]byte, l)
|
||||||
|
gl.GetShaderInfoLog(s, l, nil, (*uint8)(gl.Ptr(log)))
|
||||||
}
|
}
|
||||||
return fmt.Errorf("opengl: shader compile failed: %s", log)
|
return fmt.Errorf("opengl: shader compile failed: %s", log)
|
||||||
}
|
}
|
||||||
@ -350,7 +351,14 @@ func (c *context) newProgram(shaders []shader, attributes []string) (program, er
|
|||||||
var v int32
|
var v int32
|
||||||
gl.GetProgramiv(p, gl.LINK_STATUS, &v)
|
gl.GetProgramiv(p, gl.LINK_STATUS, &v)
|
||||||
if v == gl.FALSE {
|
if v == gl.FALSE {
|
||||||
return errors.New("opengl: program error")
|
var l int32
|
||||||
|
var log []byte
|
||||||
|
gl.GetProgramiv(p, gl.INFO_LOG_LENGTH, &l)
|
||||||
|
if l != 0 {
|
||||||
|
log = make([]byte, l)
|
||||||
|
gl.GetProgramInfoLog(p, l, nil, (*uint8)(gl.Ptr(log)))
|
||||||
|
}
|
||||||
|
return fmt.Errorf("opengl: program error: %s", log)
|
||||||
}
|
}
|
||||||
pr = program(p)
|
pr = program(p)
|
||||||
return nil
|
return nil
|
||||||
|
@ -395,7 +395,8 @@ func (c *context) newProgram(shaders []shader, attributes []string) (program, er
|
|||||||
|
|
||||||
gl.Call("linkProgram", v)
|
gl.Call("linkProgram", v)
|
||||||
if !gl.Call("getProgramParameter", v, linkStatus).Bool() {
|
if !gl.Call("getProgramParameter", v, linkStatus).Bool() {
|
||||||
return program{}, errors.New("opengl: program error")
|
info := gl.Call("getProgramInfoLog", v).String()
|
||||||
|
return program{}, fmt.Errorf("opengl: program error: %s", info)
|
||||||
}
|
}
|
||||||
|
|
||||||
id := c.lastProgramID
|
id := c.lastProgramID
|
||||||
|
@ -268,7 +268,8 @@ func (c *context) newProgram(shaders []shader, attributes []string) (program, er
|
|||||||
gl.LinkProgram(p)
|
gl.LinkProgram(p)
|
||||||
v := gl.GetProgrami(p, mgl.LINK_STATUS)
|
v := gl.GetProgrami(p, mgl.LINK_STATUS)
|
||||||
if v == mgl.FALSE {
|
if v == mgl.FALSE {
|
||||||
return program{}, errors.New("opengl: program error")
|
info := gl.GetProgramInfoLog(p)
|
||||||
|
return program{}, fmt.Errorf("opengl: program error: %s", info)
|
||||||
}
|
}
|
||||||
return program(p), nil
|
return program(p), nil
|
||||||
}
|
}
|
||||||
|
@ -132,6 +132,7 @@ package gl
|
|||||||
// typedef void (APIENTRYP GPGETINTEGERUI64I_VNV)(GLenum value, GLuint index, GLuint64EXT * result);
|
// typedef void (APIENTRYP GPGETINTEGERUI64I_VNV)(GLenum value, GLuint index, GLuint64EXT * result);
|
||||||
// typedef void (APIENTRYP GPGETINTEGERV)(GLenum pname, GLint * data);
|
// typedef void (APIENTRYP GPGETINTEGERV)(GLenum pname, GLint * data);
|
||||||
// typedef void (APIENTRYP GPGETPOINTERI_VEXT)(GLenum pname, GLuint index, void ** params);
|
// typedef void (APIENTRYP GPGETPOINTERI_VEXT)(GLenum pname, GLuint index, void ** params);
|
||||||
|
// typedef void (APIENTRYP GPGETPROGRAMINFOLOG)(GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
|
||||||
// typedef void (APIENTRYP GPGETPROGRAMIV)(GLuint program, GLenum pname, GLint * params);
|
// typedef void (APIENTRYP GPGETPROGRAMIV)(GLuint program, GLenum pname, GLint * params);
|
||||||
// typedef void (APIENTRYP GPGETSHADERINFOLOG)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
|
// typedef void (APIENTRYP GPGETSHADERINFOLOG)(GLuint shader, GLsizei bufSize, GLsizei * length, GLchar * infoLog);
|
||||||
// typedef void (APIENTRYP GPGETSHADERIV)(GLuint shader, GLenum pname, GLint * params);
|
// typedef void (APIENTRYP GPGETSHADERIV)(GLuint shader, GLenum pname, GLint * params);
|
||||||
@ -272,6 +273,9 @@ package gl
|
|||||||
// static void glowGetPointeri_vEXT(GPGETPOINTERI_VEXT fnptr, GLenum pname, GLuint index, void ** params) {
|
// static void glowGetPointeri_vEXT(GPGETPOINTERI_VEXT fnptr, GLenum pname, GLuint index, void ** params) {
|
||||||
// (*fnptr)(pname, index, params);
|
// (*fnptr)(pname, index, params);
|
||||||
// }
|
// }
|
||||||
|
// static void glowGetProgramInfoLog(GPGETPROGRAMINFOLOG fnptr, GLuint program, GLsizei bufSize, GLsizei * length, GLchar * infoLog) {
|
||||||
|
// (*fnptr)(program, bufSize, length, infoLog);
|
||||||
|
// }
|
||||||
// static void glowGetProgramiv(GPGETPROGRAMIV fnptr, GLuint program, GLenum pname, GLint * params) {
|
// static void glowGetProgramiv(GPGETPROGRAMIV fnptr, GLuint program, GLenum pname, GLint * params) {
|
||||||
// (*fnptr)(program, pname, params);
|
// (*fnptr)(program, pname, params);
|
||||||
// }
|
// }
|
||||||
@ -409,6 +413,7 @@ var (
|
|||||||
gpGetIntegerui64i_vNV C.GPGETINTEGERUI64I_VNV
|
gpGetIntegerui64i_vNV C.GPGETINTEGERUI64I_VNV
|
||||||
gpGetIntegerv C.GPGETINTEGERV
|
gpGetIntegerv C.GPGETINTEGERV
|
||||||
gpGetPointeri_vEXT C.GPGETPOINTERI_VEXT
|
gpGetPointeri_vEXT C.GPGETPOINTERI_VEXT
|
||||||
|
gpGetProgramInfoLog C.GPGETPROGRAMINFOLOG
|
||||||
gpGetProgramiv C.GPGETPROGRAMIV
|
gpGetProgramiv C.GPGETPROGRAMIV
|
||||||
gpGetShaderInfoLog C.GPGETSHADERINFOLOG
|
gpGetShaderInfoLog C.GPGETSHADERINFOLOG
|
||||||
gpGetShaderiv C.GPGETSHADERIV
|
gpGetShaderiv C.GPGETSHADERIV
|
||||||
@ -592,6 +597,10 @@ func GetPointeri_vEXT(pname uint32, index uint32, params *unsafe.Pointer) {
|
|||||||
C.glowGetPointeri_vEXT(gpGetPointeri_vEXT, (C.GLenum)(pname), (C.GLuint)(index), params)
|
C.glowGetPointeri_vEXT(gpGetPointeri_vEXT, (C.GLenum)(pname), (C.GLuint)(index), params)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetProgramInfoLog(program uint32, bufSize int32, length *int32, infoLog *uint8) {
|
||||||
|
C.glowGetProgramInfoLog(gpGetProgramInfoLog, (C.GLuint)(program), (C.GLsizei)(bufSize), (*C.GLsizei)(unsafe.Pointer(length)), (*C.GLchar)(unsafe.Pointer(infoLog)))
|
||||||
|
}
|
||||||
|
|
||||||
func GetProgramiv(program uint32, pname uint32, params *int32) {
|
func GetProgramiv(program uint32, pname uint32, params *int32) {
|
||||||
C.glowGetProgramiv(gpGetProgramiv, (C.GLuint)(program), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(params)))
|
C.glowGetProgramiv(gpGetProgramiv, (C.GLuint)(program), (C.GLenum)(pname), (*C.GLint)(unsafe.Pointer(params)))
|
||||||
}
|
}
|
||||||
@ -828,6 +837,10 @@ func InitWithProcAddrFunc(getProcAddr func(name string) unsafe.Pointer) error {
|
|||||||
return errors.New("glGetIntegerv")
|
return errors.New("glGetIntegerv")
|
||||||
}
|
}
|
||||||
gpGetPointeri_vEXT = (C.GPGETPOINTERI_VEXT)(getProcAddr("glGetPointeri_vEXT"))
|
gpGetPointeri_vEXT = (C.GPGETPOINTERI_VEXT)(getProcAddr("glGetPointeri_vEXT"))
|
||||||
|
gpGetProgramInfoLog = (C.GPGETPROGRAMINFOLOG)(getProcAddr("glGetProgramInfoLog"))
|
||||||
|
if gpGetProgramInfoLog == nil {
|
||||||
|
return errors.New("glGetProgramInfoLog")
|
||||||
|
}
|
||||||
gpGetProgramiv = (C.GPGETPROGRAMIV)(getProcAddr("glGetProgramiv"))
|
gpGetProgramiv = (C.GPGETPROGRAMIV)(getProcAddr("glGetProgramiv"))
|
||||||
if gpGetProgramiv == nil {
|
if gpGetProgramiv == nil {
|
||||||
return errors.New("glGetProgramiv")
|
return errors.New("glGetProgramiv")
|
||||||
|
@ -46,6 +46,7 @@ var (
|
|||||||
gpGetIntegerui64i_vNV uintptr
|
gpGetIntegerui64i_vNV uintptr
|
||||||
gpGetIntegerv uintptr
|
gpGetIntegerv uintptr
|
||||||
gpGetPointeri_vEXT uintptr
|
gpGetPointeri_vEXT uintptr
|
||||||
|
gpGetProgramInfoLog uintptr
|
||||||
gpGetProgramiv uintptr
|
gpGetProgramiv uintptr
|
||||||
gpGetShaderInfoLog uintptr
|
gpGetShaderInfoLog uintptr
|
||||||
gpGetShaderiv uintptr
|
gpGetShaderiv uintptr
|
||||||
@ -229,6 +230,10 @@ func GetPointeri_vEXT(pname uint32, index uint32, params *unsafe.Pointer) {
|
|||||||
syscall.Syscall(gpGetPointeri_vEXT, 3, uintptr(pname), uintptr(index), uintptr(unsafe.Pointer(params)))
|
syscall.Syscall(gpGetPointeri_vEXT, 3, uintptr(pname), uintptr(index), uintptr(unsafe.Pointer(params)))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GetProgramInfoLog(program uint32, bufSize int32, length *int32, infoLog *uint8) {
|
||||||
|
syscall.Syscall6(gpGetProgramInfoLog, 4, uintptr(program), uintptr(bufSize), uintptr(unsafe.Pointer(length)), uintptr(unsafe.Pointer(infoLog)), 0, 0)
|
||||||
|
}
|
||||||
|
|
||||||
func GetProgramiv(program uint32, pname uint32, params *int32) {
|
func GetProgramiv(program uint32, pname uint32, params *int32) {
|
||||||
syscall.Syscall(gpGetProgramiv, 3, uintptr(program), uintptr(pname), uintptr(unsafe.Pointer(params)))
|
syscall.Syscall(gpGetProgramiv, 3, uintptr(program), uintptr(pname), uintptr(unsafe.Pointer(params)))
|
||||||
}
|
}
|
||||||
@ -465,6 +470,10 @@ func InitWithProcAddrFunc(getProcAddr func(name string) uintptr) error {
|
|||||||
return errors.New("glGetIntegerv")
|
return errors.New("glGetIntegerv")
|
||||||
}
|
}
|
||||||
gpGetPointeri_vEXT = getProcAddr("glGetPointeri_vEXT")
|
gpGetPointeri_vEXT = getProcAddr("glGetPointeri_vEXT")
|
||||||
|
gpGetProgramInfoLog = getProcAddr("glGetProgramInfoLog")
|
||||||
|
if gpGetProgramInfoLog == 0 {
|
||||||
|
return errors.New("glGetProgramInfoLog")
|
||||||
|
}
|
||||||
gpGetProgramiv = getProcAddr("glGetProgramiv")
|
gpGetProgramiv = getProcAddr("glGetProgramiv")
|
||||||
if gpGetProgramiv == 0 {
|
if gpGetProgramiv == 0 {
|
||||||
return errors.New("glGetProgramiv")
|
return errors.New("glGetProgramiv")
|
||||||
|
Loading…
Reference in New Issue
Block a user