all: update OpenGL version from 2.1 to 3.2

'texelFetch' requires OpenGLSL 1.30, which requires OpenGL 3.0+.
macOS might not support OpenGL 3.0 and 3.1, so adopt 3.2.

Updates #1431
This commit is contained in:
Hajime Hoshi 2023-04-19 22:56:53 +09:00
parent 40c38eb9ee
commit 00e45affe9
28 changed files with 420 additions and 319 deletions

View File

@ -15,27 +15,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Docker build (386)
run: |
curl --location --remote-name https://repo.steampowered.com/steamrt-images-scout/snapshots/latest-public-beta/com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.Dockerfile
curl --location --remote-name https://repo.steampowered.com/steamrt-images-scout/snapshots/latest-public-beta/com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.tar.gz
docker build -f com.valvesoftware.SteamRuntime.Sdk-i386-scout-sysroot.Dockerfile -t steamrt_scout_i386:latest .
- name: Docker build (amd64)
run: |
curl --location --remote-name https://repo.steampowered.com/steamrt-images-scout/snapshots/latest-public-beta/com.valvesoftware.SteamRuntime.Sdk-amd64,i386-scout-sysroot.Dockerfile
curl --location --remote-name https://repo.steampowered.com/steamrt-images-scout/snapshots/latest-public-beta/com.valvesoftware.SteamRuntime.Sdk-amd64,i386-scout-sysroot.tar.gz
docker build -f com.valvesoftware.SteamRuntime.Sdk-amd64,i386-scout-sysroot.Dockerfile -t steamrt_scout_amd64:latest .
curl --location --remote-name https://repo.steampowered.com/steamrt-images-sniper/snapshots/latest-container-runtime-public-beta/com.valvesoftware.SteamRuntime.Sdk-amd64,i386-sniper-sysroot.Dockerfile
curl --location --remote-name https://repo.steampowered.com/steamrt-images-sniper/snapshots/latest-container-runtime-public-beta/com.valvesoftware.SteamRuntime.Sdk-amd64,i386-sniper-sysroot.tar.gz
docker build -f com.valvesoftware.SteamRuntime.Sdk-amd64,i386-sniper-sysroot.Dockerfile -t steamrt_sniper_amd64:latest .
- name: Go version
id: go
run: |
echo "::set-output name=version::$(curl --location https://go.dev/VERSION?m=text)"
- name: Docker run (386)
run: |
docker run --rm --workdir=/work --volume $(pwd):/work --env GO_FILENAME=${{ steps.go.outputs.version }}.linux-386.tar.gz steamrt_scout_i386:latest /bin/sh .github/workflows/steam.sh
- name: Docker run (amd64)
run: |
docker run --rm --workdir=/work --volume $(pwd):/work --env GO_FILENAME=${{ steps.go.outputs.version }}.linux-amd64.tar.gz steamrt_scout_amd64:latest /bin/sh .github/workflows/steam.sh
docker run --rm --workdir=/work --volume $(pwd):/work --env GO_FILENAME=${{ steps.go.outputs.version }}.linux-amd64.tar.gz steamrt_sniper_amd64:latest /bin/sh .github/workflows/steam.sh

View File

