gioui.org/ui@v0.0.0-20190926171558-ce74bc0cbaea/app/internal/gl/gl_windows.go (about)

     1  // SPDX-License-Identifier: Unlicense OR MIT
     2  
     3  package gl
     4  
     5  import (
     6  	"math"
     7  	"runtime"
     8  	"syscall"
     9  	"unsafe"
    10  
    11  	"golang.org/x/sys/windows"
    12  )
    13  
    14  var (
    15  	LibGLESv2                             = windows.NewLazyDLL("libGLESv2.dll")
    16  	_glActiveTexture                      = LibGLESv2.NewProc("glActiveTexture")
    17  	_glAttachShader                       = LibGLESv2.NewProc("glAttachShader")
    18  	_glBeginQuery                         = LibGLESv2.NewProc("glBeginQuery")
    19  	_glBindAttribLocation                 = LibGLESv2.NewProc("glBindAttribLocation")
    20  	_glBindBuffer                         = LibGLESv2.NewProc("glBindBuffer")
    21  	_glBindFramebuffer                    = LibGLESv2.NewProc("glBindFramebuffer")
    22  	_glBindRenderbuffer                   = LibGLESv2.NewProc("glBindRenderbuffer")
    23  	_glBindTexture                        = LibGLESv2.NewProc("glBindTexture")
    24  	_glBlendEquation                      = LibGLESv2.NewProc("glBlendEquation")
    25  	_glBlendFunc                          = LibGLESv2.NewProc("glBlendFunc")
    26  	_glBufferData                         = LibGLESv2.NewProc("glBufferData")
    27  	_glCheckFramebufferStatus             = LibGLESv2.NewProc("glCheckFramebufferStatus")
    28  	_glClear                              = LibGLESv2.NewProc("glClear")
    29  	_glClearColor                         = LibGLESv2.NewProc("glClearColor")
    30  	_glClearDepthf                        = LibGLESv2.NewProc("glClearDepthf")
    31  	_glDeleteQueries                      = LibGLESv2.NewProc("glDeleteQueries")
    32  	_glCompileShader                      = LibGLESv2.NewProc("glCompileShader")
    33  	_glGenBuffers                         = LibGLESv2.NewProc("glGenBuffers")
    34  	_glGenFramebuffers                    = LibGLESv2.NewProc("glGenFramebuffers")
    35  	_glCreateProgram                      = LibGLESv2.NewProc("glCreateProgram")
    36  	_glGenRenderbuffers                   = LibGLESv2.NewProc("glGenRenderbuffers")
    37  	_glCreateShader                       = LibGLESv2.NewProc("glCreateShader")
    38  	_glGenTextures                        = LibGLESv2.NewProc("glGenTextures")
    39  	_glDeleteBuffers                      = LibGLESv2.NewProc("glDeleteBuffers")
    40  	_glDeleteFramebuffers                 = LibGLESv2.NewProc("glDeleteFramebuffers")
    41  	_glDeleteProgram                      = LibGLESv2.NewProc("glDeleteProgram")
    42  	_glDeleteShader                       = LibGLESv2.NewProc("glDeleteShader")
    43  	_glDeleteRenderbuffers                = LibGLESv2.NewProc("glDeleteRenderbuffers")
    44  	_glDeleteTextures                     = LibGLESv2.NewProc("glDeleteTextures")
    45  	_glDepthFunc                          = LibGLESv2.NewProc("glDepthFunc")
    46  	_glDepthMask                          = LibGLESv2.NewProc("glDepthMask")
    47  	_glDisableVertexAttribArray           = LibGLESv2.NewProc("glDisableVertexAttribArray")
    48  	_glDisable                            = LibGLESv2.NewProc("glDisable")
    49  	_glDrawArrays                         = LibGLESv2.NewProc("glDrawArrays")
    50  	_glDrawElements                       = LibGLESv2.NewProc("glDrawElements")
    51  	_glEnable                             = LibGLESv2.NewProc("glEnable")
    52  	_glEnableVertexAttribArray            = LibGLESv2.NewProc("glEnableVertexAttribArray")
    53  	_glEndQuery                           = LibGLESv2.NewProc("glEndQuery")
    54  	_glFinish                             = LibGLESv2.NewProc("glFinish")
    55  	_glFramebufferRenderbuffer            = LibGLESv2.NewProc("glFramebufferRenderbuffer")
    56  	_glFramebufferTexture2D               = LibGLESv2.NewProc("glFramebufferTexture2D")
    57  	_glGenQueries                         = LibGLESv2.NewProc("glGenQueries")
    58  	_glGetError                           = LibGLESv2.NewProc("glGetError")
    59  	_glGetRenderbufferParameteri          = LibGLESv2.NewProc("glGetRenderbufferParameteri")
    60  	_glGetFramebufferAttachmentParameteri = LibGLESv2.NewProc("glGetFramebufferAttachmentParameteri")
    61  	_glGetIntegerv                        = LibGLESv2.NewProc("glGetIntegerv")
    62  	_glGetProgramiv                       = LibGLESv2.NewProc("glGetProgramiv")
    63  	_glGetProgramInfoLog                  = LibGLESv2.NewProc("glGetProgramInfoLog")
    64  	_glGetQueryObjectuiv                  = LibGLESv2.NewProc("glGetQueryObjectuiv")
    65  	_glGetShaderiv                        = LibGLESv2.NewProc("glGetShaderiv")
    66  	_glGetShaderInfoLog                   = LibGLESv2.NewProc("glGetShaderInfoLog")
    67  	_glGetString                          = LibGLESv2.NewProc("glGetString")
    68  	_glGetUniformLocation                 = LibGLESv2.NewProc("glGetUniformLocation")
    69  	_glInvalidateFramebuffer              = LibGLESv2.NewProc("glInvalidateFramebuffer")
    70  	_glLinkProgram                        = LibGLESv2.NewProc("glLinkProgram")
    71  	_glPixelStorei                        = LibGLESv2.NewProc("glPixelStorei")
    72  	_glReadPixels                         = LibGLESv2.NewProc("glReadPixels")
    73  	_glRenderbufferStorage                = LibGLESv2.NewProc("glRenderbufferStorage")
    74  	_glScissor                            = LibGLESv2.NewProc("glScissor")
    75  	_glShaderSource                       = LibGLESv2.NewProc("glShaderSource")
    76  	_glTexImage2D                         = LibGLESv2.NewProc("glTexImage2D")
    77  	_glTexSubImage2D                      = LibGLESv2.NewProc("glTexSubImage2D")
    78  	_glTexParameteri                      = LibGLESv2.NewProc("glTexParameteri")
    79  	_glUniform1f                          = LibGLESv2.NewProc("glUniform1f")
    80  	_glUniform1i                          = LibGLESv2.NewProc("glUniform1i")
    81  	_glUniform2f                          = LibGLESv2.NewProc("glUniform2f")
    82  	_glUniform3f                          = LibGLESv2.NewProc("glUniform3f")
    83  	_glUniform4f                          = LibGLESv2.NewProc("glUniform4f")
    84  	_glUseProgram                         = LibGLESv2.NewProc("glUseProgram")
    85  	_glVertexAttribPointer                = LibGLESv2.NewProc("glVertexAttribPointer")
    86  	_glViewport                           = LibGLESv2.NewProc("glViewport")
    87  )
    88  
    89  type Functions struct {
    90  	// Query caches.
    91  	int32s [100]int32
    92  }
    93  
    94  func (c *Functions) ActiveTexture(t Enum) {
    95  	syscall.Syscall(_glActiveTexture.Addr(), 1, uintptr(t), 0, 0)
    96  }
    97  func (c *Functions) AttachShader(p Program, s Shader) {
    98  	syscall.Syscall(_glAttachShader.Addr(), 2, uintptr(p.V), uintptr(s.V), 0)
    99  }
   100  func (f *Functions) BeginQuery(target Enum, query Query) {
   101  	syscall.Syscall(_glBeginQuery.Addr(), 2, uintptr(target), uintptr(query.V), 0)
   102  }
   103  func (c *Functions) BindAttribLocation(p Program, a Attrib, name string) {
   104  	cname := cString(name)
   105  	c0 := &cname[0]
   106  	syscall.Syscall(_glBindAttribLocation.Addr(), 3, uintptr(p.V), uintptr(a), uintptr(unsafe.Pointer(c0)))
   107  	issue34474KeepAlive(c)
   108  }
   109  func (c *Functions) BindBuffer(target Enum, b Buffer) {
   110  	syscall.Syscall(_glBindBuffer.Addr(), 2, uintptr(target), uintptr(b.V), 0)
   111  }
   112  func (c *Functions) BindFramebuffer(target Enum, fb Framebuffer) {
   113  	syscall.Syscall(_glBindFramebuffer.Addr(), 2, uintptr(target), uintptr(fb.V), 0)
   114  }
   115  func (c *Functions) BindRenderbuffer(target Enum, rb Renderbuffer) {
   116  	syscall.Syscall(_glBindRenderbuffer.Addr(), 2, uintptr(target), uintptr(rb.V), 0)
   117  }
   118  func (c *Functions) BindTexture(target Enum, t Texture) {
   119  	syscall.Syscall(_glBindTexture.Addr(), 2, uintptr(target), uintptr(t.V), 0)
   120  }
   121  func (c *Functions) BlendEquation(mode Enum) {
   122  	syscall.Syscall(_glBlendEquation.Addr(), 1, uintptr(mode), 0, 0)
   123  }
   124  func (c *Functions) BlendFunc(sfactor, dfactor Enum) {
   125  	syscall.Syscall(_glBlendFunc.Addr(), 2, uintptr(sfactor), uintptr(dfactor), 0)
   126  }
   127  func (c *Functions) BufferData(target Enum, src []byte, usage Enum) {
   128  	if n := len(src); n == 0 {
   129  		syscall.Syscall6(_glBufferData.Addr(), 4, uintptr(target), 0, 0, uintptr(usage), 0, 0)
   130  	} else {
   131  		s0 := &src[0]
   132  		syscall.Syscall6(_glBufferData.Addr(), 4, uintptr(target), uintptr(n), uintptr(unsafe.Pointer(s0)), uintptr(usage), 0, 0)
   133  		issue34474KeepAlive(s0)
   134  	}
   135  }
   136  func (c *Functions) CheckFramebufferStatus(target Enum) Enum {
   137  	s, _, _ := syscall.Syscall(_glCheckFramebufferStatus.Addr(), 1, uintptr(target), 0, 0)
   138  	return Enum(s)
   139  }
   140  func (c *Functions) Clear(mask Enum) {
   141  	syscall.Syscall(_glClear.Addr(), 1, uintptr(mask), 0, 0)
   142  }
   143  func (c *Functions) ClearColor(red, green, blue, alpha float32) {
   144  	syscall.Syscall6(_glClearColor.Addr(), 4, uintptr(math.Float32bits(red)), uintptr(math.Float32bits(green)), uintptr(math.Float32bits(blue)), uintptr(math.Float32bits(alpha)), 0, 0)
   145  }
   146  func (c *Functions) ClearDepthf(d float32) {
   147  	syscall.Syscall(_glClearDepthf.Addr(), 1, uintptr(math.Float32bits(d)), 0, 0)
   148  }
   149  func (c *Functions) CompileShader(s Shader) {
   150  	syscall.Syscall(_glCompileShader.Addr(), 1, uintptr(s.V), 0, 0)
   151  }
   152  func (c *Functions) CreateBuffer() Buffer {
   153  	var buf uintptr
   154  	syscall.Syscall(_glGenBuffers.Addr(), 2, 1, uintptr(unsafe.Pointer(&buf)), 0)
   155  	return Buffer{uint(buf)}
   156  }
   157  func (c *Functions) CreateFramebuffer() Framebuffer {
   158  	var fb uintptr
   159  	syscall.Syscall(_glGenFramebuffers.Addr(), 2, 1, uintptr(unsafe.Pointer(&fb)), 0)
   160  	return Framebuffer{uint(fb)}
   161  }
   162  func (c *Functions) CreateProgram() Program {
   163  	p, _, _ := syscall.Syscall(_glCreateProgram.Addr(), 0, 0, 0, 0)
   164  	return Program{uint(p)}
   165  }
   166  func (f *Functions) CreateQuery() Query {
   167  	var q uintptr
   168  	syscall.Syscall(_glGenQueries.Addr(), 2, 1, uintptr(unsafe.Pointer(&q)), 0)
   169  	return Query{uint(q)}
   170  }
   171  func (c *Functions) CreateRenderbuffer() Renderbuffer {
   172  	var rb uintptr
   173  	syscall.Syscall(_glGenRenderbuffers.Addr(), 2, 1, uintptr(unsafe.Pointer(&rb)), 0)
   174  	return Renderbuffer{uint(rb)}
   175  }
   176  func (c *Functions) CreateShader(ty Enum) Shader {
   177  	s, _, _ := syscall.Syscall(_glCreateShader.Addr(), 1, uintptr(ty), 0, 0)
   178  	return Shader{uint(s)}
   179  }
   180  func (c *Functions) CreateTexture() Texture {
   181  	var t uintptr
   182  	syscall.Syscall(_glGenTextures.Addr(), 2, 1, uintptr(unsafe.Pointer(&t)), 0)
   183  	return Texture{uint(t)}
   184  }
   185  func (c *Functions) DeleteBuffer(v Buffer) {
   186  	syscall.Syscall(_glDeleteBuffers.Addr(), 2, 1, uintptr(unsafe.Pointer(&v)), 0)
   187  }
   188  func (c *Functions) DeleteFramebuffer(v Framebuffer) {
   189  	syscall.Syscall(_glDeleteFramebuffers.Addr(), 2, 1, uintptr(unsafe.Pointer(&v.V)), 0)
   190  }
   191  func (c *Functions) DeleteProgram(p Program) {
   192  	syscall.Syscall(_glDeleteProgram.Addr(), 1, uintptr(p.V), 0, 0)
   193  }
   194  func (f *Functions) DeleteQuery(query Query) {
   195  	syscall.Syscall(_glDeleteQueries.Addr(), 2, 1, uintptr(unsafe.Pointer(&query.V)), 0)
   196  }
   197  func (c *Functions) DeleteShader(s Shader) {
   198  	syscall.Syscall(_glDeleteShader.Addr(), 1, uintptr(s.V), 0, 0)
   199  }
   200  func (c *Functions) DeleteRenderbuffer(v Renderbuffer) {
   201  	syscall.Syscall(_glDeleteRenderbuffers.Addr(), 2, 1, uintptr(unsafe.Pointer(&v.V)), 0)
   202  }
   203  func (c *Functions) DeleteTexture(v Texture) {
   204  	syscall.Syscall(_glDeleteTextures.Addr(), 2, 1, uintptr(unsafe.Pointer(&v.V)), 0)
   205  }
   206  func (c *Functions) DepthFunc(f Enum) {
   207  	syscall.Syscall(_glDepthFunc.Addr(), 1, uintptr(f), 0, 0)
   208  }
   209  func (c *Functions) DepthMask(mask bool) {
   210  	var m uintptr
   211  	if mask {
   212  		m = 1
   213  	}
   214  	syscall.Syscall(_glDepthMask.Addr(), 1, m, 0, 0)
   215  }
   216  func (c *Functions) DisableVertexAttribArray(a Attrib) {
   217  	syscall.Syscall(_glDisableVertexAttribArray.Addr(), 1, uintptr(a), 0, 0)
   218  }
   219  func (c *Functions) Disable(cap Enum) {
   220  	syscall.Syscall(_glDisable.Addr(), 1, uintptr(cap), 0, 0)
   221  }
   222  func (c *Functions) DrawArrays(mode Enum, first, count int) {
   223  	syscall.Syscall(_glDrawArrays.Addr(), 3, uintptr(mode), uintptr(first), uintptr(count))
   224  }
   225  func (c *Functions) DrawElements(mode Enum, count int, ty Enum, offset int) {
   226  	syscall.Syscall6(_glDrawElements.Addr(), 4, uintptr(mode), uintptr(count), uintptr(ty), uintptr(offset), 0, 0)
   227  }
   228  func (c *Functions) Enable(cap Enum) {
   229  	syscall.Syscall(_glEnable.Addr(), 1, uintptr(cap), 0, 0)
   230  }
   231  func (c *Functions) EnableVertexAttribArray(a Attrib) {
   232  	syscall.Syscall(_glEnableVertexAttribArray.Addr(), 1, uintptr(a), 0, 0)
   233  }
   234  func (f *Functions) EndQuery(target Enum) {
   235  	syscall.Syscall(_glEndQuery.Addr(), 1, uintptr(target), 0, 0)
   236  }
   237  func (c *Functions) Finish() {
   238  	syscall.Syscall(_glFinish.Addr(), 0, 0, 0, 0)
   239  }
   240  func (c *Functions) FramebufferRenderbuffer(target, attachment, renderbuffertarget Enum, renderbuffer Renderbuffer) {
   241  	syscall.Syscall6(_glFramebufferRenderbuffer.Addr(), 4, uintptr(target), uintptr(attachment), uintptr(renderbuffertarget), uintptr(renderbuffer.V), 0, 0)
   242  }
   243  func (c *Functions) FramebufferTexture2D(target, attachment, texTarget Enum, t Texture, level int) {
   244  	syscall.Syscall6(_glFramebufferTexture2D.Addr(), 5, uintptr(target), uintptr(attachment), uintptr(texTarget), uintptr(t.V), uintptr(level), 0)
   245  }
   246  func (c *Functions) GetBinding(pname Enum) Object {
   247  	return Object{uint(c.GetInteger(pname))}
   248  }
   249  func (c *Functions) GetError() Enum {
   250  	e, _, _ := syscall.Syscall(_glGetError.Addr(), 0, 0, 0, 0)
   251  	return Enum(e)
   252  }
   253  func (c *Functions) GetRenderbufferParameteri(target, pname Enum) int {
   254  	p, _, _ := syscall.Syscall(_glGetRenderbufferParameteri.Addr(), 2, uintptr(target), uintptr(pname), 0)
   255  	return int(p)
   256  }
   257  func (c *Functions) GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int {
   258  	p, _, _ := syscall.Syscall(_glGetFramebufferAttachmentParameteri.Addr(), 3, uintptr(target), uintptr(attachment), uintptr(pname))
   259  	return int(p)
   260  }
   261  func (c *Functions) GetInteger(pname Enum) int {
   262  	syscall.Syscall(_glGetIntegerv.Addr(), 2, uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])), 0)
   263  	return int(c.int32s[0])
   264  }
   265  func (c *Functions) GetProgrami(p Program, pname Enum) int {
   266  	syscall.Syscall(_glGetProgramiv.Addr(), 3, uintptr(p.V), uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])))
   267  	return int(c.int32s[0])
   268  }
   269  func (c *Functions) GetProgramInfoLog(p Program) string {
   270  	n := c.GetProgrami(p, INFO_LOG_LENGTH)
   271  	buf := make([]byte, n)
   272  	syscall.Syscall6(_glGetProgramInfoLog.Addr(), 4, uintptr(p.V), uintptr(len(buf)), 0, uintptr(unsafe.Pointer(&buf[0])), 0, 0)
   273  	return string(buf)
   274  }
   275  func (c *Functions) GetQueryObjectuiv(query Query, pname Enum) uint {
   276  	syscall.Syscall(_glGetQueryObjectuiv.Addr(), 3, uintptr(query.V), uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])))
   277  	return uint(c.int32s[0])
   278  }
   279  func (c *Functions) GetShaderi(s Shader, pname Enum) int {
   280  	syscall.Syscall(_glGetShaderiv.Addr(), 3, uintptr(s.V), uintptr(pname), uintptr(unsafe.Pointer(&c.int32s[0])))
   281  	return int(c.int32s[0])
   282  }
   283  func (c *Functions) GetShaderInfoLog(s Shader) string {
   284  	n := c.GetShaderi(s, INFO_LOG_LENGTH)
   285  	buf := make([]byte, n)
   286  	syscall.Syscall6(_glGetShaderInfoLog.Addr(), 4, uintptr(s.V), uintptr(len(buf)), 0, uintptr(unsafe.Pointer(&buf[0])), 0, 0)
   287  	return string(buf)
   288  }
   289  func (c *Functions) GetString(pname Enum) string {
   290  	s, _, _ := syscall.Syscall(_glGetString.Addr(), 1, uintptr(pname), 0, 0)
   291  	return GoString(SliceOf(s))
   292  }
   293  func (c *Functions) GetUniformLocation(p Program, name string) Uniform {
   294  	cname := cString(name)
   295  	c0 := &cname[0]
   296  	u, _, _ := syscall.Syscall(_glGetUniformLocation.Addr(), 2, uintptr(p.V), uintptr(unsafe.Pointer(c0)), 0)
   297  	issue34474KeepAlive(c)
   298  	return Uniform{int(u)}
   299  }
   300  func (c *Functions) InvalidateFramebuffer(target, attachment Enum) {
   301  	addr := _glInvalidateFramebuffer.Addr()
   302  	if addr == 0 {
   303  		// InvalidateFramebuffer is just a hint. Skip it if not supported.
   304  		return
   305  	}
   306  	syscall.Syscall(addr, 3, uintptr(target), 1, uintptr(unsafe.Pointer(&attachment)))
   307  }
   308  func (c *Functions) LinkProgram(p Program) {
   309  	syscall.Syscall(_glLinkProgram.Addr(), 1, uintptr(p.V), 0, 0)
   310  }
   311  func (c *Functions) PixelStorei(pname Enum, param int32) {
   312  	syscall.Syscall(_glPixelStorei.Addr(), 2, uintptr(pname), uintptr(param), 0)
   313  }
   314  func (f *Functions) ReadPixels(x, y, width, height int, format, ty Enum, data []byte) {
   315  	d0 := &data[0]
   316  	syscall.Syscall6(_glReadPixels.Addr(), uintptr(x), uintptr(y), uintptr(width), uintptr(height), uintptr(format), uintptr(ty), uintptr(unsafe.Pointer(d0)))
   317  	issue34474KeepAlive(d0)
   318  }
   319  func (c *Functions) RenderbufferStorage(target, internalformat Enum, width, height int) {
   320  	syscall.Syscall6(_glRenderbufferStorage.Addr(), 4, uintptr(target), uintptr(internalformat), uintptr(width), uintptr(height), 0, 0)
   321  }
   322  func (c *Functions) Scissor(x, y, width, height int32) {
   323  	syscall.Syscall6(_glScissor.Addr(), 4, uintptr(x), uintptr(y), uintptr(width), uintptr(height), 0, 0)
   324  }
   325  func (c *Functions) ShaderSource(s Shader, src string) {
   326  	var n uintptr = uintptr(len(src))
   327  	psrc := &src
   328  	syscall.Syscall6(_glShaderSource.Addr(), 4, uintptr(s.V), 1, uintptr(unsafe.Pointer(psrc)), uintptr(unsafe.Pointer(&n)), 0, 0)
   329  	issue34474KeepAlive(psrc)
   330  }
   331  func (c *Functions) TexImage2D(target Enum, level int, internalFormat int, width, height int, format, ty Enum, data []byte) {
   332  	if len(data) == 0 {
   333  		syscall.Syscall9(_glTexImage2D.Addr(), 9, uintptr(target), uintptr(level), uintptr(internalFormat), uintptr(width), uintptr(height), 0, uintptr(format), uintptr(ty), 0)
   334  	} else {
   335  		d0 := &data[0]
   336  		syscall.Syscall9(_glTexImage2D.Addr(), 9, uintptr(target), uintptr(level), uintptr(internalFormat), uintptr(width), uintptr(height), 0, uintptr(format), uintptr(ty), uintptr(unsafe.Pointer(d0)))
   337  		issue34474KeepAlive(d0)
   338  	}
   339  }
   340  func (c *Functions) TexSubImage2D(target Enum, level int, x, y, width, height int, format, ty Enum, data []byte) {
   341  	d0 := &data[0]
   342  	syscall.Syscall9(_glTexSubImage2D.Addr(), 9, uintptr(target), uintptr(level), uintptr(x), uintptr(y), uintptr(width), uintptr(height), uintptr(format), uintptr(ty), uintptr(unsafe.Pointer(d0)))
   343  	issue34474KeepAlive(d0)
   344  }
   345  func (c *Functions) TexParameteri(target, pname Enum, param int) {
   346  	syscall.Syscall(_glTexParameteri.Addr(), 3, uintptr(target), uintptr(pname), uintptr(param))
   347  }
   348  func (c *Functions) Uniform1f(dst Uniform, v float32) {
   349  	syscall.Syscall(_glUniform1f.Addr(), 2, uintptr(dst.V), uintptr(math.Float32bits(v)), 0)
   350  }
   351  func (c *Functions) Uniform1i(dst Uniform, v int) {
   352  	syscall.Syscall(_glUniform1i.Addr(), 2, uintptr(dst.V), uintptr(v), 0)
   353  }
   354  func (c *Functions) Uniform2f(dst Uniform, v0, v1 float32) {
   355  	syscall.Syscall(_glUniform2f.Addr(), 3, uintptr(dst.V), uintptr(math.Float32bits(v0)), uintptr(math.Float32bits(v1)))
   356  }
   357  func (c *Functions) Uniform3f(dst Uniform, v0, v1, v2 float32) {
   358  	syscall.Syscall6(_glUniform3f.Addr(), 4, uintptr(dst.V), uintptr(math.Float32bits(v0)), uintptr(math.Float32bits(v1)), uintptr(math.Float32bits(v2)), 0, 0)
   359  }
   360  func (c *Functions) Uniform4f(dst Uniform, v0, v1, v2, v3 float32) {
   361  	syscall.Syscall6(_glUniform4f.Addr(), 5, uintptr(dst.V), uintptr(math.Float32bits(v0)), uintptr(math.Float32bits(v1)), uintptr(math.Float32bits(v2)), uintptr(math.Float32bits(v3)), 0)
   362  }
   363  func (c *Functions) UseProgram(p Program) {
   364  	syscall.Syscall(_glUseProgram.Addr(), 1, uintptr(p.V), 0, 0)
   365  }
   366  func (c *Functions) VertexAttribPointer(dst Attrib, size int, ty Enum, normalized bool, stride, offset int) {
   367  	var norm uintptr
   368  	if normalized {
   369  		norm = 1
   370  	}
   371  	syscall.Syscall6(_glVertexAttribPointer.Addr(), 6, uintptr(dst), uintptr(size), uintptr(ty), norm, uintptr(stride), uintptr(offset))
   372  }
   373  func (c *Functions) Viewport(x, y, width, height int) {
   374  	syscall.Syscall6(_glViewport.Addr(), 4, uintptr(x), uintptr(y), uintptr(width), uintptr(height), 0, 0)
   375  }
   376  
   377  func cString(s string) []byte {
   378  	b := make([]byte, len(s)+1)
   379  	copy(b, s)
   380  	return b
   381  }
   382  
   383  // issue34474KeepAlive calls runtime.KeepAlive as a
   384  // workaround for golang.org/issue/34474.
   385  func issue34474KeepAlive(v interface{}) {
   386  	runtime.KeepAlive(v)
   387  }