internal/graphicsdriver/opengl/gl: bug fix: crash when log length is 0

This commit is contained in:
Hajime Hoshi 2024-08-25 11:45:54 +09:00
parent dd63eef65e
commit 3547d999b1
2 changed files with 12 additions and 0 deletions

View File

@ -592,6 +592,9 @@ func (c *defaultContext) GetInteger(pname uint32) int {
func (c *defaultContext) GetProgramInfoLog(program uint32) string {
bufSize := c.GetProgrami(program, INFO_LOG_LENGTH)
if bufSize == 0 {
return ""
}
infoLog := make([]byte, bufSize)
C.glowGetProgramInfoLog(c.gpGetProgramInfoLog, C.GLuint(program), C.GLsizei(bufSize), nil, (*C.GLchar)(unsafe.Pointer(&infoLog[0])))
return string(infoLog)
@ -605,6 +608,9 @@ func (c *defaultContext) GetProgrami(program uint32, pname uint32) int {
func (c *defaultContext) GetShaderInfoLog(shader uint32) string {
bufSize := c.GetShaderi(shader, INFO_LOG_LENGTH)
if bufSize == 0 {
return ""
}
infoLog := make([]byte, bufSize)
C.glowGetShaderInfoLog(c.gpGetShaderInfoLog, C.GLuint(shader), C.GLsizei(bufSize), nil, (*C.GLchar)(unsafe.Pointer(&infoLog[0])))
return string(infoLog)

View File

@ -300,6 +300,9 @@ func (c *defaultContext) GetInteger(pname uint32) int {
func (c *defaultContext) GetProgramInfoLog(program uint32) string {
bufSize := c.GetProgrami(program, INFO_LOG_LENGTH)
if bufSize == 0 {
return ""
}
infoLog := make([]byte, bufSize)
purego.SyscallN(c.gpGetProgramInfoLog, uintptr(program), uintptr(bufSize), 0, uintptr(unsafe.Pointer(&infoLog[0])))
return string(infoLog)
@ -313,6 +316,9 @@ func (c *defaultContext) GetProgrami(program uint32, pname uint32) int {
func (c *defaultContext) GetShaderInfoLog(shader uint32) string {
bufSize := c.GetShaderi(shader, INFO_LOG_LENGTH)
if bufSize == 0 {
return ""
}
infoLog := make([]byte, bufSize)
purego.SyscallN(c.gpGetShaderInfoLog, uintptr(shader), uintptr(bufSize), 0, uintptr(unsafe.Pointer(&infoLog[0])))
return string(infoLog)