@ -59,20 +59,22 @@ const (
)
const (
AutoIconify = Hint(0x00020006)
ClientAPI = Hint(0x00022001)
ContextCreationAPI = Hint(0x0002200B)
ContextVersionMajor = Hint(0x00022002)
ContextVersionMinor = Hint(0x00022003)
Decorated = Hint(0x00020005)
Floating = Hint(0x00020007)
Focused = Hint(0x00020001)
FocusOnShow = Hint(0x0002000C)
Iconified = Hint(0x00020002)
Maximized = Hint(0x00020008)
Resizable = Hint(0x00020003)
TransparentFramebuffer = Hint(0x0002000A)
Visible = Hint(0x00020004)
AutoIconify = Hint(0x00020006)
ClientAPI = Hint(0x00022001)
ContextCreationAPI = Hint(0x0002200B)
ContextVersionMajor = Hint(0x00022002)
ContextVersionMinor = Hint(0x00022003)
Decorated = Hint(0x00020005)
Floating = Hint(0x00020007)
Focused = Hint(0x00020001)
FocusOnShow = Hint(0x0002000C)
Iconified = Hint(0x00020002)
Maximized = Hint(0x00020008)
OpenGLForwardCompatible = Hint(0x00022006)
OpenGLProfile = Hint(0x00022008)
Resizable = Hint(0x00020003)
TransparentFramebuffer = Hint(0x0002000A)
Visible = Hint(0x00020004)
)
const (
@ -82,13 +84,14 @@ const (
)
const (
CursorDisabled = 0x00034003
CursorHidden = 0x00034002
CursorNormal = 0x00034001
EGLContextAPI = 0x00036002
NoAPI = 0
OpenGLAPI = 0x00030001
OpenGLESAPI = 0x00030002
CursorDisabled = 0x00034003
CursorHidden = 0x00034002
CursorNormal = 0x00034001
EGLContextAPI = 0x00036002
NoAPI = 0
OpenGLAPI = 0x00030001
OpenGLCoreProfile = 0x00032001
OpenGLESAPI = 0x00030002
)
const (

View File

@ -81,6 +81,14 @@ func (d *DebugContext) BindTexture(arg0 uint32, arg1 uint32) {
}
}
func (d *DebugContext) BindVertexArray(arg0 uint32) {
d.Context.BindVertexArray(arg0)
fmt.Fprintln(os.Stderr, "BindVertexArray")
if e := d.Context.GetError(); e != NO_ERROR {
panic(fmt.Sprintf("gl: GetError() returned %d at BindVertexArray", e))
}
}
func (d *DebugContext) BlendEquationSeparate(arg0 uint32, arg1 uint32) {
d.Context.BlendEquationSeparate(arg0, arg1)
fmt.Fprintln(os.Stderr, "BlendEquationSeparate")
@ -200,6 +208,15 @@ func (d *DebugContext) CreateTexture() uint32 {
return out0
}
func (d *DebugContext) CreateVertexArray() uint32 {
out0 := d.Context.CreateVertexArray()
fmt.Fprintln(os.Stderr, "CreateVertexArray")
if e := d.Context.GetError(); e != NO_ERROR {
panic(fmt.Sprintf("gl: GetError() returned %d at CreateVertexArray", e))
}
return out0
}
func (d *DebugContext) DeleteBuffer(arg0 uint32) {
d.Context.DeleteBuffer(arg0)
fmt.Fprintln(os.Stderr, "DeleteBuffer")
@ -248,6 +265,14 @@ func (d *DebugContext) DeleteTexture(arg0 uint32) {
}
}
func (d *DebugContext) DeleteVertexArray(arg0 uint32) {
d.Context.DeleteVertexArray(arg0)
fmt.Fprintln(os.Stderr, "DeleteVertexArray")
if e := d.Context.GetError(); e != NO_ERROR {
panic(fmt.Sprintf("gl: GetError() returned %d at DeleteVertexArray", e))
}
}
func (d *DebugContext) Disable(arg0 uint32) {
d.Context.Disable(arg0)
fmt.Fprintln(os.Stderr, "Disable")

View File

@ -35,11 +35,11 @@ package gl
// typedef void (*fn)(GLenum target, GLuint buffer);
// ((fn)(fnptr))(target, buffer);
// }
// static void glowBindFramebufferEXT(uintptr_t fnptr, GLenum target, GLuint framebuffer) {
// static void glowBindFramebuffer(uintptr_t fnptr, GLenum target, GLuint framebuffer) {
// typedef void (*fn)(GLenum target, GLuint framebuffer);
// ((fn)(fnptr))(target, framebuffer);
// }
// static void glowBindRenderbufferEXT(uintptr_t fnptr, GLenum target, GLuint renderbuffer) {
// static void glowBindRenderbuffer(uintptr_t fnptr, GLenum target, GLuint renderbuffer) {
// typedef void (*fn)(GLenum target, GLuint renderbuffer);
// ((fn)(fnptr))(target, renderbuffer);
// }
@ -47,6 +47,10 @@ package gl
// typedef void (*fn)(GLenum target, GLuint texture);
// ((fn)(fnptr))(target, texture);
// }
// static void glowBindVertexArray(uintptr_t fnptr, GLuint array) {
// typedef void (*fn)(GLuint array);
// ((fn)(fnptr))(array);
// }
// static void glowBlendEquationSeparate(uintptr_t fnptr, GLenum modeRGB, GLenum modeAlpha) {
// typedef void (*fn)(GLenum modeRGB, GLenum modeAlpha);
// ((fn)(fnptr))(modeRGB, modeAlpha);
@ -63,7 +67,7 @@ package gl
// typedef void (*fn)(GLenum target, GLintptr offset, GLsizeiptr size, const void* data);
// ((fn)(fnptr))(target, offset, size, data);
// }
// static GLenum glowCheckFramebufferStatusEXT(uintptr_t fnptr, GLenum target) {
// static GLenum glowCheckFramebufferStatus(uintptr_t fnptr, GLenum target) {
// typedef GLenum (*fn)(GLenum target);
// return ((fn)(fnptr))(target);
// }
@ -91,7 +95,7 @@ package gl
// typedef void (*fn)(GLsizei n, const GLuint* buffers);
// ((fn)(fnptr))(n, buffers);
// }
// static void glowDeleteFramebuffersEXT(uintptr_t fnptr, GLsizei n, const GLuint* framebuffers) {
// static void glowDeleteFramebuffers(uintptr_t fnptr, GLsizei n, const GLuint* framebuffers) {
// typedef void (*fn)(GLsizei n, const GLuint* framebuffers);
// ((fn)(fnptr))(n, framebuffers);
// }
@ -99,7 +103,7 @@ package gl
// typedef void (*fn)(GLuint program);
// ((fn)(fnptr))(program);
// }
// static void glowDeleteRenderbuffersEXT(uintptr_t fnptr, GLsizei n, const GLuint* renderbuffers) {
// static void glowDeleteRenderbuffers(uintptr_t fnptr, GLsizei n, const GLuint* renderbuffers) {
// typedef void (*fn)(GLsizei n, const GLuint* renderbuffers);
// ((fn)(fnptr))(n, renderbuffers);
// }
@ -111,6 +115,10 @@ package gl
// typedef void (*fn)(GLsizei n, const GLuint* textures);
// ((fn)(fnptr))(n, textures);
// }
// static void glowDeleteVertexArrays(uintptr_t fnptr, GLsizei n, const GLuint* arrays) {
// typedef void (*fn)(GLsizei n, const GLuint* arrays);
// ((fn)(fnptr))(n, arrays);
// }
// static void glowDisable(uintptr_t fnptr, GLenum cap) {
// typedef void (*fn)(GLenum cap);
// ((fn)(fnptr))(cap);
@ -135,11 +143,11 @@ package gl
// typedef void (*fn)();
// ((fn)(fnptr))();
// }
// static void glowFramebufferRenderbufferEXT(uintptr_t fnptr, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) {
// static void glowFramebufferRenderbuffer(uintptr_t fnptr, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) {
// typedef void (*fn)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer);
// ((fn)(fnptr))(target, attachment, renderbuffertarget, renderbuffer);
// }
// static void glowFramebufferTexture2DEXT(uintptr_t fnptr, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
// static void glowFramebufferTexture2D(uintptr_t fnptr, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) {
// typedef void (*fn)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level);
// ((fn)(fnptr))(target, attachment, textarget, texture, level);
// }
@ -147,11 +155,11 @@ package gl
// typedef void (*fn)(GLsizei n, GLuint* buffers);
// ((fn)(fnptr))(n, buffers);
// }
// static void glowGenFramebuffersEXT(uintptr_t fnptr, GLsizei n, GLuint* framebuffers) {
// static void glowGenFramebuffers(uintptr_t fnptr, GLsizei n, GLuint* framebuffers) {
// typedef void (*fn)(GLsizei n, GLuint* framebuffers);
// ((fn)(fnptr))(n, framebuffers);
// }
// static void glowGenRenderbuffersEXT(uintptr_t fnptr, GLsizei n, GLuint* renderbuffers) {
// static void glowGenRenderbuffers(uintptr_t fnptr, GLsizei n, GLuint* renderbuffers) {
// typedef void (*fn)(GLsizei n, GLuint* renderbuffers);
// ((fn)(fnptr))(n, renderbuffers);
// }
@ -159,6 +167,10 @@ package gl
// typedef void (*fn)(GLsizei n, GLuint* textures);
// ((fn)(fnptr))(n, textures);
// }
// static void glowGenVertexArrays(uintptr_t fnptr, GLsizei n, GLuint* arrays) {
// typedef void (*fn)(GLsizei n, GLuint* arrays);
// ((fn)(fnptr))(n, arrays);
// }
// static GLenum glowGetError(uintptr_t fnptr) {
// typedef GLenum (*fn)();
// return ((fn)(fnptr))();
@ -187,7 +199,7 @@ package gl
// typedef GLint (*fn)(GLuint program, const GLchar* name);
// return ((fn)(fnptr))(program, name);
// }
// static GLboolean glowIsFramebufferEXT(uintptr_t fnptr, GLuint framebuffer) {
// static GLboolean glowIsFramebuffer(uintptr_t fnptr, GLuint framebuffer) {
// typedef GLboolean (*fn)(GLuint framebuffer);
// return ((fn)(fnptr))(framebuffer);
// }
@ -195,7 +207,7 @@ package gl
// typedef GLboolean (*fn)(GLuint program);
// return ((fn)(fnptr))(program);
// }
// static GLboolean glowIsRenderbufferEXT(uintptr_t fnptr, GLuint renderbuffer) {
// static GLboolean glowIsRenderbuffer(uintptr_t fnptr, GLuint renderbuffer) {
// typedef GLboolean (*fn)(GLuint renderbuffer);
// return ((fn)(fnptr))(renderbuffer);
// }
@ -215,7 +227,7 @@ package gl
// typedef void (*fn)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void* pixels);
// ((fn)(fnptr))(x, y, width, height, format, type, pixels);
// }
// static void glowRenderbufferStorageEXT(uintptr_t fnptr, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
// static void glowRenderbufferStorage(uintptr_t fnptr, GLenum target, GLenum internalformat, GLsizei width, GLsizei height) {
// typedef void (*fn)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height);
// ((fn)(fnptr))(target, internalformat, width, height);
// }
@ -315,78 +327,81 @@ import (
)
type defaultContext struct {
gpActiveTexture C.uintptr_t
gpAttachShader C.uintptr_t
gpBindAttribLocation C.uintptr_t
gpBindBuffer C.uintptr_t
gpBindFramebufferEXT C.uintptr_t
gpBindRenderbufferEXT C.uintptr_t
gpBindTexture C.uintptr_t
gpBlendEquationSeparate C.uintptr_t
gpBlendFuncSeparate C.uintptr_t
gpBufferData C.uintptr_t
gpBufferSubData C.uintptr_t
gpCheckFramebufferStatusEXT C.uintptr_t
gpClear C.uintptr_t
gpColorMask C.uintptr_t
gpCompileShader C.uintptr_t
gpCreateProgram C.uintptr_t
gpCreateShader C.uintptr_t
gpDeleteBuffers C.uintptr_t
gpDeleteFramebuffersEXT C.uintptr_t
gpDeleteProgram C.uintptr_t
gpDeleteRenderbuffersEXT C.uintptr_t
gpDeleteShader C.uintptr_t
gpDeleteTextures C.uintptr_t
gpDisable C.uintptr_t
gpDisableVertexAttribArray C.uintptr_t
gpDrawElements C.uintptr_t
gpEnable C.uintptr_t
gpEnableVertexAttribArray C.uintptr_t
gpFlush C.uintptr_t
gpFramebufferRenderbufferEXT C.uintptr_t
gpFramebufferTexture2DEXT C.uintptr_t
gpGenBuffers C.uintptr_t
gpGenFramebuffersEXT C.uintptr_t
gpGenRenderbuffersEXT C.uintptr_t
gpGenTextures C.uintptr_t
gpGetError C.uintptr_t
gpGetIntegerv C.uintptr_t
gpGetProgramInfoLog C.uintptr_t
gpGetProgramiv C.uintptr_t
gpGetShaderInfoLog C.uintptr_t
gpGetShaderiv C.uintptr_t
gpGetUniformLocation C.uintptr_t
gpIsFramebufferEXT C.uintptr_t
gpIsProgram C.uintptr_t
gpIsRenderbufferEXT C.uintptr_t
gpIsTexture C.uintptr_t
gpLinkProgram C.uintptr_t
gpPixelStorei C.uintptr_t
gpReadPixels C.uintptr_t
gpRenderbufferStorageEXT C.uintptr_t
gpScissor C.uintptr_t
gpShaderSource C.uintptr_t
gpStencilFunc C.uintptr_t
gpStencilOp C.uintptr_t
gpTexImage2D C.uintptr_t
gpTexParameteri C.uintptr_t
gpTexSubImage2D C.uintptr_t
gpUniform1fv C.uintptr_t
gpUniform1i C.uintptr_t
gpUniform1iv C.uintptr_t
gpUniform2fv C.uintptr_t
gpUniform2iv C.uintptr_t
gpUniform3fv C.uintptr_t
gpUniform3iv C.uintptr_t
gpUniform4fv C.uintptr_t
gpUniform4iv C.uintptr_t
gpUniformMatrix2fv C.uintptr_t
gpUniformMatrix3fv C.uintptr_t
gpUniformMatrix4fv C.uintptr_t
gpUseProgram C.uintptr_t
gpVertexAttribPointer C.uintptr_t
gpViewport C.uintptr_t
gpActiveTexture C.uintptr_t
gpAttachShader C.uintptr_t
gpBindAttribLocation C.uintptr_t
gpBindBuffer C.uintptr_t
gpBindFramebuffer C.uintptr_t
gpBindRenderbuffer C.uintptr_t
gpBindTexture C.uintptr_t
gpBindVertexArray C.uintptr_t
gpBlendEquationSeparate C.uintptr_t
gpBlendFuncSeparate C.uintptr_t
gpBufferData C.uintptr_t
gpBufferSubData C.uintptr_t
gpCheckFramebufferStatus C.uintptr_t
gpClear C.uintptr_t
gpColorMask C.uintptr_t
gpCompileShader C.uintptr_t
gpCreateProgram C.uintptr_t
gpCreateShader C.uintptr_t
gpDeleteBuffers C.uintptr_t
gpDeleteFramebuffers C.uintptr_t
gpDeleteProgram C.uintptr_t
gpDeleteRenderbuffers C.uintptr_t
gpDeleteShader C.uintptr_t
gpDeleteTextures C.uintptr_t
gpDeleteVertexArrays C.uintptr_t
gpDisable C.uintptr_t
gpDisableVertexAttribArray C.uintptr_t
gpDrawElements C.uintptr_t
gpEnable C.uintptr_t
gpEnableVertexAttribArray C.uintptr_t
gpFlush C.uintptr_t
gpFramebufferRenderbuffer C.uintptr_t
gpFramebufferTexture2D C.uintptr_t
gpGenBuffers C.uintptr_t
gpGenFramebuffers C.uintptr_t
gpGenRenderbuffers C.uintptr_t
gpGenTextures C.uintptr_t
gpGenVertexArrays C.uintptr_t
gpGetError C.uintptr_t
gpGetIntegerv C.uintptr_t
gpGetProgramInfoLog C.uintptr_t
gpGetProgramiv C.uintptr_t
gpGetShaderInfoLog C.uintptr_t
gpGetShaderiv C.uintptr_t
gpGetUniformLocation C.uintptr_t
gpIsFramebuffer C.uintptr_t
gpIsProgram C.uintptr_t
gpIsRenderbuffer C.uintptr_t
gpIsTexture C.uintptr_t
gpLinkProgram C.uintptr_t
gpPixelStorei C.uintptr_t
gpReadPixels C.uintptr_t
gpRenderbufferStorage C.uintptr_t
gpScissor C.uintptr_t
gpShaderSource C.uintptr_t
gpStencilFunc C.uintptr_t
gpStencilOp C.uintptr_t
gpTexImage2D C.uintptr_t
gpTexParameteri C.uintptr_t
gpTexSubImage2D C.uintptr_t
gpUniform1fv C.uintptr_t
gpUniform1i C.uintptr_t
gpUniform1iv C.uintptr_t
gpUniform2fv C.uintptr_t
gpUniform2iv C.uintptr_t
gpUniform3fv C.uintptr_t
gpUniform3iv C.uintptr_t
gpUniform4fv C.uintptr_t
gpUniform4iv C.uintptr_t
gpUniformMatrix2fv C.uintptr_t
gpUniformMatrix3fv C.uintptr_t
gpUniformMatrix4fv C.uintptr_t
gpUseProgram C.uintptr_t
gpVertexAttribPointer C.uintptr_t
gpViewport C.uintptr_t
isES bool
}
@ -429,17 +444,21 @@ func (c *defaultContext) BindBuffer(target uint32, buffer uint32) {
}
func (c *defaultContext) BindFramebuffer(target uint32, framebuffer uint32) {
C.glowBindFramebufferEXT(c.gpBindFramebufferEXT, C.GLenum(target), C.GLuint(framebuffer))
C.glowBindFramebuffer(c.gpBindFramebuffer, C.GLenum(target), C.GLuint(framebuffer))
}
func (c *defaultContext) BindRenderbuffer(target uint32, renderbuffer uint32) {
C.glowBindRenderbufferEXT(c.gpBindRenderbufferEXT, C.GLenum(target), C.GLuint(renderbuffer))
C.glowBindRenderbuffer(c.gpBindRenderbuffer, C.GLenum(target), C.GLuint(renderbuffer))
}
func (c *defaultContext) BindTexture(target uint32, texture uint32) {
C.glowBindTexture(c.gpBindTexture, C.GLenum(target), C.GLuint(texture))
}
func (c *defaultContext) BindVertexArray(array uint32) {
C.glowBindVertexArray(c.gpBindVertexArray, C.GLuint(array))
}
func (c *defaultContext) BlendEquationSeparate(modeRGB uint32, modeAlpha uint32) {
C.glowBlendEquationSeparate(c.gpBlendEquationSeparate, C.GLenum(modeRGB), C.GLenum(modeAlpha))
}
@ -458,7 +477,7 @@ func (c *defaultContext) BufferSubData(target uint32, offset int, data []byte) {
}
func (c *defaultContext) CheckFramebufferStatus(target uint32) uint32 {
ret := C.glowCheckFramebufferStatusEXT(c.gpCheckFramebufferStatusEXT, C.GLenum(target))
ret := C.glowCheckFramebufferStatus(c.gpCheckFramebufferStatus, C.GLenum(target))
return uint32(ret)
}
@ -482,7 +501,7 @@ func (c *defaultContext) CreateBuffer() uint32 {
func (c *defaultContext) CreateFramebuffer() uint32 {
var framebuffer uint32
C.glowGenFramebuffersEXT(c.gpGenFramebuffersEXT, 1, (*C.GLuint)(unsafe.Pointer(&framebuffer)))
C.glowGenFramebuffers(c.gpGenFramebuffers, 1, (*C.GLuint)(unsafe.Pointer(&framebuffer)))
return framebuffer
}
@ -493,7 +512,7 @@ func (c *defaultContext) CreateProgram() uint32 {
func (c *defaultContext) CreateRenderbuffer() uint32 {
var renderbuffer uint32
C.glowGenRenderbuffersEXT(c.gpGenRenderbuffersEXT, 1, (*C.GLuint)(unsafe.Pointer(&renderbuffer)))
C.glowGenRenderbuffers(c.gpGenRenderbuffers, 1, (*C.GLuint)(unsafe.Pointer(&renderbuffer)))
return renderbuffer
}
@ -508,12 +527,18 @@ func (c *defaultContext) CreateTexture() uint32 {
return texture
}
func (c *defaultContext) CreateVertexArray() uint32 {
var array uint32
C.glowGenVertexArrays(c.gpGenVertexArrays, 1, (*C.GLuint)(unsafe.Pointer(&array)))
return array
}
func (c *defaultContext) DeleteBuffer(buffer uint32) {
C.glowDeleteBuffers(c.gpDeleteBuffers, 1, (*C.GLuint)(unsafe.Pointer(&buffer)))
}
func (c *defaultContext) DeleteFramebuffer(framebuffer uint32) {
C.glowDeleteFramebuffersEXT(c.gpDeleteFramebuffersEXT, 1, (*C.GLuint)(unsafe.Pointer(&framebuffer)))
C.glowDeleteFramebuffers(c.gpDeleteFramebuffers, 1, (*C.GLuint)(unsafe.Pointer(&framebuffer)))
}
func (c *defaultContext) DeleteProgram(program uint32) {
@ -521,7 +546,7 @@ func (c *defaultContext) DeleteProgram(program uint32) {
}
func (c *defaultContext) DeleteRenderbuffer(renderbuffer uint32) {
C.glowDeleteRenderbuffersEXT(c.gpDeleteRenderbuffersEXT, 1, (*C.GLuint)(unsafe.Pointer(&renderbuffer)))
C.glowDeleteRenderbuffers(c.gpDeleteRenderbuffers, 1, (*C.GLuint)(unsafe.Pointer(&renderbuffer)))
}
func (c *defaultContext) DeleteShader(shader uint32) {
@ -532,6 +557,10 @@ func (c *defaultContext) DeleteTexture(texture uint32) {
C.glowDeleteTextures(c.gpDeleteTextures, 1, (*C.GLuint)(unsafe.Pointer(&texture)))
}
func (c *defaultContext) DeleteVertexArray(array uint32) {
C.glowDeleteVertexArrays(c.gpDeleteVertexArrays, 1, (*C.GLuint)(unsafe.Pointer(&array)))
}
func (c *defaultContext) Disable(cap uint32) {
C.glowDisable(c.gpDisable, C.GLenum(cap))
}
@ -557,11 +586,11 @@ func (c *defaultContext) Flush() {
}
func (c *defaultContext) FramebufferRenderbuffer(target uint32, attachment uint32, renderbuffertarget uint32, renderbuffer uint32) {
C.glowFramebufferRenderbufferEXT(c.gpFramebufferRenderbufferEXT, C.GLenum(target), C.GLenum(attachment), C.GLenum(renderbuffertarget), C.GLuint(renderbuffer))
C.glowFramebufferRenderbuffer(c.gpFramebufferRenderbuffer, C.GLenum(target), C.GLenum(attachment), C.GLenum(renderbuffertarget), C.GLuint(renderbuffer))
}
func (c *defaultContext) FramebufferTexture2D(target uint32, attachment uint32, textarget uint32, texture uint32, level int32) {
C.glowFramebufferTexture2DEXT(c.gpFramebufferTexture2DEXT, C.GLenum(target), C.GLenum(attachment), C.GLenum(textarget), C.GLuint(texture), C.GLint(level))
C.glowFramebufferTexture2D(c.gpFramebufferTexture2D, C.GLenum(target), C.GLenum(attachment), C.GLenum(textarget), C.GLuint(texture), C.GLint(level))
}
func (c *defaultContext) GetError() uint32 {
@ -609,7 +638,7 @@ func (c *defaultContext) GetUniformLocation(program uint32, name string) int32 {
}
func (c *defaultContext) IsFramebuffer(framebuffer uint32) bool {
ret := C.glowIsFramebufferEXT(c.gpIsFramebufferEXT, C.GLuint(framebuffer))
ret := C.glowIsFramebuffer(c.gpIsFramebuffer, C.GLuint(framebuffer))
return ret == TRUE
}
@ -619,7 +648,7 @@ func (c *defaultContext) IsProgram(program uint32) bool {
}
func (c *defaultContext) IsRenderbuffer(renderbuffer uint32) bool {
ret := C.glowIsRenderbufferEXT(c.gpIsRenderbufferEXT, C.GLuint(renderbuffer))
ret := C.glowIsRenderbuffer(c.gpIsRenderbuffer, C.GLuint(renderbuffer))
return ret == TRUE
}
@ -641,7 +670,7 @@ func (c *defaultContext) ReadPixels(dst []byte, x int32, y int32, width int32, h
}
func (c *defaultContext) RenderbufferStorage(target uint32, internalformat uint32, width int32, height int32) {
C.glowRenderbufferStorageEXT(c.gpRenderbufferStorageEXT, C.GLenum(target), C.GLenum(internalformat), C.GLsizei(width), C.GLsizei(height))
C.glowRenderbufferStorage(c.gpRenderbufferStorage, C.GLenum(target), C.GLenum(internalformat), C.GLsizei(width), C.GLsizei(height))
}
func (c *defaultContext) Scissor(x int32, y int32, width int32, height int32) {
@ -758,37 +787,40 @@ func (c *defaultContext) LoadFunctions() error {
c.gpAttachShader = C.uintptr_t(g.get("glAttachShader"))
c.gpBindAttribLocation = C.uintptr_t(g.get("glBindAttribLocation"))
c.gpBindBuffer = C.uintptr_t(g.get("glBindBuffer"))
c.gpBindFramebufferEXT = C.uintptr_t(g.get("glBindFramebufferEXT"))
c.gpBindRenderbufferEXT = C.uintptr_t(g.get("glBindRenderbufferEXT"))
c.gpBindFramebuffer = C.uintptr_t(g.get("glBindFramebuffer"))
c.gpBindRenderbuffer = C.uintptr_t(g.get("glBindRenderbuffer"))
c.gpBindTexture = C.uintptr_t(g.get("glBindTexture"))
c.gpBindVertexArray = C.uintptr_t(g.get("glBindVertexArray"))
c.gpBlendEquationSeparate = C.uintptr_t(g.get("glBlendEquationSeparate"))
c.gpBlendFuncSeparate = C.uintptr_t(g.get("glBlendFuncSeparate"))
c.gpBufferData = C.uintptr_t(g.get("glBufferData"))
c.gpBufferSubData = C.uintptr_t(g.get("glBufferSubData"))
c.gpCheckFramebufferStatusEXT = C.uintptr_t(g.get("glCheckFramebufferStatusEXT"))
c.gpCheckFramebufferStatus = C.uintptr_t(g.get("glCheckFramebufferStatus"))
c.gpClear = C.uintptr_t(g.get("glClear"))
c.gpColorMask = C.uintptr_t(g.get("glColorMask"))
c.gpCompileShader = C.uintptr_t(g.get("glCompileShader"))
c.gpCreateProgram = C.uintptr_t(g.get("glCreateProgram"))
c.gpCreateShader = C.uintptr_t(g.get("glCreateShader"))
c.gpDeleteBuffers = C.uintptr_t(g.get("glDeleteBuffers"))
c.gpDeleteFramebuffersEXT = C.uintptr_t(g.get("glDeleteFramebuffersEXT"))
c.gpDeleteFramebuffers = C.uintptr_t(g.get("glDeleteFramebuffers"))
c.gpDeleteProgram = C.uintptr_t(g.get("glDeleteProgram"))
c.gpDeleteRenderbuffersEXT = C.uintptr_t(g.get("glDeleteRenderbuffersEXT"))
c.gpDeleteRenderbuffers = C.uintptr_t(g.get("glDeleteRenderbuffers"))
c.gpDeleteShader = C.uintptr_t(g.get("glDeleteShader"))
c.gpDeleteTextures = C.uintptr_t(g.get("glDeleteTextures"))
c.gpDeleteVertexArrays = C.uintptr_t(g.get("glDeleteVertexArrays"))
c.gpDisable = C.uintptr_t(g.get("glDisable"))
c.gpDisableVertexAttribArray = C.uintptr_t(g.get("glDisableVertexAttribArray"))
c.gpDrawElements = C.uintptr_t(g.get("glDrawElements"))
c.gpEnable = C.uintptr_t(g.get("glEnable"))
c.gpEnableVertexAttribArray = C.uintptr_t(g.get("glEnableVertexAttribArray"))
c.gpFlush = C.uintptr_t(g.get("glFlush"))
c.gpFramebufferRenderbufferEXT = C.uintptr_t(g.get("glFramebufferRenderbufferEXT"))
c.gpFramebufferTexture2DEXT = C.uintptr_t(g.get("glFramebufferTexture2DEXT"))
c.gpFramebufferRenderbuffer = C.uintptr_t(g.get("glFramebufferRenderbuffer"))
c.gpFramebufferTexture2D = C.uintptr_t(g.get("glFramebufferTexture2D"))
c.gpGenBuffers = C.uintptr_t(g.get("glGenBuffers"))
c.gpGenFramebuffersEXT = C.uintptr_t(g.get("glGenFramebuffersEXT"))
c.gpGenRenderbuffersEXT = C.uintptr_t(g.get("glGenRenderbuffersEXT"))
c.gpGenFramebuffers = C.uintptr_t(g.get("glGenFramebuffers"))
c.gpGenRenderbuffers = C.uintptr_t(g.get("glGenRenderbuffers"))
c.gpGenTextures = C.uintptr_t(g.get("glGenTextures"))
c.gpGenVertexArrays = C.uintptr_t(g.get("glGenVertexArrays"))
c.gpGetError = C.uintptr_t(g.get("glGetError"))
c.gpGetIntegerv = C.uintptr_t(g.get("glGetIntegerv"))
c.gpGetProgramInfoLog = C.uintptr_t(g.get("glGetProgramInfoLog"))
@ -796,14 +828,14 @@ func (c *defaultContext) LoadFunctions() error {
c.gpGetShaderInfoLog = C.uintptr_t(g.get("glGetShaderInfoLog"))
c.gpGetShaderiv = C.uintptr_t(g.get("glGetShaderiv"))
c.gpGetUniformLocation = C.uintptr_t(g.get("glGetUniformLocation"))
c.gpIsFramebufferEXT = C.uintptr_t(g.get("glIsFramebufferEXT"))
c.gpIsFramebuffer = C.uintptr_t(g.get("glIsFramebuffer"))
c.gpIsProgram = C.uintptr_t(g.get("glIsProgram"))
c.gpIsRenderbufferEXT = C.uintptr_t(g.get("glIsRenderbufferEXT"))
c.gpIsRenderbuffer = C.uintptr_t(g.get("glIsRenderbuffer"))
c.gpIsTexture = C.uintptr_t(g.get("glIsTexture"))
c.gpLinkProgram = C.uintptr_t(g.get("glLinkProgram"))
c.gpPixelStorei = C.uintptr_t(g.get("glPixelStorei"))
c.gpReadPixels = C.uintptr_t(g.get("glReadPixels"))
c.gpRenderbufferStorageEXT = C.uintptr_t(g.get("glRenderbufferStorageEXT"))
c.gpRenderbufferStorage = C.uintptr_t(g.get("glRenderbufferStorage"))
c.gpScissor = C.uintptr_t(g.get("glScissor"))
c.gpShaderSource = C.uintptr_t(g.get("glShaderSource"))
c.gpStencilFunc = C.uintptr_t(g.get("glStencilFunc"))

View File

@ -29,6 +29,7 @@ type defaultContext struct {
fnBindFramebuffer js.Value
fnBindRenderbuffer js.Value
fnBindTexture js.Value
fnBindVertexArray js.Value
fnBlendEquationSeparate js.Value
fnBlendFuncSeparate js.Value
fnBufferData js.Value
@ -43,12 +44,14 @@ type defaultContext struct {
fnCreateRenderbuffer js.Value
fnCreateShader js.Value
fnCreateTexture js.Value
fnCreateVertexArray js.Value
fnDeleteBuffer js.Value
fnDeleteFramebuffer js.Value
fnDeleteProgram js.Value
fnDeleteRenderbuffer js.Value
fnDeleteShader js.Value
fnDeleteTexture js.Value
fnDeleteVertexArray js.Value
fnDisable js.Value
fnDisableVertexAttribArray js.Value
fnDrawElements js.Value
@ -102,6 +105,7 @@ type defaultContext struct {
renderbuffers values
shaders values
textures values
vertexArrays values
uniformLocations map[uint32]*values
}
@ -156,6 +160,7 @@ func NewDefaultContext(v js.Value) (Context, error) {
fnBindFramebuffer: v.Get("bindFramebuffer").Call("bind", v),
fnBindRenderbuffer: v.Get("bindRenderbuffer").Call("bind", v),
fnBindTexture: v.Get("bindTexture").Call("bind", v),
fnBindVertexArray: v.Get("bindVertexArray").Call("bind", v),
fnBlendEquationSeparate: v.Get("blendEquationSeparate").Call("bind", v),
fnBlendFuncSeparate: v.Get("blendFuncSeparate").Call("bind", v),
fnBufferData: v.Get("bufferData").Call("bind", v),
@ -170,12 +175,14 @@ func NewDefaultContext(v js.Value) (Context, error) {
fnCreateRenderbuffer: v.Get("createRenderbuffer").Call("bind", v),
fnCreateShader: v.Get("createShader").Call("bind", v),
fnCreateTexture: v.Get("createTexture").Call("bind", v),
fnCreateVertexArray: v.Get("createVertexArray").Call("bind", v),
fnDeleteBuffer: v.Get("deleteBuffer").Call("bind", v),
fnDeleteFramebuffer: v.Get("deleteFramebuffer").Call("bind", v),
fnDeleteProgram: v.Get("deleteProgram").Call("bind", v),
fnDeleteRenderbuffer: v.Get("deleteRenderbuffer").Call("bind", v),
fnDeleteShader: v.Get("deleteShader").Call("bind", v),
fnDeleteTexture: v.Get("deleteTexture").Call("bind", v),
fnDeleteVertexArray: v.Get("deleteVertexArray").Call("bind", v),
fnDisable: v.Get("disable").Call("bind", v),
fnDisableVertexAttribArray: v.Get("disableVertexAttribArray").Call("bind", v),
fnDrawElements: v.Get("drawElements").Call("bind", v),
@ -269,6 +276,10 @@ func (c *defaultContext) BindTexture(target uint32, texture uint32) {
c.fnBindTexture.Invoke(target, c.textures.get(texture))
}
func (c *defaultContext) BindVertexArray(array uint32) {
c.fnBindVertexArray.Invoke(c.vertexArrays.get(array))
}
func (c *defaultContext) BlendEquationSeparate(modeRGB uint32, modeAlpha uint32) {
c.fnBlendEquationSeparate.Invoke(modeRGB, modeAlpha)
}
@ -327,6 +338,10 @@ func (c *defaultContext) CreateTexture() uint32 {
return c.textures.create(c.fnCreateTexture.Invoke())
}
func (c *defaultContext) CreateVertexArray() uint32 {
return c.vertexArrays.create(c.fnCreateVertexArray.Invoke())
}
func (c *defaultContext) DeleteBuffer(buffer uint32) {
c.fnDeleteBuffer.Invoke(c.buffers.get(buffer))
c.buffers.delete(buffer)
@ -358,6 +373,11 @@ func (c *defaultContext) DeleteTexture(texture uint32) {
c.textures.delete(texture)
}
func (c *defaultContext) DeleteVertexArray(array uint32) {
c.fnDeleteVertexArray.Invoke(c.vertexArrays.get(array))
c.textures.delete(array)
}
func (c *defaultContext) Disable(cap uint32) {
c.fnDisable.Invoke(cap)
}

View File

@ -24,78 +24,81 @@ import (
)
type defaultContext struct {
gpActiveTexture uintptr
gpAttachShader uintptr
gpBindAttribLocation uintptr
gpBindBuffer uintptr
gpBindFramebufferEXT uintptr
gpBindRenderbufferEXT uintptr
gpBindTexture uintptr
gpBlendEquationSeparate uintptr
gpBlendFuncSeparate uintptr
gpBufferData uintptr
gpBufferSubData uintptr
gpCheckFramebufferStatusEXT uintptr
gpClear uintptr
gpColorMask uintptr
gpCompileShader uintptr
gpCreateProgram uintptr
gpCreateShader uintptr
gpDeleteBuffers uintptr
gpDeleteFramebuffersEXT uintptr
gpDeleteProgram uintptr
gpDeleteRenderbuffersEXT uintptr
gpDeleteShader uintptr
gpDeleteTextures uintptr
gpDisable uintptr
gpDisableVertexAttribArray uintptr
gpDrawElements uintptr
gpEnable uintptr
gpEnableVertexAttribArray uintptr
gpFlush uintptr
gpFramebufferRenderbufferEXT uintptr
gpFramebufferTexture2DEXT uintptr
gpGenBuffers uintptr
gpGenFramebuffersEXT uintptr
gpGenRenderbuffersEXT uintptr
gpGenTextures uintptr
gpGetError uintptr
gpGetIntegerv uintptr
gpGetProgramInfoLog uintptr
gpGetProgramiv uintptr
gpGetShaderInfoLog uintptr
gpGetShaderiv uintptr
gpGetUniformLocation uintptr
gpIsFramebufferEXT uintptr
gpIsProgram uintptr
gpIsRenderbufferEXT uintptr
gpIsTexture uintptr
gpLinkProgram uintptr
gpPixelStorei uintptr
gpReadPixels uintptr
gpRenderbufferStorageEXT uintptr
gpScissor uintptr
gpShaderSource uintptr
gpStencilFunc uintptr
gpStencilOp uintptr
gpTexImage2D uintptr
gpTexParameteri uintptr
gpTexSubImage2D uintptr
gpUniform1fv uintptr
gpUniform1i uintptr
gpUniform1iv uintptr
gpUniform2fv uintptr
gpUniform2iv uintptr
gpUniform3fv uintptr
gpUniform3iv uintptr
gpUniform4fv uintptr
gpUniform4iv uintptr
gpUniformMatrix2fv uintptr
gpUniformMatrix3fv uintptr
gpUniformMatrix4fv uintptr
gpUseProgram uintptr
gpVertexAttribPointer uintptr
gpViewport uintptr
gpActiveTexture uintptr
gpAttachShader uintptr
gpBindAttribLocation uintptr
gpBindBuffer uintptr
gpBindFramebuffer uintptr
gpBindRenderbuffer uintptr
gpBindTexture uintptr
gpBindVertexArray uintptr
gpBlendEquationSeparate uintptr
gpBlendFuncSeparate uintptr
gpBufferData uintptr
gpBufferSubData uintptr
gpCheckFramebufferStatus uintptr
gpClear uintptr
gpColorMask uintptr
gpCompileShader uintptr
gpCreateProgram uintptr
gpCreateShader uintptr
gpDeleteBuffers uintptr
gpDeleteFramebuffers uintptr
gpDeleteProgram uintptr
gpDeleteRenderbuffers uintptr
gpDeleteShader uintptr
gpDeleteTextures uintptr
gpDeleteVertexArrays uintptr
gpDisable uintptr
gpDisableVertexAttribArray uintptr
gpDrawElements uintptr
gpEnable uintptr
gpEnableVertexAttribArray uintptr
gpFlush uintptr
gpFramebufferRenderbuffer uintptr
gpFramebufferTexture2D uintptr
gpGenBuffers uintptr
gpGenFramebuffers uintptr
gpGenRenderbuffers uintptr
gpGenTextures uintptr
gpGenVertexArrays uintptr
gpGetError uintptr
gpGetIntegerv uintptr
gpGetProgramInfoLog uintptr
gpGetProgramiv uintptr
gpGetShaderInfoLog uintptr
gpGetShaderiv uintptr
gpGetUniformLocation uintptr
gpIsFramebuffer uintptr
gpIsProgram uintptr
gpIsRenderbuffer uintptr
gpIsTexture uintptr
gpLinkProgram uintptr
gpPixelStorei uintptr
gpReadPixels uintptr
gpRenderbufferStorage uintptr
gpScissor uintptr
gpShaderSource uintptr
gpStencilFunc uintptr
gpStencilOp uintptr
gpTexImage2D uintptr
gpTexParameteri uintptr
gpTexSubImage2D uintptr
gpUniform1fv uintptr
gpUniform1i uintptr
gpUniform1iv uintptr
gpUniform2fv uintptr
gpUniform2iv uintptr
gpUniform3fv uintptr
gpUniform3iv uintptr
gpUniform4fv uintptr
gpUniform4iv uintptr
gpUniformMatrix2fv uintptr
gpUniformMatrix3fv uintptr
gpUniformMatrix4fv uintptr
gpUseProgram uintptr
gpVertexAttribPointer uintptr
gpViewport uintptr
isES bool
}
@ -138,17 +141,21 @@ func (c *defaultContext) BindBuffer(target uint32, buffer uint32) {
}
func (c *defaultContext) BindFramebuffer(target uint32, framebuffer uint32) {
purego.SyscallN(c.gpBindFramebufferEXT, uintptr(target), uintptr(framebuffer))
purego.SyscallN(c.gpBindFramebuffer, uintptr(target), uintptr(framebuffer))
}
func (c *defaultContext) BindRenderbuffer(target uint32, renderbuffer uint32) {
purego.SyscallN(c.gpBindRenderbufferEXT, uintptr(target), uintptr(renderbuffer))
purego.SyscallN(c.gpBindRenderbuffer, uintptr(target), uintptr(renderbuffer))
}
func (c *defaultContext) BindTexture(target uint32, texture uint32) {
purego.SyscallN(c.gpBindTexture, uintptr(target), uintptr(texture))
}
func (c *defaultContext) BindVertexArray(array uint32) {
purego.SyscallN(c.gpBindVertexArray, uintptr(array))
}
func (c *defaultContext) BlendEquationSeparate(modeRGB uint32, modeAlpha uint32) {
purego.SyscallN(c.gpBlendEquationSeparate, uintptr(modeRGB), uintptr(modeAlpha))
}
@ -167,7 +174,7 @@ func (c *defaultContext) BufferSubData(target uint32, offset int, data []byte) {
}
func (c *defaultContext) CheckFramebufferStatus(target uint32) uint32 {
ret, _, _ := purego.SyscallN(c.gpCheckFramebufferStatusEXT, uintptr(target))
ret, _, _ := purego.SyscallN(c.gpCheckFramebufferStatus, uintptr(target))
return uint32(ret)
}
@ -191,7 +198,7 @@ func (c *defaultContext) CreateBuffer() uint32 {
func (c *defaultContext) CreateFramebuffer() uint32 {
var framebuffer uint32
purego.SyscallN(c.gpGenFramebuffersEXT, 1, uintptr(unsafe.Pointer(&framebuffer)))
purego.SyscallN(c.gpGenFramebuffers, 1, uintptr(unsafe.Pointer(&framebuffer)))
return framebuffer
}
@ -202,7 +209,7 @@ func (c *defaultContext) CreateProgram() uint32 {
func (c *defaultContext) CreateRenderbuffer() uint32 {
var renderbuffer uint32
purego.SyscallN(c.gpGenRenderbuffersEXT, 1, uintptr(unsafe.Pointer(&renderbuffer)))
purego.SyscallN(c.gpGenRenderbuffers, 1, uintptr(unsafe.Pointer(&renderbuffer)))
return renderbuffer
}
@ -217,12 +224,18 @@ func (c *defaultContext) CreateTexture() uint32 {
return texture
}
func (c *defaultContext) CreateVertexArray() uint32 {
var array uint32
purego.SyscallN(c.gpGenVertexArrays, 1, uintptr(unsafe.Pointer(&array)))
return array
}
func (c *defaultContext) DeleteBuffer(buffer uint32) {
purego.SyscallN(c.gpDeleteBuffers, 1, uintptr(unsafe.Pointer(&buffer)))
}
func (c *defaultContext) DeleteFramebuffer(framebuffer uint32) {
purego.SyscallN(c.gpDeleteFramebuffersEXT, 1, uintptr(unsafe.Pointer(&framebuffer)))
purego.SyscallN(c.gpDeleteFramebuffers, 1, uintptr(unsafe.Pointer(&framebuffer)))
}
func (c *defaultContext) DeleteProgram(program uint32) {
@ -230,7 +243,7 @@ func (c *defaultContext) DeleteProgram(program uint32) {
}
func (c *defaultContext) DeleteRenderbuffer(renderbuffer uint32) {
purego.SyscallN(c.gpDeleteRenderbuffersEXT, 1, uintptr(unsafe.Pointer(&renderbuffer)))
purego.SyscallN(c.gpDeleteRenderbuffers, 1, uintptr(unsafe.Pointer(&renderbuffer)))
}
func (c *defaultContext) DeleteShader(shader uint32) {
@ -241,6 +254,10 @@ func (c *defaultContext) DeleteTexture(texture uint32) {
purego.SyscallN(c.gpDeleteTextures, 1, uintptr(unsafe.Pointer(&texture)))
}
func (c *defaultContext) DeleteVertexArray(array uint32) {
purego.SyscallN(c.gpDeleteVertexArrays, 1, uintptr(unsafe.Pointer(&array)))
}
func (c *defaultContext) Disable(cap uint32) {
purego.SyscallN(c.gpDisable, uintptr(cap))
}
@ -266,11 +283,11 @@ func (c *defaultContext) Flush() {
}
func (c *defaultContext) FramebufferRenderbuffer(target uint32, attachment uint32, renderbuffertarget uint32, renderbuffer uint32) {
purego.SyscallN(c.gpFramebufferRenderbufferEXT, uintptr(target), uintptr(attachment), uintptr(renderbuffertarget), uintptr(renderbuffer))
purego.SyscallN(c.gpFramebufferRenderbuffer, uintptr(target), uintptr(attachment), uintptr(renderbuffertarget), uintptr(renderbuffer))
}
func (c *defaultContext) FramebufferTexture2D(target uint32, attachment uint32, textarget uint32, texture uint32, level int32) {
purego.SyscallN(c.gpFramebufferTexture2DEXT, uintptr(target), uintptr(attachment), uintptr(textarget), uintptr(texture), uintptr(level))
purego.SyscallN(c.gpFramebufferTexture2D, uintptr(target), uintptr(attachment), uintptr(textarget), uintptr(texture), uintptr(level))
}
func (c *defaultContext) GetError() uint32 {
@ -318,7 +335,7 @@ func (c *defaultContext) GetUniformLocation(program uint32, name string) int32 {
}
func (c *defaultContext) IsFramebuffer(framebuffer uint32) bool {
ret, _, _ := purego.SyscallN(c.gpIsFramebufferEXT, uintptr(framebuffer))
ret, _, _ := purego.SyscallN(c.gpIsFramebuffer, uintptr(framebuffer))
return byte(ret) != 0
}
@ -328,7 +345,7 @@ func (c *defaultContext) IsProgram(program uint32) bool {
}
func (c *defaultContext) IsRenderbuffer(renderbuffer uint32) bool {
ret, _, _ := purego.SyscallN(c.gpIsRenderbufferEXT, uintptr(renderbuffer))
ret, _, _ := purego.SyscallN(c.gpIsRenderbuffer, uintptr(renderbuffer))
return byte(ret) != 0
}
@ -350,7 +367,7 @@ func (c *defaultContext) ReadPixels(dst []byte, x int32, y int32, width int32, h
}
func (c *defaultContext) RenderbufferStorage(target uint32, internalformat uint32, width int32, height int32) {
purego.SyscallN(c.gpRenderbufferStorageEXT, uintptr(target), uintptr(internalformat), uintptr(width), uintptr(height))
purego.SyscallN(c.gpRenderbufferStorage, uintptr(target), uintptr(internalformat), uintptr(width), uintptr(height))
}
func (c *defaultContext) Scissor(x int32, y int32, width int32, height int32) {
@ -467,37 +484,40 @@ func (c *defaultContext) LoadFunctions() error {
c.gpAttachShader = g.get("glAttachShader")
c.gpBindAttribLocation = g.get("glBindAttribLocation")
c.gpBindBuffer = g.get("glBindBuffer")
c.gpBindFramebufferEXT = g.get("glBindFramebufferEXT")
c.gpBindRenderbufferEXT = g.get("glBindRenderbufferEXT")
c.gpBindFramebuffer = g.get("glBindFramebuffer")
c.gpBindRenderbuffer = g.get("glBindRenderbuffer")
c.gpBindTexture = g.get("glBindTexture")
c.gpBindVertexArray = g.get("glBindVertexArray")
c.gpBlendEquationSeparate = g.get("glBlendEquationSeparate")
c.gpBlendFuncSeparate = g.get("glBlendFuncSeparate")
c.gpBufferData = g.get("glBufferData")
c.gpBufferSubData = g.get("glBufferSubData")
c.gpCheckFramebufferStatusEXT = g.get("glCheckFramebufferStatusEXT")
c.gpCheckFramebufferStatus = g.get("glCheckFramebufferStatus")
c.gpClear = g.get("glClear")
c.gpColorMask = g.get("glColorMask")
c.gpCompileShader = g.get("glCompileShader")
c.gpCreateProgram = g.get("glCreateProgram")
c.gpCreateShader = g.get("glCreateShader")
c.gpDeleteBuffers = g.get("glDeleteBuffers")
c.gpDeleteFramebuffersEXT = g.get("glDeleteFramebuffersEXT")
c.gpDeleteFramebuffers = g.get("glDeleteFramebuffers")
c.gpDeleteProgram = g.get("glDeleteProgram")
c.gpDeleteRenderbuffersEXT = g.get("glDeleteRenderbuffersEXT")
c.gpDeleteRenderbuffers = g.get("glDeleteRenderbuffers")
c.gpDeleteShader = g.get("glDeleteShader")
c.gpDeleteTextures = g.get("glDeleteTextures")
c.gpDeleteVertexArrays = g.get("glDeleteVertexArrays")
c.gpDisable = g.get("glDisable")
c.gpDisableVertexAttribArray = g.get("glDisableVertexAttribArray")
c.gpDrawElements = g.get("glDrawElements")
c.gpEnable = g.get("glEnable")
c.gpEnableVertexAttribArray = g.get("glEnableVertexAttribArray")
c.gpFlush = g.get("glFlush")
c.gpFramebufferRenderbufferEXT = g.get("glFramebufferRenderbufferEXT")
c.gpFramebufferTexture2DEXT = g.get("glFramebufferTexture2DEXT")
c.gpFramebufferRenderbuffer = g.get("glFramebufferRenderbuffer")
c.gpFramebufferTexture2D = g.get("glFramebufferTexture2D")
c.gpGenBuffers = g.get("glGenBuffers")
c.gpGenFramebuffersEXT = g.get("glGenFramebuffersEXT")
c.gpGenRenderbuffersEXT = g.get("glGenRenderbuffersEXT")
c.gpGenFramebuffers = g.get("glGenFramebuffers")
c.gpGenRenderbuffers = g.get("glGenRenderbuffers")
c.gpGenTextures = g.get("glGenTextures")
c.gpGenVertexArrays = g.get("glGenVertexArrays")
c.gpGetError = g.get("glGetError")
c.gpGetIntegerv = g.get("glGetIntegerv")
c.gpGetProgramInfoLog = g.get("glGetProgramInfoLog")
@ -505,14 +525,14 @@ func (c *defaultContext) LoadFunctions() error {
c.gpGetShaderInfoLog = g.get("glGetShaderInfoLog")
c.gpGetShaderiv = g.get("glGetShaderiv")
c.gpGetUniformLocation = g.get("glGetUniformLocation")
c.gpIsFramebufferEXT = g.get("glIsFramebufferEXT")
c.gpIsFramebuffer = g.get("glIsFramebuffer")
c.gpIsProgram = g.get("glIsProgram")
c.gpIsRenderbufferEXT = g.get("glIsRenderbufferEXT")
c.gpIsRenderbuffer = g.get("glIsRenderbuffer")
c.gpIsTexture = g.get("glIsTexture")
c.gpLinkProgram = g.get("glLinkProgram")
c.gpPixelStorei = g.get("glPixelStorei")
c.gpReadPixels = g.get("glReadPixels")
c.gpRenderbufferStorageEXT = g.get("glRenderbufferStorageEXT")
c.gpRenderbufferStorage = g.get("glRenderbufferStorage")
c.gpScissor = g.get("glScissor")
c.gpShaderSource = g.get("glShaderSource")
c.gpStencilFunc = g.get("glStencilFunc")

View File

@ -71,6 +71,10 @@ func (g *gomobileContext) BindTexture(target uint32, texture uint32) {
g.ctx.BindTexture(gl.Enum(target), gl.Texture{Value: texture})
}
func (g *gomobileContext) BindVertexArray(array uint32) {
g.ctx.BindVertexArray(gl.VertexArray{Value: array})
}
func (g *gomobileContext) BlendEquationSeparate(modeRGB uint32, modeAlpha uint32) {
g.ctx.BlendEquationSeparate(gl.Enum(modeRGB), gl.Enum(modeAlpha))
}
@ -127,6 +131,10 @@ func (g *gomobileContext) CreateTexture() uint32 {
return g.ctx.CreateTexture().Value
}
func (g *gomobileContext) CreateVertexArray() uint32 {
return g.ctx.CreateVertexArray().Value
}
func (g *gomobileContext) DeleteBuffer(buffer uint32) {
g.ctx.DeleteBuffer(gl.Buffer{Value: buffer})
}
@ -151,6 +159,10 @@ func (g *gomobileContext) DeleteTexture(texture uint32) {
g.ctx.DeleteTexture(gl.Texture{Value: texture})
}
func (g *gomobileContext) DeleteVertexArray(texture uint32) {
g.ctx.DeleteVertexArray(gl.VertexArray{Value: texture})
}
func (g *gomobileContext) Disable(cap uint32) {
g.ctx.Disable(gl.Enum(cap))
}

View File

@ -32,6 +32,7 @@ type Context interface {
BindFramebuffer(target uint32, framebuffer uint32)
BindRenderbuffer(target uint32, renderbuffer uint32)
BindTexture(target uint32, texture uint32)
BindVertexArray(array uint32)
BlendEquationSeparate(modeRGB uint32, modeAlpha uint32)
BlendFuncSeparate(srcRGB uint32, dstRGB uint32, srcAlpha uint32, dstAlpha uint32)
BufferInit(target uint32, size int, usage uint32)
@ -46,12 +47,14 @@ type Context interface {
CreateRenderbuffer() uint32
CreateShader(xtype uint32) uint32
CreateTexture() uint32
CreateVertexArray() uint32
DeleteBuffer(buffer uint32)
DeleteFramebuffer(framebuffer uint32)
DeleteProgram(program uint32)
DeleteRenderbuffer(renderbuffer uint32)
DeleteShader(shader uint32)
DeleteTexture(textures uint32)
DeleteTexture(texture uint32)
DeleteVertexArray(array uint32)
Disable(cap uint32)
DisableVertexAttribArray(index uint32)
DrawElements(mode uint32, count int32, xtype uint32, offset int)

View File

@ -16,7 +16,6 @@ package gl
import (
"fmt"
"strings"
"github.com/ebitengine/purego"
)
@ -44,9 +43,6 @@ func (c *defaultContext) init() error {
}
func (c *defaultContext) getProcAddress(name string) (uintptr, error) {
if c.isES {
name = strings.TrimSuffix(name, "EXT")
}
proc, err := purego.Dlsym(opengl, name)
if err != nil {
return 0, err

View File

@ -108,7 +108,6 @@ func getProcAddressGL(name string) uintptr {
}
func getProcAddressGLES(name string) uintptr {
name = strings.TrimSuffix(name, "EXT")
cname := C.CString(name)
defer C.free(unsafe.Pointer(cname))
return uintptr(C.getProcAddressGLES(libGLES, cname))

View File

@ -17,6 +17,8 @@
package opengl
import (
"runtime"
"github.com/hajimehoshi/ebiten/v2/internal/glfw"
)
@ -30,6 +32,11 @@ func (g *Graphics) SetGLFWClientAPI() {
}
glfw.WindowHint(glfw.ClientAPI, glfw.OpenGLAPI)
glfw.WindowHint(glfw.ContextVersionMajor, 2)
glfw.WindowHint(glfw.ContextVersionMinor, 1)
glfw.WindowHint(glfw.ContextVersionMajor, 3)
glfw.WindowHint(glfw.ContextVersionMinor, 2)
// macOS requires forward-compatible and a core profile.
if runtime.GOOS == "darwin" {
glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True)
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile)
}
}

View File

@ -112,6 +112,8 @@ func init() {
}
type openGLState struct {
vertexArray uint32
// arrayBuffer is OpenGL's array buffer (vertices data).
arrayBuffer buffer
@ -148,11 +150,16 @@ func (s *openGLState) reset(context *context) error {
if s.elementArrayBuffer != 0 {
context.ctx.DeleteBuffer(uint32(s.elementArrayBuffer))
}
if s.vertexArray != 0 {
context.ctx.DeleteVertexArray(s.vertexArray)
}
}
s.arrayBuffer = 0
s.arrayBufferSizeInBytes = 0
s.elementArrayBuffer = 0
s.elementArrayBufferSizeInBytes = 0
s.vertexArray = 0
return nil
}
@ -170,6 +177,11 @@ func pow2(x int) int {
}
func (s *openGLState) setVertices(context *context, vertices []float32, indices []uint16) {
if s.vertexArray == 0 {
s.vertexArray = context.ctx.CreateVertexArray()
}
context.ctx.BindVertexArray(s.vertexArray)
if size := len(vertices) * 4; s.arrayBufferSizeInBytes < size {
if s.arrayBuffer != 0 {
context.ctx.DeleteBuffer(uint32(s.arrayBuffer))

View File

@ -29,5 +29,5 @@ vec4 F1(in vec4 l0) {
}
void main(void) {
gl_FragColor = F1(gl_FragCoord);
fragColor = F1(gl_FragCoord);
}

View File

@ -1,7 +1,7 @@
uniform float U0;
uniform float U1;
uniform float U2;
attribute vec2 A0;
in vec2 A0;
int F0(in int l0);

View File

@ -8,5 +8,5 @@ vec4 F0(in vec4 l0) {
}
void main(void) {
gl_FragColor = F0(gl_FragCoord);
fragColor = F0(gl_FragCoord);
}

View File

@ -1,4 +1,4 @@
attribute vec2 A0;
in vec2 A0;
void main(void) {
if (true) {

View File

@ -9,5 +9,5 @@ vec4 F0(in vec4 l0) {
}
void main(void) {
gl_FragColor = F0(gl_FragCoord);
fragColor = F0(gl_FragCoord);
}

View File

@ -1,4 +1,4 @@
attribute vec2 A0;
in vec2 A0;
void main(void) {
vec4 l0 = vec4(0);

View File

@ -15,5 +15,5 @@ vec4 F5(in vec4 l0) {
}
void main(void) {
gl_FragColor = F5(gl_FragCoord);
fragColor = F5(gl_FragCoord);
}

View File

@ -1,4 +1,4 @@
attribute vec2 A0;
in vec2 A0;
void F0(void);
void F1(void);

View File

@ -1,3 +1,3 @@
uniform vec2 U0;
varying vec2 V0;
varying vec4 V1;
in vec2 V0;
in vec4 V1;

View File

@ -1,9 +1,9 @@
uniform vec2 U0;
attribute vec2 A0;
attribute vec2 A1;
attribute vec4 A2;
varying vec2 V0;
varying vec4 V1;
in vec2 A0;
in vec2 A1;
in vec4 A2;
out vec2 V0;
out vec4 V1;
void main(void) {
mat4 l0 = mat4(0);

View File

@ -1,6 +1,6 @@
uniform vec2 U0;
varying vec2 V0;
varying vec4 V1;
in vec2 V0;
in vec4 V1;
vec4 F0(in vec4 l0, in vec2 l1, in vec4 l2);
@ -9,5 +9,5 @@ vec4 F0(in vec4 l0, in vec2 l1, in vec4 l2) {
}
void main(void) {
gl_FragColor = F0(gl_FragCoord, V0, V1);
fragColor = F0(gl_FragCoord, V0, V1);
}

View File

@ -1,9 +1,9 @@
uniform vec2 U0;
attribute vec2 A0;
attribute vec2 A1;
attribute vec4 A2;
varying vec2 V0;
varying vec4 V1;
in vec2 A0;
in vec2 A1;
in vec4 A2;
out vec2 V0;
out vec4 V1;
void main(void) {
mat4 l0 = mat4(0);

View File

@ -63,7 +63,7 @@ ivec4 modInt(ivec4 x, ivec4 y) {
func VertexPrelude(version GLSLVersion) string {
switch version {
case GLSLVersionDefault:
return utilFunctions
return `#version 150` + "\n\n" + utilFunctions
case GLSLVersionES300:
return `#version 300 es`
}
@ -73,6 +73,8 @@ func VertexPrelude(version GLSLVersion) string {
func FragmentPrelude(version GLSLVersion) string {
var prefix string
switch version {
case GLSLVersionDefault:
prefix = `#version 150` + "\n\n"
case GLSLVersionES300:
prefix = `#version 300 es` + "\n\n"
}
@ -83,7 +85,9 @@ precision highp int;
#define lowp
#define mediump
#define highp
#endif`
#endif
out vec4 fragColor;`
if version == GLSLVersionDefault {
prelude += "\n\n" + utilFunctions
}
@ -132,18 +136,10 @@ func Compile(p *shaderir.Program, version GLSLVersion) (vertexShader, fragmentSh
vslines = append(vslines, fmt.Sprintf("uniform sampler2D T%d;", i))
}
for i, t := range p.Attributes {
keyword := "attribute"
if version == GLSLVersionES300 {
keyword = "in"
}
vslines = append(vslines, fmt.Sprintf("%s %s;", keyword, c.varDecl(p, &t, fmt.Sprintf("A%d", i))))
vslines = append(vslines, fmt.Sprintf("in %s;", c.varDecl(p, &t, fmt.Sprintf("A%d", i))))
}
for i, t := range p.Varyings {
keyword := "varying"
if version == GLSLVersionES300 {
keyword = "out"
}
vslines = append(vslines, fmt.Sprintf("%s %s;", keyword, c.varDecl(p, &t, fmt.Sprintf("V%d", i))))
vslines = append(vslines, fmt.Sprintf("out %s;", c.varDecl(p, &t, fmt.Sprintf("V%d", i))))
}
}
@ -229,16 +225,9 @@ func Compile(p *shaderir.Program, version GLSLVersion) (vertexShader, fragmentSh
fslines = append(fslines, fmt.Sprintf("uniform sampler2D T%d;", i))
}
for i, t := range p.Varyings {
keyword := "varying"
if version == GLSLVersionES300 {
keyword = "in"
}
fslines = append(fslines, fmt.Sprintf("%s %s;", keyword, c.varDecl(p, &t, fmt.Sprintf("V%d", i))))
fslines = append(fslines, fmt.Sprintf("in %s;", c.varDecl(p, &t, fmt.Sprintf("V%d", i))))
}
}
if version == GLSLVersionES300 {
fslines = append(fslines, "out vec4 fragColor;")
}
var funcs []*shaderir.Func
if p.VertexFunc.Block != nil {
@ -615,11 +604,7 @@ func (c *compileContext) block(p *shaderir.Program, topBlock, block *shaderir.Bl
case shaderir.Return:
switch {
case topBlock == p.FragmentFunc.Block:
token := "gl_FragColor"
if c.version == GLSLVersionES300 {
token = "fragColor"
}
lines = append(lines, fmt.Sprintf("%s%s = %s;", idt, token, expr(&s.Exprs[0])))
lines = append(lines, fmt.Sprintf("%sfragColor = %s;", idt, expr(&s.Exprs[0])))
// The 'return' statement is not required so far, as the fragment entrypoint has only one sentence so far. See adjustProgram implementation.
case len(s.Exprs) == 0:
lines = append(lines, idt+"return;")

View File

@ -122,10 +122,7 @@ func (c *compileContext) builtinFuncString(f shaderir.BuiltinFunc) string {
case shaderir.Dfdy:
return "dFdy"
case shaderir.Texture2DF:
if c.version == GLSLVersionES300 {
return "texture"
}
return "texture2D"
return "texture"
default:
return string(f)
}

View File

@ -220,11 +220,11 @@ uniform S0 U0;`,
},
GlslVS: glslVertexPrelude + `
uniform float U0;
attribute vec2 A0;
varying vec3 V0;`,
in vec2 A0;
out vec3 V0;`,
GlslFS: glslFragmentPrelude + `
uniform float U0;
varying vec3 V0;`,
in vec3 V0;`,
},
{
Name: "Func",
@ -930,11 +930,11 @@ void F0(float l0, float l1, thread float& l2) {
},
GlslVS: glslVertexPrelude + `
uniform float U0;
attribute vec4 A0;
attribute float A1;
attribute vec2 A2;
varying float V0;
varying vec2 V1;
in vec4 A0;
in float A1;
in vec2 A2;
out float V0;
out vec2 V1;
void main(void) {
gl_Position = A0;
@ -943,8 +943,8 @@ void main(void) {
}`,
GlslFS: glslFragmentPrelude + `
uniform float U0;
varying float V0;
varying vec2 V1;`,
in float V0;
in vec2 V1;`,
},
{
Name: "FragmentFunc",
@ -1002,11 +1002,11 @@ varying vec2 V1;`,
},
GlslVS: glslVertexPrelude + `
uniform float U0;
attribute vec4 A0;
attribute float A1;
attribute vec2 A2;
varying float V0;
varying vec2 V1;
in vec4 A0;
in float A1;
in vec2 A2;
out float V0;
out vec2 V1;
void main(void) {
gl_Position = A0;
@ -1015,8 +1015,8 @@ void main(void) {
}`,
GlslFS: glslFragmentPrelude + `
uniform float U0;
varying float V0;
varying vec2 V1;
in float V0;
in vec2 V1;
vec4 F0(in vec4 l0, in float l1, in vec2 l2);
@ -1029,7 +1029,7 @@ vec4 F0(in vec4 l0, in float l1, in vec2 l2) {
}
void main(void) {
gl_FragColor = F0(gl_FragCoord, V0, V1);
fragColor = F0(gl_FragCoord, V0, V1);
}`,
},
}

View File

@ -71,8 +71,8 @@ func (e *egl) init(nativeWindowHandle C.NativeWindowType) error {
// Create new context and set it as current.
contextAttribs := []C.EGLint{
// Set target graphics api version.
C.EGL_CONTEXT_MAJOR_VERSION, 2,
C.EGL_CONTEXT_MINOR_VERSION, 1,
C.EGL_CONTEXT_MAJOR_VERSION, 3,
C.EGL_CONTEXT_MINOR_VERSION, 2,
// For debug callback
C.EGL_CONTEXT_FLAGS_KHR, C.EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR,
C.EGL_NONE}