-
Notifications
You must be signed in to change notification settings - Fork 282
Select opengl #258
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
Merged
Select opengl #258
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7 h1:SCYMcCJ89LjRGwEa0tRluNRiMjZHalQZrVrvTbPh+qw= | ||
github.com/go-gl/gl v0.0.0-20190320180904-bf2b1f2f34d7/go.mod h1:482civXOzJJCPzJ4ZOX/pwvXBWSnzD4OKMdH4ClKGbk= | ||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1 h1:QbL/5oDUmRBzO9/Z7Seo6zf912W/a6Sr4Eu0G/3Jho0= | ||
github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= | ||
github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= | ||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= | ||
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk= | ||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= | ||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Package opengl wraps the go-gl/gl OpenGL bindings with a compile-time OpenGL | ||
// version selector. | ||
// | ||
// This package allows clients to target multiple version of OpenGL when | ||
// building go-flutter. | ||
// default is v3.3 | ||
// | ||
// Golang build constraints are used for version selection. | ||
package opengl |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
// +build !openglnone | ||
|
||
package opengl | ||
|
||
// The default version (3.3) of OpenGL used by go-flutter. | ||
// If you want to support other version, copy/pase this file, change the import | ||
// statement, add builds constraints and open a PR. | ||
|
||
import ( | ||
"unsafe" | ||
|
||
"github.com/go-gl/gl/v3.3-core/gl" | ||
"github.com/go-gl/glfw/v3.2/glfw" | ||
) | ||
|
||
// const exposed to go-flutter | ||
const ( | ||
TEXTURE2D = gl.TEXTURE_2D | ||
RGBA8 = gl.RGBA8 | ||
) | ||
|
||
// Init opengl | ||
func Init() error { | ||
return gl.Init() | ||
} | ||
|
||
// DeleteTextures deletes named textures | ||
func DeleteTextures(n int32, textures *uint32) { | ||
gl.DeleteTextures(n, textures) | ||
} | ||
|
||
// CreateTexture creates a texture for go-flutter uses | ||
func CreateTexture(texture *uint32) { | ||
gl.GenTextures(1, texture) | ||
gl.BindTexture(gl.TEXTURE_2D, *texture) | ||
// set the texture wrapping parameters | ||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_BORDER) | ||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_BORDER) | ||
// set texture filtering parameters | ||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR) | ||
gl.TexParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR) | ||
} | ||
|
||
// BindTexture binds a named texture to a texturing target | ||
func BindTexture(texture uint32) { | ||
gl.BindTexture(gl.TEXTURE_2D, texture) | ||
} | ||
|
||
// Ptr takes a slice or pointer (to a singular scalar value or the first | ||
// element of an array or slice) and returns its GL-compatible address. | ||
func Ptr(data interface{}) unsafe.Pointer { | ||
return gl.Ptr(data) | ||
} | ||
|
||
// TexImage2D specifies a two-dimensional texture image | ||
func TexImage2D(width, height int32, pixels unsafe.Pointer) { | ||
// It the current flutter/engine can only support RGBA texture. | ||
gl.TexImage2D( | ||
gl.TEXTURE_2D, | ||
0, | ||
gl.RGBA, | ||
width, | ||
height, | ||
0, | ||
gl.RGBA, | ||
gl.UNSIGNED_BYTE, | ||
pixels, | ||
) | ||
} | ||
|
||
// GLFWWindowHint sets hints for the next call to CreateWindow. | ||
func GLFWWindowHint() { | ||
glfw.WindowHint(glfw.ContextVersionMajor, 3) | ||
glfw.WindowHint(glfw.ContextVersionMinor, 3) | ||
glfw.WindowHint(glfw.OpenGLProfile, glfw.OpenGLCoreProfile) | ||
glfw.WindowHint(glfw.OpenGLForwardCompatible, glfw.True) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// +build openglnone | ||
|
||
package opengl | ||
|
||
// Don't link go-flutter against OpenGL, less-dependency at the cost of not | ||
// supporting external texture (eg: video_plugin) | ||
// | ||
// compile go-flutter with: hover build|run --opengl=none | ||
|
||
import ( | ||
"unsafe" | ||
) | ||
|
||
// const exposed to go-flutter | ||
const ( | ||
TEXTURE2D = 0 | ||
RGBA8 = 0 | ||
) | ||
|
||
// Init opengl | ||
func Init() error { return nil } | ||
|
||
// DeleteTextures deletes named textures | ||
func DeleteTextures(n int32, textures *uint32) {} | ||
|
||
// CreateTexture creates a texture for go-flutter uses | ||
func CreateTexture(texture *uint32) {} | ||
|
||
// BindTexture binds a named texture to a texturing target | ||
func BindTexture(texture uint32) {} | ||
|
||
// Ptr takes a slice or pointer (to a singular scalar value or the first | ||
// element of an array or slice) and returns its GL-compatible address. | ||
func Ptr(data interface{}) unsafe.Pointer { return nil } | ||
|
||
// TexImage2D specifies a two-dimensional texture image | ||
func TexImage2D(width, height int32, pixels unsafe.Pointer) { | ||
panic("go-flutter: go-flutter wasn't compiled with support for external texture plugin.") | ||
} | ||
|
||
// GLFWWindowHint sets hints for the next call to CreateWindow. | ||
func GLFWWindowHint() {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.