Skip to content

Commit

Permalink
Add hints to override default GLContextAttributes options
Browse files Browse the repository at this point in the history
  • Loading branch information
Yoshiki Shibukawa committed Nov 27, 2015
1 parent abb1335 commit ff14acd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
8 changes: 8 additions & 0 deletions browser.go
Expand Up @@ -67,7 +67,15 @@ func CreateWindow(_, _ int, title string, monitor *Monitor, share *Window) (*Win
// Use glfw hints.
attrs := defaultAttributes()
attrs.Alpha = (hints[AlphaBits] > 0)
if _, ok := hints[Depth]; ok {
attrs.Depth = (hints[Depth] > 0)
}
attrs.Stencil = (hints[Stencil] > 0)
attrs.Antialias = (hints[Samples] > 0)
attrs.PremultipliedAlpha = (hints[PremultipliedAlpha] > 0)
attrs.PreserveDrawingBuffer = (hints[PreserveDrawingBuffer] > 0)
attrs.PreferLowPowerToHighPerformance = (hints[PreferLowPowerToHighPerformance] > 0)
attrs.FailIfMajorPerformanceCaveat = (hints[FailIfMajorPerformanceCaveat] > 0)

// Create GL context.
context, err := newContext(canvas.Underlying(), attrs)
Expand Down
10 changes: 8 additions & 2 deletions hint_js.go
Expand Up @@ -7,8 +7,14 @@ var hints = make(map[Hint]int)
type Hint int

const (
AlphaBits Hint = 0x00021004
Samples Hint = 0x0002100D
AlphaBits Hint = 0x00021004
Samples Hint = 0x0002100D
Depth Hint = 0x00021100 // github.com/goxjs/glfw original hint for JS
Stencil Hint = 0x00021101 // github.com/goxjs/glfw original hint for JS
PremultipliedAlpha Hint = 0x00021102 // github.com/goxjs/glfw original hint for JS
PreserveDrawingBuffer Hint = 0x00021103 // github.com/goxjs/glfw original hint for JS
PreferLowPowerToHighPerformance Hint = 0x00021104 // github.com/goxjs/glfw original hint for JS
FailIfMajorPerformanceCaveat Hint = 0x00021105 // github.com/goxjs/glfw original hint for JS
)

func WindowHint(target Hint, hint int) {
Expand Down

0 comments on commit ff14acd

Please sign in to comment.