This change will break Darwin. I have only built and tested this on desktop linux and Android linux. A follow-up CL will fix Darwin. Currently, OpenGL gets its own thread, and UI C code (e.g. the Android event loop, or the X11 event loop) gets its own thread. This relies on multiple system-provided UI-related C libraries working nicely together, even when running on different threads. Keeping all the C code on the one thread seems more sound. As side-effects: - In package app/debug, DrawFPS now takes an explicit Config. - In package app, some callbacks now take an explicit Config. - In package exp/sprite, Render now takes an explicit Config. - In package event, there are new events (Config, Draw, Lifecycle), and an event filter mechanism to replace multiple app Callbacks. - In package geom, the deprecated Width, Height and PixelsPerPt global variables were removed in favor of an event.Config that is explicitly passed around (and does not require mutex-locking). Converting a geom.Pt to pixels now requires passing a pixelsPerPt. - In package gl, the Do, Start and Stop functions are removed, as well as the need to call Start in its own goroutine. There is no longer a separate GL thread. Instead, package app explicitly performs any GL work (gl.DoWork) when some is available (gl.WorkAvailable). - In package gl/glutil, Image.Draw now takes an explicit Config. Callbacks are no longer executed on 'the UI thread'. Changing the app programming model from callbacks to events (since a channel of events works with select) will be a follow-up change. Change-Id: Id9865cd9ee1c45a98c613e9021a63c17226a64b1 Reviewed-on: https://go-review.googlesource.com/11351 Reviewed-by: David Crawshaw <crawshaw@golang.org>
180 lines
3.4 KiB
C
180 lines
3.4 KiB
C
// Copyright 2015 The Go Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
#ifdef os_linux
|
|
#include <GLES2/gl2.h>
|
|
#endif
|
|
#ifdef os_ios
|
|
#include <OpenGLES/ES2/glext.h>
|
|
#endif
|
|
#ifdef os_osx
|
|
#include <OpenGL/gl3.h>
|
|
#endif
|
|
|
|
#include <stdint.h>
|
|
#include <stdlib.h>
|
|
|
|
typedef enum {
|
|
glfnUNDEFINED,
|
|
|
|
glfnActiveTexture,
|
|
glfnAttachShader,
|
|
glfnBindAttribLocation,
|
|
glfnBindBuffer,
|
|
glfnBindFramebuffer,
|
|
glfnBindRenderbuffer,
|
|
glfnBindTexture,
|
|
glfnBlendColor,
|
|
glfnBlendEquation,
|
|
glfnBlendEquationSeparate,
|
|
glfnBlendFunc,
|
|
glfnBlendFuncSeparate,
|
|
glfnBufferData,
|
|
glfnBufferSubData,
|
|
glfnCheckFramebufferStatus,
|
|
glfnClear,
|
|
glfnClearColor,
|
|
glfnClearDepthf,
|
|
glfnClearStencil,
|
|
glfnColorMask,
|
|
glfnCompileShader,
|
|
glfnCompressedTexImage2D,
|
|
glfnCompressedTexSubImage2D,
|
|
glfnCopyTexImage2D,
|
|
glfnCopyTexSubImage2D,
|
|
glfnCreateProgram,
|
|
glfnCreateShader,
|
|
glfnCullFace,
|
|
glfnDeleteBuffer,
|
|
glfnDeleteFramebuffer,
|
|
glfnDeleteProgram,
|
|
glfnDeleteRenderbuffer,
|
|
glfnDeleteShader,
|
|
glfnDeleteTexture,
|
|
glfnDepthFunc,
|
|
glfnDepthRangef,
|
|
glfnDepthMask,
|
|
glfnDetachShader,
|
|
glfnDisable,
|
|
glfnDisableVertexAttribArray,
|
|
glfnDrawArrays,
|
|
glfnDrawElements,
|
|
glfnEnable,
|
|
glfnEnableVertexAttribArray,
|
|
glfnFinish,
|
|
glfnFlush,
|
|
glfnFramebufferRenderbuffer,
|
|
glfnFramebufferTexture2D,
|
|
glfnFrontFace,
|
|
glfnGenBuffer,
|
|
glfnGenFramebuffer,
|
|
glfnGenRenderbuffer,
|
|
glfnGenTexture,
|
|
glfnGenerateMipmap,
|
|
glfnGetActiveAttrib,
|
|
glfnGetActiveUniform,
|
|
glfnGetAttachedShaders,
|
|
glfnGetAttribLocation,
|
|
glfnGetBooleanv,
|
|
glfnGetBufferParameteri,
|
|
glfnGetError,
|
|
glfnGetFloatv,
|
|
glfnGetFramebufferAttachmentParameteriv,
|
|
glfnGetIntegerv,
|
|
glfnGetProgramInfoLog,
|
|
glfnGetProgramiv,
|
|
glfnGetRenderbufferParameteriv,
|
|
glfnGetShaderInfoLog,
|
|
glfnGetShaderPrecisionFormat,
|
|
glfnGetShaderSource,
|
|
glfnGetShaderiv,
|
|
glfnGetString,
|
|
glfnGetTexParameterfv,
|
|
glfnGetTexParameteriv,
|
|
glfnGetUniformLocation,
|
|
glfnGetUniformfv,
|
|
glfnGetUniformiv,
|
|
glfnGetVertexAttribfv,
|
|
glfnGetVertexAttribiv,
|
|
glfnHint,
|
|
glfnIsBuffer,
|
|
glfnIsEnabled,
|
|
glfnIsFramebuffer,
|
|
glfnIsProgram,
|
|
glfnIsRenderbuffer,
|
|
glfnIsShader,
|
|
glfnIsTexture,
|
|
glfnLineWidth,
|
|
glfnLinkProgram,
|
|
glfnPixelStorei,
|
|
glfnPolygonOffset,
|
|
glfnReadPixels,
|
|
glfnReleaseShaderCompiler,
|
|
glfnRenderbufferStorage,
|
|
glfnSampleCoverage,
|
|
glfnScissor,
|
|
glfnShaderSource,
|
|
glfnStencilFunc,
|
|
glfnStencilFuncSeparate,
|
|
glfnStencilMask,
|
|
glfnStencilMaskSeparate,
|
|
glfnStencilOp,
|
|
glfnStencilOpSeparate,
|
|
glfnTexImage2D,
|
|
glfnTexParameterf,
|
|
glfnTexParameterfv,
|
|
glfnTexParameteri,
|
|
glfnTexParameteriv,
|
|
glfnTexSubImage2D,
|
|
glfnUniform1f,
|
|
glfnUniform1fv,
|
|
glfnUniform1i,
|
|
glfnUniform1iv,
|
|
glfnUniform2f,
|
|
glfnUniform2fv,
|
|
glfnUniform2i,
|
|
glfnUniform2iv,
|
|
glfnUniform3f,
|
|
glfnUniform3fv,
|
|
glfnUniform3i,
|
|
glfnUniform3iv,
|
|
glfnUniform4f,
|
|
glfnUniform4fv,
|
|
glfnUniform4i,
|
|
glfnUniform4iv,
|
|
glfnUniformMatrix2fv,
|
|
glfnUniformMatrix3fv,
|
|
glfnUniformMatrix4fv,
|
|
glfnUseProgram,
|
|
glfnValidateProgram,
|
|
glfnVertexAttrib1f,
|
|
glfnVertexAttrib1fv,
|
|
glfnVertexAttrib2f,
|
|
glfnVertexAttrib2fv,
|
|
glfnVertexAttrib3f,
|
|
glfnVertexAttrib3fv,
|
|
glfnVertexAttrib4f,
|
|
glfnVertexAttrib4fv,
|
|
glfnVertexAttribPointer,
|
|
glfnViewport,
|
|
} glfn;
|
|
|
|
struct fnargs {
|
|
glfn fn;
|
|
|
|
uintptr_t a0;
|
|
uintptr_t a1;
|
|
uintptr_t a2;
|
|
uintptr_t a3;
|
|
uintptr_t a4;
|
|
uintptr_t a5;
|
|
uintptr_t a6;
|
|
uintptr_t a7;
|
|
uintptr_t a8;
|
|
};
|
|
|
|
extern uintptr_t ret;
|
|
|
|
extern void processFn(struct fnargs* args);
|