Skip to content

Add gl_proc_resolver to resolve GL procs within the GLFW context #71

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions flutter/flutter_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ bool proxy_clear_current(void *v);
bool proxy_present(void *v);
uint32_t proxy_fbo_callback(void *v);
bool proxy_make_resource_current(void *v);
void *proxy_gl_proc_resolver(void *v, const char *procname);

bool proxy_on_platform_message(FlutterPlatformMessage *message,
void *window);
Expand All @@ -27,6 +28,7 @@ FlutterResult runFlutter(uintptr_t window, FlutterEngine *engine, FlutterProject
config.open_gl.present = proxy_present;
config.open_gl.fbo_callback = proxy_fbo_callback;
config.open_gl.make_resource_current = proxy_make_resource_current;
config.open_gl.gl_proc_resolver = proxy_gl_proc_resolver;

Args->command_line_argc = nVmAgrs;
Args->command_line_argv = vmArgs;
Expand Down
5 changes: 5 additions & 0 deletions flutter/flutter_proxy_glfw.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,8 @@ func proxy_make_resource_current(v unsafe.Pointer) C.bool {
index := *(*C.int)(w.GetUserPointer())
return C.bool(flutterEngines[index].FMakeResourceCurrent(v))
}

//export proxy_gl_proc_resolver
func proxy_gl_proc_resolver(v unsafe.Pointer, procname *C.char) unsafe.Pointer {
return glfw.GetProcAddress(C.GoString(procname))
}
38 changes: 38 additions & 0 deletions flutter/library/flutter_embedder.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,31 @@ typedef enum {

typedef struct _FlutterEngine* FlutterEngine;

typedef struct {
// horizontal scale factor
double scaleX;
// horizontal skew factor
double skewX;
// horizontal translation
double transX;
// vertical skew factor
double skewY;
// vertical scale factor
double scaleY;
// vertical translation
double transY;
// input x-axis perspective factor
double pers0;
// input y-axis perspective factor
double pers1;
// perspective scale factor
double pers2;
} FlutterTransformation;

typedef bool (*BoolCallback)(void* /* user data */);
typedef FlutterTransformation (*TransformationCallback)(void* /* user data */);
typedef uint32_t (*UIntCallback)(void* /* user data */);
typedef void* (*ProcResolver)(void* /* user data */, const char* /* name */);

typedef struct {
// The size of this struct. Must be sizeof(FlutterOpenGLRendererConfig).
Expand All @@ -41,7 +64,22 @@ typedef struct {
BoolCallback clear_current;
BoolCallback present;
UIntCallback fbo_callback;
// This is an optional callback. Flutter will ask the emebdder to create a GL
// context current on a background thread. If the embedder is able to do so,
// Flutter will assume that this context is in the same sharegroup as the main
// rendering context and use this context for asynchronous texture uploads.
// Though optional, it is recommended that all embedders set this callback as
// it will lead to better performance in texture handling.
BoolCallback make_resource_current;
// By default, the renderer config assumes that the FBO does not change for
// the duration of the engine run. If this argument is true, the
// engine will ask the embedder for an updated FBO target (via an fbo_callback
// invocation) after a present call.
bool fbo_reset_after_present;
// The transformation to apply to the render target before any rendering
// operations. This callback is optional.
TransformationCallback surface_transformation;
ProcResolver gl_proc_resolver;
} FlutterOpenGLRendererConfig;

typedef struct {
Expand Down