graphicsdriver/opengl/gl: Fix go-vet errors on Windows

Updates #889
This commit is contained in:
Hajime Hoshi 2019-10-06 23:19:56 +09:00
parent 3a0f8655e6
commit 4088de5349
2 changed files with 67 additions and 67 deletions

View File

@ -331,198 +331,198 @@ func Viewport(x int32, y int32, width int32, height int32) {
// InitWithProcAddrFunc intializes the package using the specified OpenGL // InitWithProcAddrFunc intializes the package using the specified OpenGL
// function pointer loading function. For more cases Init should be used // function pointer loading function. For more cases Init should be used
func InitWithProcAddrFunc(getProcAddr func(name string) unsafe.Pointer) error { func InitWithProcAddrFunc(getProcAddr func(name string) uintptr) error {
gpAttachShader = uintptr(getProcAddr("glAttachShader")) gpAttachShader = getProcAddr("glAttachShader")
if gpAttachShader == 0 { if gpAttachShader == 0 {
return errors.New("glAttachShader") return errors.New("glAttachShader")
} }
gpBindAttribLocation = uintptr(getProcAddr("glBindAttribLocation")) gpBindAttribLocation = getProcAddr("glBindAttribLocation")
if gpBindAttribLocation == 0 { if gpBindAttribLocation == 0 {
return errors.New("glBindAttribLocation") return errors.New("glBindAttribLocation")
} }
gpBindBuffer = uintptr(getProcAddr("glBindBuffer")) gpBindBuffer = getProcAddr("glBindBuffer")
if gpBindBuffer == 0 { if gpBindBuffer == 0 {
return errors.New("glBindBuffer") return errors.New("glBindBuffer")
} }
gpBindFramebufferEXT = uintptr(getProcAddr("glBindFramebufferEXT")) gpBindFramebufferEXT = getProcAddr("glBindFramebufferEXT")
gpBindTexture = uintptr(getProcAddr("glBindTexture")) gpBindTexture = getProcAddr("glBindTexture")
if gpBindTexture == 0 { if gpBindTexture == 0 {
return errors.New("glBindTexture") return errors.New("glBindTexture")
} }
gpBlendFunc = uintptr(getProcAddr("glBlendFunc")) gpBlendFunc = getProcAddr("glBlendFunc")
if gpBlendFunc == 0 { if gpBlendFunc == 0 {
return errors.New("glBlendFunc") return errors.New("glBlendFunc")
} }
gpBufferData = uintptr(getProcAddr("glBufferData")) gpBufferData = getProcAddr("glBufferData")
if gpBufferData == 0 { if gpBufferData == 0 {
return errors.New("glBufferData") return errors.New("glBufferData")
} }
gpBufferSubData = uintptr(getProcAddr("glBufferSubData")) gpBufferSubData = getProcAddr("glBufferSubData")
if gpBufferSubData == 0 { if gpBufferSubData == 0 {
return errors.New("glBufferSubData") return errors.New("glBufferSubData")
} }
gpCheckFramebufferStatusEXT = uintptr(getProcAddr("glCheckFramebufferStatusEXT")) gpCheckFramebufferStatusEXT = getProcAddr("glCheckFramebufferStatusEXT")
gpCompileShader = uintptr(getProcAddr("glCompileShader")) gpCompileShader = getProcAddr("glCompileShader")
if gpCompileShader == 0 { if gpCompileShader == 0 {
return errors.New("glCompileShader") return errors.New("glCompileShader")
} }
gpCreateProgram = uintptr(getProcAddr("glCreateProgram")) gpCreateProgram = getProcAddr("glCreateProgram")
if gpCreateProgram == 0 { if gpCreateProgram == 0 {
return errors.New("glCreateProgram") return errors.New("glCreateProgram")
} }
gpCreateShader = uintptr(getProcAddr("glCreateShader")) gpCreateShader = getProcAddr("glCreateShader")
if gpCreateShader == 0 { if gpCreateShader == 0 {
return errors.New("glCreateShader") return errors.New("glCreateShader")
} }
gpDeleteBuffers = uintptr(getProcAddr("glDeleteBuffers")) gpDeleteBuffers = getProcAddr("glDeleteBuffers")
if gpDeleteBuffers == 0 { if gpDeleteBuffers == 0 {
return errors.New("glDeleteBuffers") return errors.New("glDeleteBuffers")
} }
gpDeleteFramebuffersEXT = uintptr(getProcAddr("glDeleteFramebuffersEXT")) gpDeleteFramebuffersEXT = getProcAddr("glDeleteFramebuffersEXT")
gpDeleteProgram = uintptr(getProcAddr("glDeleteProgram")) gpDeleteProgram = getProcAddr("glDeleteProgram")
if gpDeleteProgram == 0 { if gpDeleteProgram == 0 {
return errors.New("glDeleteProgram") return errors.New("glDeleteProgram")
} }
gpDeleteShader = uintptr(getProcAddr("glDeleteShader")) gpDeleteShader = getProcAddr("glDeleteShader")
if gpDeleteShader == 0 { if gpDeleteShader == 0 {
return errors.New("glDeleteShader") return errors.New("glDeleteShader")
} }
gpDeleteTextures = uintptr(getProcAddr("glDeleteTextures")) gpDeleteTextures = getProcAddr("glDeleteTextures")
if gpDeleteTextures == 0 { if gpDeleteTextures == 0 {
return errors.New("glDeleteTextures") return errors.New("glDeleteTextures")
} }
gpDisableVertexAttribArray = uintptr(getProcAddr("glDisableVertexAttribArray")) gpDisableVertexAttribArray = getProcAddr("glDisableVertexAttribArray")
if gpDisableVertexAttribArray == 0 { if gpDisableVertexAttribArray == 0 {
return errors.New("glDisableVertexAttribArray") return errors.New("glDisableVertexAttribArray")
} }
gpDrawElements = uintptr(getProcAddr("glDrawElements")) gpDrawElements = getProcAddr("glDrawElements")
if gpDrawElements == 0 { if gpDrawElements == 0 {
return errors.New("glDrawElements") return errors.New("glDrawElements")
} }
gpEnable = uintptr(getProcAddr("glEnable")) gpEnable = getProcAddr("glEnable")
if gpEnable == 0 { if gpEnable == 0 {
return errors.New("glEnable") return errors.New("glEnable")
} }
gpEnableVertexAttribArray = uintptr(getProcAddr("glEnableVertexAttribArray")) gpEnableVertexAttribArray = getProcAddr("glEnableVertexAttribArray")
if gpEnableVertexAttribArray == 0 { if gpEnableVertexAttribArray == 0 {
return errors.New("glEnableVertexAttribArray") return errors.New("glEnableVertexAttribArray")
} }
gpFlush = uintptr(getProcAddr("glFlush")) gpFlush = getProcAddr("glFlush")
if gpFlush == 0 { if gpFlush == 0 {
return errors.New("glFlush") return errors.New("glFlush")
} }
gpFramebufferTexture2DEXT = uintptr(getProcAddr("glFramebufferTexture2DEXT")) gpFramebufferTexture2DEXT = getProcAddr("glFramebufferTexture2DEXT")
gpGenBuffers = uintptr(getProcAddr("glGenBuffers")) gpGenBuffers = getProcAddr("glGenBuffers")
if gpGenBuffers == 0 { if gpGenBuffers == 0 {
return errors.New("glGenBuffers") return errors.New("glGenBuffers")
} }
gpGenFramebuffersEXT = uintptr(getProcAddr("glGenFramebuffersEXT")) gpGenFramebuffersEXT = getProcAddr("glGenFramebuffersEXT")
gpGenTextures = uintptr(getProcAddr("glGenTextures")) gpGenTextures = getProcAddr("glGenTextures")
if gpGenTextures == 0 { if gpGenTextures == 0 {
return errors.New("glGenTextures") return errors.New("glGenTextures")
} }
gpGetDoublei_v = uintptr(getProcAddr("glGetDoublei_v")) gpGetDoublei_v = getProcAddr("glGetDoublei_v")
gpGetDoublei_vEXT = uintptr(getProcAddr("glGetDoublei_vEXT")) gpGetDoublei_vEXT = getProcAddr("glGetDoublei_vEXT")
gpGetError = uintptr(getProcAddr("glGetError")) gpGetError = getProcAddr("glGetError")
if gpGetError == 0 { if gpGetError == 0 {
return errors.New("glGetError") return errors.New("glGetError")
} }
gpGetFloati_v = uintptr(getProcAddr("glGetFloati_v")) gpGetFloati_v = getProcAddr("glGetFloati_v")
gpGetFloati_vEXT = uintptr(getProcAddr("glGetFloati_vEXT")) gpGetFloati_vEXT = getProcAddr("glGetFloati_vEXT")
gpGetIntegeri_v = uintptr(getProcAddr("glGetIntegeri_v")) gpGetIntegeri_v = getProcAddr("glGetIntegeri_v")
gpGetIntegerui64i_vNV = uintptr(getProcAddr("glGetIntegerui64i_vNV")) gpGetIntegerui64i_vNV = getProcAddr("glGetIntegerui64i_vNV")
gpGetIntegerv = uintptr(getProcAddr("glGetIntegerv")) gpGetIntegerv = getProcAddr("glGetIntegerv")
if gpGetIntegerv == 0 { if gpGetIntegerv == 0 {
return errors.New("glGetIntegerv") return errors.New("glGetIntegerv")
} }
gpGetPointeri_vEXT = uintptr(getProcAddr("glGetPointeri_vEXT")) gpGetPointeri_vEXT = getProcAddr("glGetPointeri_vEXT")
gpGetProgramiv = uintptr(getProcAddr("glGetProgramiv")) gpGetProgramiv = getProcAddr("glGetProgramiv")
if gpGetProgramiv == 0 { if gpGetProgramiv == 0 {
return errors.New("glGetProgramiv") return errors.New("glGetProgramiv")
} }
gpGetShaderInfoLog = uintptr(getProcAddr("glGetShaderInfoLog")) gpGetShaderInfoLog = getProcAddr("glGetShaderInfoLog")
if gpGetShaderInfoLog == 0 { if gpGetShaderInfoLog == 0 {
return errors.New("glGetShaderInfoLog") return errors.New("glGetShaderInfoLog")
} }
gpGetShaderiv = uintptr(getProcAddr("glGetShaderiv")) gpGetShaderiv = getProcAddr("glGetShaderiv")
if gpGetShaderiv == 0 { if gpGetShaderiv == 0 {
return errors.New("glGetShaderiv") return errors.New("glGetShaderiv")
} }
gpGetTransformFeedbacki64_v = uintptr(getProcAddr("glGetTransformFeedbacki64_v")) gpGetTransformFeedbacki64_v = getProcAddr("glGetTransformFeedbacki64_v")
gpGetTransformFeedbacki_v = uintptr(getProcAddr("glGetTransformFeedbacki_v")) gpGetTransformFeedbacki_v = getProcAddr("glGetTransformFeedbacki_v")
gpGetUniformLocation = uintptr(getProcAddr("glGetUniformLocation")) gpGetUniformLocation = getProcAddr("glGetUniformLocation")
if gpGetUniformLocation == 0 { if gpGetUniformLocation == 0 {
return errors.New("glGetUniformLocation") return errors.New("glGetUniformLocation")
} }
gpGetUnsignedBytei_vEXT = uintptr(getProcAddr("glGetUnsignedBytei_vEXT")) gpGetUnsignedBytei_vEXT = getProcAddr("glGetUnsignedBytei_vEXT")
gpGetVertexArrayIntegeri_vEXT = uintptr(getProcAddr("glGetVertexArrayIntegeri_vEXT")) gpGetVertexArrayIntegeri_vEXT = getProcAddr("glGetVertexArrayIntegeri_vEXT")
gpGetVertexArrayPointeri_vEXT = uintptr(getProcAddr("glGetVertexArrayPointeri_vEXT")) gpGetVertexArrayPointeri_vEXT = getProcAddr("glGetVertexArrayPointeri_vEXT")
gpIsFramebufferEXT = uintptr(getProcAddr("glIsFramebufferEXT")) gpIsFramebufferEXT = getProcAddr("glIsFramebufferEXT")
gpIsProgram = uintptr(getProcAddr("glIsProgram")) gpIsProgram = getProcAddr("glIsProgram")
if gpIsProgram == 0 { if gpIsProgram == 0 {
return errors.New("glIsProgram") return errors.New("glIsProgram")
} }
gpIsTexture = uintptr(getProcAddr("glIsTexture")) gpIsTexture = getProcAddr("glIsTexture")
if gpIsTexture == 0 { if gpIsTexture == 0 {
return errors.New("glIsTexture") return errors.New("glIsTexture")
} }
gpLinkProgram = uintptr(getProcAddr("glLinkProgram")) gpLinkProgram = getProcAddr("glLinkProgram")
if gpLinkProgram == 0 { if gpLinkProgram == 0 {
return errors.New("glLinkProgram") return errors.New("glLinkProgram")
} }
gpPixelStorei = uintptr(getProcAddr("glPixelStorei")) gpPixelStorei = getProcAddr("glPixelStorei")
if gpPixelStorei == 0 { if gpPixelStorei == 0 {
return errors.New("glPixelStorei") return errors.New("glPixelStorei")
} }
gpReadPixels = uintptr(getProcAddr("glReadPixels")) gpReadPixels = getProcAddr("glReadPixels")
if gpReadPixels == 0 { if gpReadPixels == 0 {
return errors.New("glReadPixels") return errors.New("glReadPixels")
} }
gpShaderSource = uintptr(getProcAddr("glShaderSource")) gpShaderSource = getProcAddr("glShaderSource")
if gpShaderSource == 0 { if gpShaderSource == 0 {
return errors.New("glShaderSource") return errors.New("glShaderSource")
} }
gpTexImage2D = uintptr(getProcAddr("glTexImage2D")) gpTexImage2D = getProcAddr("glTexImage2D")
if gpTexImage2D == 0 { if gpTexImage2D == 0 {
return errors.New("glTexImage2D") return errors.New("glTexImage2D")
} }
gpTexParameteri = uintptr(getProcAddr("glTexParameteri")) gpTexParameteri = getProcAddr("glTexParameteri")
if gpTexParameteri == 0 { if gpTexParameteri == 0 {
return errors.New("glTexParameteri") return errors.New("glTexParameteri")
} }
gpTexSubImage2D = uintptr(getProcAddr("glTexSubImage2D")) gpTexSubImage2D = getProcAddr("glTexSubImage2D")
if gpTexSubImage2D == 0 { if gpTexSubImage2D == 0 {
return errors.New("glTexSubImage2D") return errors.New("glTexSubImage2D")
} }
gpUniform1f = uintptr(getProcAddr("glUniform1f")) gpUniform1f = getProcAddr("glUniform1f")
if gpUniform1f == 0 { if gpUniform1f == 0 {
return errors.New("glUniform1f") return errors.New("glUniform1f")
} }
gpUniform1i = uintptr(getProcAddr("glUniform1i")) gpUniform1i = getProcAddr("glUniform1i")
if gpUniform1i == 0 { if gpUniform1i == 0 {
return errors.New("glUniform1i") return errors.New("glUniform1i")
} }
gpUniform2fv = uintptr(getProcAddr("glUniform2fv")) gpUniform2fv = getProcAddr("glUniform2fv")
if gpUniform2fv == 0 { if gpUniform2fv == 0 {
return errors.New("glUniform2fv") return errors.New("glUniform2fv")
} }
gpUniform4fv = uintptr(getProcAddr("glUniform4fv")) gpUniform4fv = getProcAddr("glUniform4fv")
if gpUniform4fv == 0 { if gpUniform4fv == 0 {
return errors.New("glUniform4fv") return errors.New("glUniform4fv")
} }
gpUniformMatrix4fv = uintptr(getProcAddr("glUniformMatrix4fv")) gpUniformMatrix4fv = getProcAddr("glUniformMatrix4fv")
if gpUniformMatrix4fv == 0 { if gpUniformMatrix4fv == 0 {
return errors.New("glUniformMatrix4fv") return errors.New("glUniformMatrix4fv")
} }
gpUseProgram = uintptr(getProcAddr("glUseProgram")) gpUseProgram = getProcAddr("glUseProgram")
if gpUseProgram == 0 { if gpUseProgram == 0 {
return errors.New("glUseProgram") return errors.New("glUseProgram")
} }
gpVertexAttribPointer = uintptr(getProcAddr("glVertexAttribPointer")) gpVertexAttribPointer = getProcAddr("glVertexAttribPointer")
if gpVertexAttribPointer == 0 { if gpVertexAttribPointer == 0 {
return errors.New("glVertexAttribPointer") return errors.New("glVertexAttribPointer")
} }
gpViewport = uintptr(getProcAddr("glViewport")) gpViewport = getProcAddr("glViewport")
if gpViewport == 0 { if gpViewport == 0 {
return errors.New("glViewport") return errors.New("glViewport")
} }

View File

@ -13,18 +13,18 @@ var (
wglGetProcAddress = opengl32.NewProc("wglGetProcAddress") wglGetProcAddress = opengl32.NewProc("wglGetProcAddress")
) )
func getProcAddress(namea string) unsafe.Pointer { func getProcAddress(namea string) uintptr {
cname, err := windows.BytePtrFromString(namea) cname, err := windows.BytePtrFromString(namea)
if err != nil { if err != nil {
panic(err) panic(err)
} }
if r, _, _ := wglGetProcAddress.Call(uintptr(unsafe.Pointer(cname))); r != 0 { if r, _, _ := wglGetProcAddress.Call(uintptr(unsafe.Pointer(cname))); r != 0 {
return unsafe.Pointer(r) return r
} }
p := opengl32.NewProc(namea) p := opengl32.NewProc(namea)
if err := p.Find(); err != nil { if err := p.Find(); err != nil {
// The proc is not found. // The proc is not found.
return nil return 0
} }
return unsafe.Pointer(p.Addr()) return p.Addr()
} }