zorldo

Goofing around with Ebiten
git clone git://bsandro.tech/zorldo
Log | Files | Refs | README

interface.go (31777B)


      1 // Copyright 2014 The Go Authors.  All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 package gl
      6 
      7 // Context is an OpenGL ES context.
      8 //
      9 // A Context has a method for every GL function supported by ES 2 or later.
     10 // In a program compiled with ES 3 support, a Context is also a Context3.
     11 // For example, a program can:
     12 //
     13 //	func f(glctx gl.Context) {
     14 //		glctx.(gl.Context3).BlitFramebuffer(...)
     15 //	}
     16 //
     17 // Calls are not safe for concurrent use. However calls can be made from
     18 // any goroutine, the gl package removes the notion of thread-local
     19 // context.
     20 //
     21 // Contexts are independent. Two contexts can be used concurrently.
     22 type Context interface {
     23 	// ActiveTexture sets the active texture unit.
     24 	//
     25 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glActiveTexture.xhtml
     26 	ActiveTexture(texture Enum)
     27 
     28 	// AttachShader attaches a shader to a program.
     29 	//
     30 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glAttachShader.xhtml
     31 	AttachShader(p Program, s Shader)
     32 
     33 	// BindAttribLocation binds a vertex attribute index with a named
     34 	// variable.
     35 	//
     36 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBindAttribLocation.xhtml
     37 	BindAttribLocation(p Program, a Attrib, name string)
     38 
     39 	// BindBuffer binds a buffer.
     40 	//
     41 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBindBuffer.xhtml
     42 	BindBuffer(target Enum, b Buffer)
     43 
     44 	// BindFramebuffer binds a framebuffer.
     45 	//
     46 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBindFramebuffer.xhtml
     47 	BindFramebuffer(target Enum, fb Framebuffer)
     48 
     49 	// BindRenderbuffer binds a render buffer.
     50 	//
     51 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBindRenderbuffer.xhtml
     52 	BindRenderbuffer(target Enum, rb Renderbuffer)
     53 
     54 	// BindTexture binds a texture.
     55 	//
     56 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBindTexture.xhtml
     57 	BindTexture(target Enum, t Texture)
     58 
     59 	// BindVertexArray binds a vertex array.
     60 	//
     61 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBindVertexArray.xhtml
     62 	BindVertexArray(rb VertexArray)
     63 
     64 	// BlendColor sets the blend color.
     65 	//
     66 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendColor.xhtml
     67 	BlendColor(red, green, blue, alpha float32)
     68 
     69 	// BlendEquation sets both RGB and alpha blend equations.
     70 	//
     71 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendEquation.xhtml
     72 	BlendEquation(mode Enum)
     73 
     74 	// BlendEquationSeparate sets RGB and alpha blend equations separately.
     75 	//
     76 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendEquationSeparate.xhtml
     77 	BlendEquationSeparate(modeRGB, modeAlpha Enum)
     78 
     79 	// BlendFunc sets the pixel blending factors.
     80 	//
     81 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendFunc.xhtml
     82 	BlendFunc(sfactor, dfactor Enum)
     83 
     84 	// BlendFunc sets the pixel RGB and alpha blending factors separately.
     85 	//
     86 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBlendFuncSeparate.xhtml
     87 	BlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha Enum)
     88 
     89 	// BufferData creates a new data store for the bound buffer object.
     90 	//
     91 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBufferData.xhtml
     92 	BufferData(target Enum, src []byte, usage Enum)
     93 
     94 	// BufferInit creates a new uninitialized data store for the bound buffer object.
     95 	//
     96 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBufferData.xhtml
     97 	BufferInit(target Enum, size int, usage Enum)
     98 
     99 	// BufferSubData sets some of data in the bound buffer object.
    100 	//
    101 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glBufferSubData.xhtml
    102 	BufferSubData(target Enum, offset int, data []byte)
    103 
    104 	// CheckFramebufferStatus reports the completeness status of the
    105 	// active framebuffer.
    106 	//
    107 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glCheckFramebufferStatus.xhtml
    108 	CheckFramebufferStatus(target Enum) Enum
    109 
    110 	// Clear clears the window.
    111 	//
    112 	// The behavior of Clear is influenced by the pixel ownership test,
    113 	// the scissor test, dithering, and the buffer writemasks.
    114 	//
    115 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glClear.xhtml
    116 	Clear(mask Enum)
    117 
    118 	// ClearColor specifies the RGBA values used to clear color buffers.
    119 	//
    120 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glClearColor.xhtml
    121 	ClearColor(red, green, blue, alpha float32)
    122 
    123 	// ClearDepthf sets the depth value used to clear the depth buffer.
    124 	//
    125 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glClearDepthf.xhtml
    126 	ClearDepthf(d float32)
    127 
    128 	// ClearStencil sets the index used to clear the stencil buffer.
    129 	//
    130 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glClearStencil.xhtml
    131 	ClearStencil(s int)
    132 
    133 	// ColorMask specifies whether color components in the framebuffer
    134 	// can be written.
    135 	//
    136 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glColorMask.xhtml
    137 	ColorMask(red, green, blue, alpha bool)
    138 
    139 	// CompileShader compiles the source code of s.
    140 	//
    141 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glCompileShader.xhtml
    142 	CompileShader(s Shader)
    143 
    144 	// CompressedTexImage2D writes a compressed 2D texture.
    145 	//
    146 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexImage2D.xhtml
    147 	CompressedTexImage2D(target Enum, level int, internalformat Enum, width, height, border int, data []byte)
    148 
    149 	// CompressedTexSubImage2D writes a subregion of a compressed 2D texture.
    150 	//
    151 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glCompressedTexSubImage2D.xhtml
    152 	CompressedTexSubImage2D(target Enum, level, xoffset, yoffset, width, height int, format Enum, data []byte)
    153 
    154 	// CopyTexImage2D writes a 2D texture from the current framebuffer.
    155 	//
    156 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glCopyTexImage2D.xhtml
    157 	CopyTexImage2D(target Enum, level int, internalformat Enum, x, y, width, height, border int)
    158 
    159 	// CopyTexSubImage2D writes a 2D texture subregion from the
    160 	// current framebuffer.
    161 	//
    162 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glCopyTexSubImage2D.xhtml
    163 	CopyTexSubImage2D(target Enum, level, xoffset, yoffset, x, y, width, height int)
    164 
    165 	// CreateBuffer creates a buffer object.
    166 	//
    167 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGenBuffers.xhtml
    168 	CreateBuffer() Buffer
    169 
    170 	// CreateFramebuffer creates a framebuffer object.
    171 	//
    172 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGenFramebuffers.xhtml
    173 	CreateFramebuffer() Framebuffer
    174 
    175 	// CreateProgram creates a new empty program object.
    176 	//
    177 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glCreateProgram.xhtml
    178 	CreateProgram() Program
    179 
    180 	// CreateRenderbuffer create a renderbuffer object.
    181 	//
    182 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGenRenderbuffers.xhtml
    183 	CreateRenderbuffer() Renderbuffer
    184 
    185 	// CreateShader creates a new empty shader object.
    186 	//
    187 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glCreateShader.xhtml
    188 	CreateShader(ty Enum) Shader
    189 
    190 	// CreateTexture creates a texture object.
    191 	//
    192 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGenTextures.xhtml
    193 	CreateTexture() Texture
    194 
    195 	// CreateTVertexArray creates a vertex array.
    196 	//
    197 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGenVertexArrays.xhtml
    198 	CreateVertexArray() VertexArray
    199 
    200 	// CullFace specifies which polygons are candidates for culling.
    201 	//
    202 	// Valid modes: FRONT, BACK, FRONT_AND_BACK.
    203 	//
    204 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glCullFace.xhtml
    205 	CullFace(mode Enum)
    206 
    207 	// DeleteBuffer deletes the given buffer object.
    208 	//
    209 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteBuffers.xhtml
    210 	DeleteBuffer(v Buffer)
    211 
    212 	// DeleteFramebuffer deletes the given framebuffer object.
    213 	//
    214 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteFramebuffers.xhtml
    215 	DeleteFramebuffer(v Framebuffer)
    216 
    217 	// DeleteProgram deletes the given program object.
    218 	//
    219 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteProgram.xhtml
    220 	DeleteProgram(p Program)
    221 
    222 	// DeleteRenderbuffer deletes the given render buffer object.
    223 	//
    224 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteRenderbuffers.xhtml
    225 	DeleteRenderbuffer(v Renderbuffer)
    226 
    227 	// DeleteShader deletes shader s.
    228 	//
    229 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteShader.xhtml
    230 	DeleteShader(s Shader)
    231 
    232 	// DeleteTexture deletes the given texture object.
    233 	//
    234 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteTextures.xhtml
    235 	DeleteTexture(v Texture)
    236 
    237 	// DeleteVertexArray deletes the given render buffer object.
    238 	//
    239 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDeleteVertexArrays.xhtml
    240 	DeleteVertexArray(v VertexArray)
    241 
    242 	// DepthFunc sets the function used for depth buffer comparisons.
    243 	//
    244 	// Valid fn values:
    245 	//	NEVER
    246 	//	LESS
    247 	//	EQUAL
    248 	//	LEQUAL
    249 	//	GREATER
    250 	//	NOTEQUAL
    251 	//	GEQUAL
    252 	//	ALWAYS
    253 	//
    254 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDepthFunc.xhtml
    255 	DepthFunc(fn Enum)
    256 
    257 	// DepthMask sets the depth buffer enabled for writing.
    258 	//
    259 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDepthMask.xhtml
    260 	DepthMask(flag bool)
    261 
    262 	// DepthRangef sets the mapping from normalized device coordinates to
    263 	// window coordinates.
    264 	//
    265 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDepthRangef.xhtml
    266 	DepthRangef(n, f float32)
    267 
    268 	// DetachShader detaches the shader s from the program p.
    269 	//
    270 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDetachShader.xhtml
    271 	DetachShader(p Program, s Shader)
    272 
    273 	// Disable disables various GL capabilities.
    274 	//
    275 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDisable.xhtml
    276 	Disable(cap Enum)
    277 
    278 	// DisableVertexAttribArray disables a vertex attribute array.
    279 	//
    280 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDisableVertexAttribArray.xhtml
    281 	DisableVertexAttribArray(a Attrib)
    282 
    283 	// DrawArrays renders geometric primitives from the bound data.
    284 	//
    285 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDrawArrays.xhtml
    286 	DrawArrays(mode Enum, first, count int)
    287 
    288 	// DrawElements renders primitives from a bound buffer.
    289 	//
    290 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glDrawElements.xhtml
    291 	DrawElements(mode Enum, count int, ty Enum, offset int)
    292 
    293 	// TODO(crawshaw): consider DrawElements8 / DrawElements16 / DrawElements32
    294 
    295 	// Enable enables various GL capabilities.
    296 	//
    297 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glEnable.xhtml
    298 	Enable(cap Enum)
    299 
    300 	// EnableVertexAttribArray enables a vertex attribute array.
    301 	//
    302 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glEnableVertexAttribArray.xhtml
    303 	EnableVertexAttribArray(a Attrib)
    304 
    305 	// Finish blocks until the effects of all previously called GL
    306 	// commands are complete.
    307 	//
    308 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glFinish.xhtml
    309 	Finish()
    310 
    311 	// Flush empties all buffers. It does not block.
    312 	//
    313 	// An OpenGL implementation may buffer network communication,
    314 	// the command stream, or data inside the graphics accelerator.
    315 	//
    316 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glFlush.xhtml
    317 	Flush()
    318 
    319 	// FramebufferRenderbuffer attaches rb to the current frame buffer.
    320 	//
    321 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glFramebufferRenderbuffer.xhtml
    322 	FramebufferRenderbuffer(target, attachment, rbTarget Enum, rb Renderbuffer)
    323 
    324 	// FramebufferTexture2D attaches the t to the current frame buffer.
    325 	//
    326 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glFramebufferTexture2D.xhtml
    327 	FramebufferTexture2D(target, attachment, texTarget Enum, t Texture, level int)
    328 
    329 	// FrontFace defines which polygons are front-facing.
    330 	//
    331 	// Valid modes: CW, CCW.
    332 	//
    333 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glFrontFace.xhtml
    334 	FrontFace(mode Enum)
    335 
    336 	// GenerateMipmap generates mipmaps for the current texture.
    337 	//
    338 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGenerateMipmap.xhtml
    339 	GenerateMipmap(target Enum)
    340 
    341 	// GetActiveAttrib returns details about an active attribute variable.
    342 	// A value of 0 for index selects the first active attribute variable.
    343 	// Permissible values for index range from 0 to the number of active
    344 	// attribute variables minus 1.
    345 	//
    346 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetActiveAttrib.xhtml
    347 	GetActiveAttrib(p Program, index uint32) (name string, size int, ty Enum)
    348 
    349 	// GetActiveUniform returns details about an active uniform variable.
    350 	// A value of 0 for index selects the first active uniform variable.
    351 	// Permissible values for index range from 0 to the number of active
    352 	// uniform variables minus 1.
    353 	//
    354 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetActiveUniform.xhtml
    355 	GetActiveUniform(p Program, index uint32) (name string, size int, ty Enum)
    356 
    357 	// GetAttachedShaders returns the shader objects attached to program p.
    358 	//
    359 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetAttachedShaders.xhtml
    360 	GetAttachedShaders(p Program) []Shader
    361 
    362 	// GetAttribLocation returns the location of an attribute variable.
    363 	//
    364 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetAttribLocation.xhtml
    365 	GetAttribLocation(p Program, name string) Attrib
    366 
    367 	// GetBooleanv returns the boolean values of parameter pname.
    368 	//
    369 	// Many boolean parameters can be queried more easily using IsEnabled.
    370 	//
    371 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGet.xhtml
    372 	GetBooleanv(dst []bool, pname Enum)
    373 
    374 	// GetFloatv returns the float values of parameter pname.
    375 	//
    376 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGet.xhtml
    377 	GetFloatv(dst []float32, pname Enum)
    378 
    379 	// GetIntegerv returns the int values of parameter pname.
    380 	//
    381 	// Single values may be queried more easily using GetInteger.
    382 	//
    383 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGet.xhtml
    384 	GetIntegerv(dst []int32, pname Enum)
    385 
    386 	// GetInteger returns the int value of parameter pname.
    387 	//
    388 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGet.xhtml
    389 	GetInteger(pname Enum) int
    390 
    391 	// GetBufferParameteri returns a parameter for the active buffer.
    392 	//
    393 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetBufferParameter.xhtml
    394 	GetBufferParameteri(target, value Enum) int
    395 
    396 	// GetError returns the next error.
    397 	//
    398 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetError.xhtml
    399 	GetError() Enum
    400 
    401 	// GetFramebufferAttachmentParameteri returns attachment parameters
    402 	// for the active framebuffer object.
    403 	//
    404 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetFramebufferAttachmentParameteriv.xhtml
    405 	GetFramebufferAttachmentParameteri(target, attachment, pname Enum) int
    406 
    407 	// GetProgrami returns a parameter value for a program.
    408 	//
    409 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetProgramiv.xhtml
    410 	GetProgrami(p Program, pname Enum) int
    411 
    412 	// GetProgramInfoLog returns the information log for a program.
    413 	//
    414 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetProgramInfoLog.xhtml
    415 	GetProgramInfoLog(p Program) string
    416 
    417 	// GetRenderbufferParameteri returns a parameter value for a render buffer.
    418 	//
    419 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetRenderbufferParameteriv.xhtml
    420 	GetRenderbufferParameteri(target, pname Enum) int
    421 
    422 	// GetShaderi returns a parameter value for a shader.
    423 	//
    424 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetShaderiv.xhtml
    425 	GetShaderi(s Shader, pname Enum) int
    426 
    427 	// GetShaderInfoLog returns the information log for a shader.
    428 	//
    429 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetShaderInfoLog.xhtml
    430 	GetShaderInfoLog(s Shader) string
    431 
    432 	// GetShaderPrecisionFormat returns range and precision limits for
    433 	// shader types.
    434 	//
    435 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetShaderPrecisionFormat.xhtml
    436 	GetShaderPrecisionFormat(shadertype, precisiontype Enum) (rangeLow, rangeHigh, precision int)
    437 
    438 	// GetShaderSource returns source code of shader s.
    439 	//
    440 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetShaderSource.xhtml
    441 	GetShaderSource(s Shader) string
    442 
    443 	// GetString reports current GL state.
    444 	//
    445 	// Valid name values:
    446 	//	EXTENSIONS
    447 	//	RENDERER
    448 	//	SHADING_LANGUAGE_VERSION
    449 	//	VENDOR
    450 	//	VERSION
    451 	//
    452 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetString.xhtml
    453 	GetString(pname Enum) string
    454 
    455 	// GetTexParameterfv returns the float values of a texture parameter.
    456 	//
    457 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetTexParameter.xhtml
    458 	GetTexParameterfv(dst []float32, target, pname Enum)
    459 
    460 	// GetTexParameteriv returns the int values of a texture parameter.
    461 	//
    462 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetTexParameter.xhtml
    463 	GetTexParameteriv(dst []int32, target, pname Enum)
    464 
    465 	// GetUniformfv returns the float values of a uniform variable.
    466 	//
    467 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetUniform.xhtml
    468 	GetUniformfv(dst []float32, src Uniform, p Program)
    469 
    470 	// GetUniformiv returns the float values of a uniform variable.
    471 	//
    472 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetUniform.xhtml
    473 	GetUniformiv(dst []int32, src Uniform, p Program)
    474 
    475 	// GetUniformLocation returns the location of a uniform variable.
    476 	//
    477 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetUniformLocation.xhtml
    478 	GetUniformLocation(p Program, name string) Uniform
    479 
    480 	// GetVertexAttribf reads the float value of a vertex attribute.
    481 	//
    482 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetVertexAttrib.xhtml
    483 	GetVertexAttribf(src Attrib, pname Enum) float32
    484 
    485 	// GetVertexAttribfv reads float values of a vertex attribute.
    486 	//
    487 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetVertexAttrib.xhtml
    488 	GetVertexAttribfv(dst []float32, src Attrib, pname Enum)
    489 
    490 	// GetVertexAttribi reads the int value of a vertex attribute.
    491 	//
    492 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetVertexAttrib.xhtml
    493 	GetVertexAttribi(src Attrib, pname Enum) int32
    494 
    495 	// GetVertexAttribiv reads int values of a vertex attribute.
    496 	//
    497 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glGetVertexAttrib.xhtml
    498 	GetVertexAttribiv(dst []int32, src Attrib, pname Enum)
    499 
    500 	// TODO(crawshaw): glGetVertexAttribPointerv
    501 
    502 	// Hint sets implementation-specific modes.
    503 	//
    504 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glHint.xhtml
    505 	Hint(target, mode Enum)
    506 
    507 	// IsBuffer reports if b is a valid buffer.
    508 	//
    509 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glIsBuffer.xhtml
    510 	IsBuffer(b Buffer) bool
    511 
    512 	// IsEnabled reports if cap is an enabled capability.
    513 	//
    514 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glIsEnabled.xhtml
    515 	IsEnabled(cap Enum) bool
    516 
    517 	// IsFramebuffer reports if fb is a valid frame buffer.
    518 	//
    519 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glIsFramebuffer.xhtml
    520 	IsFramebuffer(fb Framebuffer) bool
    521 
    522 	// IsProgram reports if p is a valid program object.
    523 	//
    524 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glIsProgram.xhtml
    525 	IsProgram(p Program) bool
    526 
    527 	// IsRenderbuffer reports if rb is a valid render buffer.
    528 	//
    529 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glIsRenderbuffer.xhtml
    530 	IsRenderbuffer(rb Renderbuffer) bool
    531 
    532 	// IsShader reports if s is valid shader.
    533 	//
    534 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glIsShader.xhtml
    535 	IsShader(s Shader) bool
    536 
    537 	// IsTexture reports if t is a valid texture.
    538 	//
    539 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glIsTexture.xhtml
    540 	IsTexture(t Texture) bool
    541 
    542 	// LineWidth specifies the width of lines.
    543 	//
    544 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glLineWidth.xhtml
    545 	LineWidth(width float32)
    546 
    547 	// LinkProgram links the specified program.
    548 	//
    549 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glLinkProgram.xhtml
    550 	LinkProgram(p Program)
    551 
    552 	// PixelStorei sets pixel storage parameters.
    553 	//
    554 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glPixelStorei.xhtml
    555 	PixelStorei(pname Enum, param int32)
    556 
    557 	// PolygonOffset sets the scaling factors for depth offsets.
    558 	//
    559 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glPolygonOffset.xhtml
    560 	PolygonOffset(factor, units float32)
    561 
    562 	// ReadPixels returns pixel data from a buffer.
    563 	//
    564 	// In GLES 3, the source buffer is controlled with ReadBuffer.
    565 	//
    566 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glReadPixels.xhtml
    567 	ReadPixels(dst []byte, x, y, width, height int, format, ty Enum)
    568 
    569 	// ReleaseShaderCompiler frees resources allocated by the shader compiler.
    570 	//
    571 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glReleaseShaderCompiler.xhtml
    572 	ReleaseShaderCompiler()
    573 
    574 	// RenderbufferStorage establishes the data storage, format, and
    575 	// dimensions of a renderbuffer object's image.
    576 	//
    577 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glRenderbufferStorage.xhtml
    578 	RenderbufferStorage(target, internalFormat Enum, width, height int)
    579 
    580 	// SampleCoverage sets multisample coverage parameters.
    581 	//
    582 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glSampleCoverage.xhtml
    583 	SampleCoverage(value float32, invert bool)
    584 
    585 	// Scissor defines the scissor box rectangle, in window coordinates.
    586 	//
    587 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glScissor.xhtml
    588 	Scissor(x, y, width, height int32)
    589 
    590 	// TODO(crawshaw): ShaderBinary
    591 
    592 	// ShaderSource sets the source code of s to the given source code.
    593 	//
    594 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glShaderSource.xhtml
    595 	ShaderSource(s Shader, src string)
    596 
    597 	// StencilFunc sets the front and back stencil test reference value.
    598 	//
    599 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilFunc.xhtml
    600 	StencilFunc(fn Enum, ref int, mask uint32)
    601 
    602 	// StencilFunc sets the front or back stencil test reference value.
    603 	//
    604 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilFuncSeparate.xhtml
    605 	StencilFuncSeparate(face, fn Enum, ref int, mask uint32)
    606 
    607 	// StencilMask controls the writing of bits in the stencil planes.
    608 	//
    609 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilMask.xhtml
    610 	StencilMask(mask uint32)
    611 
    612 	// StencilMaskSeparate controls the writing of bits in the stencil planes.
    613 	//
    614 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilMaskSeparate.xhtml
    615 	StencilMaskSeparate(face Enum, mask uint32)
    616 
    617 	// StencilOp sets front and back stencil test actions.
    618 	//
    619 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilOp.xhtml
    620 	StencilOp(fail, zfail, zpass Enum)
    621 
    622 	// StencilOpSeparate sets front or back stencil tests.
    623 	//
    624 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glStencilOpSeparate.xhtml
    625 	StencilOpSeparate(face, sfail, dpfail, dppass Enum)
    626 
    627 	// TexImage2D writes a 2D texture image.
    628 	//
    629 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glTexImage2D.xhtml
    630 	TexImage2D(target Enum, level int, internalFormat int, width, height int, format Enum, ty Enum, data []byte)
    631 
    632 	// TexSubImage2D writes a subregion of a 2D texture image.
    633 	//
    634 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glTexSubImage2D.xhtml
    635 	TexSubImage2D(target Enum, level int, x, y, width, height int, format, ty Enum, data []byte)
    636 
    637 	// TexParameterf sets a float texture parameter.
    638 	//
    639 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glTexParameter.xhtml
    640 	TexParameterf(target, pname Enum, param float32)
    641 
    642 	// TexParameterfv sets a float texture parameter array.
    643 	//
    644 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glTexParameter.xhtml
    645 	TexParameterfv(target, pname Enum, params []float32)
    646 
    647 	// TexParameteri sets an integer texture parameter.
    648 	//
    649 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glTexParameter.xhtml
    650 	TexParameteri(target, pname Enum, param int)
    651 
    652 	// TexParameteriv sets an integer texture parameter array.
    653 	//
    654 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glTexParameter.xhtml
    655 	TexParameteriv(target, pname Enum, params []int32)
    656 
    657 	// Uniform1f writes a float uniform variable.
    658 	//
    659 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    660 	Uniform1f(dst Uniform, v float32)
    661 
    662 	// Uniform1fv writes a [len(src)]float uniform array.
    663 	//
    664 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    665 	Uniform1fv(dst Uniform, src []float32)
    666 
    667 	// Uniform1i writes an int uniform variable.
    668 	//
    669 	// Uniform1i and Uniform1iv are the only two functions that may be used
    670 	// to load uniform variables defined as sampler types. Loading samplers
    671 	// with any other function will result in a INVALID_OPERATION error.
    672 	//
    673 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    674 	Uniform1i(dst Uniform, v int)
    675 
    676 	// Uniform1iv writes a int uniform array of len(src) elements.
    677 	//
    678 	// Uniform1i and Uniform1iv are the only two functions that may be used
    679 	// to load uniform variables defined as sampler types. Loading samplers
    680 	// with any other function will result in a INVALID_OPERATION error.
    681 	//
    682 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    683 	Uniform1iv(dst Uniform, src []int32)
    684 
    685 	// Uniform2f writes a vec2 uniform variable.
    686 	//
    687 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    688 	Uniform2f(dst Uniform, v0, v1 float32)
    689 
    690 	// Uniform2fv writes a vec2 uniform array of len(src)/2 elements.
    691 	//
    692 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    693 	Uniform2fv(dst Uniform, src []float32)
    694 
    695 	// Uniform2i writes an ivec2 uniform variable.
    696 	//
    697 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    698 	Uniform2i(dst Uniform, v0, v1 int)
    699 
    700 	// Uniform2iv writes an ivec2 uniform array of len(src)/2 elements.
    701 	//
    702 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    703 	Uniform2iv(dst Uniform, src []int32)
    704 
    705 	// Uniform3f writes a vec3 uniform variable.
    706 	//
    707 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    708 	Uniform3f(dst Uniform, v0, v1, v2 float32)
    709 
    710 	// Uniform3fv writes a vec3 uniform array of len(src)/3 elements.
    711 	//
    712 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    713 	Uniform3fv(dst Uniform, src []float32)
    714 
    715 	// Uniform3i writes an ivec3 uniform variable.
    716 	//
    717 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    718 	Uniform3i(dst Uniform, v0, v1, v2 int32)
    719 
    720 	// Uniform3iv writes an ivec3 uniform array of len(src)/3 elements.
    721 	//
    722 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    723 	Uniform3iv(dst Uniform, src []int32)
    724 
    725 	// Uniform4f writes a vec4 uniform variable.
    726 	//
    727 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    728 	Uniform4f(dst Uniform, v0, v1, v2, v3 float32)
    729 
    730 	// Uniform4fv writes a vec4 uniform array of len(src)/4 elements.
    731 	//
    732 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    733 	Uniform4fv(dst Uniform, src []float32)
    734 
    735 	// Uniform4i writes an ivec4 uniform variable.
    736 	//
    737 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    738 	Uniform4i(dst Uniform, v0, v1, v2, v3 int32)
    739 
    740 	// Uniform4i writes an ivec4 uniform array of len(src)/4 elements.
    741 	//
    742 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    743 	Uniform4iv(dst Uniform, src []int32)
    744 
    745 	// UniformMatrix2fv writes 2x2 matrices. Each matrix uses four
    746 	// float32 values, so the number of matrices written is len(src)/4.
    747 	//
    748 	// Each matrix must be supplied in column major order.
    749 	//
    750 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    751 	UniformMatrix2fv(dst Uniform, src []float32)
    752 
    753 	// UniformMatrix3fv writes 3x3 matrices. Each matrix uses nine
    754 	// float32 values, so the number of matrices written is len(src)/9.
    755 	//
    756 	// Each matrix must be supplied in column major order.
    757 	//
    758 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    759 	UniformMatrix3fv(dst Uniform, src []float32)
    760 
    761 	// UniformMatrix4fv writes 4x4 matrices. Each matrix uses 16
    762 	// float32 values, so the number of matrices written is len(src)/16.
    763 	//
    764 	// Each matrix must be supplied in column major order.
    765 	//
    766 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUniform.xhtml
    767 	UniformMatrix4fv(dst Uniform, src []float32)
    768 
    769 	// UseProgram sets the active program.
    770 	//
    771 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glUseProgram.xhtml
    772 	UseProgram(p Program)
    773 
    774 	// ValidateProgram checks to see whether the executables contained in
    775 	// program can execute given the current OpenGL state.
    776 	//
    777 	// Typically only used for debugging.
    778 	//
    779 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glValidateProgram.xhtml
    780 	ValidateProgram(p Program)
    781 
    782 	// VertexAttrib1f writes a float vertex attribute.
    783 	//
    784 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
    785 	VertexAttrib1f(dst Attrib, x float32)
    786 
    787 	// VertexAttrib1fv writes a float vertex attribute.
    788 	//
    789 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
    790 	VertexAttrib1fv(dst Attrib, src []float32)
    791 
    792 	// VertexAttrib2f writes a vec2 vertex attribute.
    793 	//
    794 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
    795 	VertexAttrib2f(dst Attrib, x, y float32)
    796 
    797 	// VertexAttrib2fv writes a vec2 vertex attribute.
    798 	//
    799 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
    800 	VertexAttrib2fv(dst Attrib, src []float32)
    801 
    802 	// VertexAttrib3f writes a vec3 vertex attribute.
    803 	//
    804 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
    805 	VertexAttrib3f(dst Attrib, x, y, z float32)
    806 
    807 	// VertexAttrib3fv writes a vec3 vertex attribute.
    808 	//
    809 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
    810 	VertexAttrib3fv(dst Attrib, src []float32)
    811 
    812 	// VertexAttrib4f writes a vec4 vertex attribute.
    813 	//
    814 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
    815 	VertexAttrib4f(dst Attrib, x, y, z, w float32)
    816 
    817 	// VertexAttrib4fv writes a vec4 vertex attribute.
    818 	//
    819 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttrib.xhtml
    820 	VertexAttrib4fv(dst Attrib, src []float32)
    821 
    822 	// VertexAttribPointer uses a bound buffer to define vertex attribute data.
    823 	//
    824 	// Direct use of VertexAttribPointer to load data into OpenGL is not
    825 	// supported via the Go bindings. Instead, use BindBuffer with an
    826 	// ARRAY_BUFFER and then fill it using BufferData.
    827 	//
    828 	// The size argument specifies the number of components per attribute,
    829 	// between 1-4. The stride argument specifies the byte offset between
    830 	// consecutive vertex attributes.
    831 	//
    832 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glVertexAttribPointer.xhtml
    833 	VertexAttribPointer(dst Attrib, size int, ty Enum, normalized bool, stride, offset int)
    834 
    835 	// Viewport sets the viewport, an affine transformation that
    836 	// normalizes device coordinates to window coordinates.
    837 	//
    838 	// http://www.khronos.org/opengles/sdk/docs/man3/html/glViewport.xhtml
    839 	Viewport(x, y, width, height int)
    840 }
    841 
    842 // Context3 is an OpenGL ES 3 context.
    843 //
    844 // When the gl package is compiled with GL ES 3 support, the produced
    845 // Context object also implements the Context3 interface.
    846 type Context3 interface {
    847 	Context
    848 
    849 	// BlitFramebuffer copies a block of pixels between framebuffers.
    850 	//
    851 	// https://www.khronos.org/opengles/sdk/docs/man3/html/glBlitFramebuffer.xhtml
    852 	BlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1 int, mask uint, filter Enum)
    853 }
    854 
    855 // Worker is used by display driver code to execute OpenGL calls.
    856 //
    857 // Typically display driver code creates a gl.Context for an application,
    858 // and along with it establishes a locked OS thread to execute the cgo
    859 // calls:
    860 //
    861 //	go func() {
    862 //		runtime.LockOSThread()
    863 //		// ... platform-specific cgo call to bind a C OpenGL context
    864 //		// into thread-local storage.
    865 //
    866 //		glctx, worker := gl.NewContext()
    867 //		workAvailable := worker.WorkAvailable()
    868 //		go userAppCode(glctx)
    869 //		for {
    870 //			select {
    871 //			case <-workAvailable:
    872 //				worker.DoWork()
    873 //			case <-drawEvent:
    874 //				// ... platform-specific cgo call to draw screen
    875 //			}
    876 //		}
    877 //	}()
    878 //
    879 // This interface is an internal implementation detail and should only be used
    880 // by the package responsible for managing the screen, such as
    881 // golang.org/x/mobile/app.
    882 type Worker interface {
    883 	// WorkAvailable returns a channel that communicates when DoWork should be
    884 	// called.
    885 	WorkAvailable() <-chan struct{}
    886 
    887 	// DoWork performs any pending OpenGL calls.
    888 	DoWork()
    889 }