浏览代码

added GetScreenResolution()

leonsal 8 年之前
父节点
当前提交
e92758227a
共有 2 个文件被更改,包括 15 次插入1 次删除
  1. 9 0
      window/glfw.go
  2. 6 1
      window/window.go

+ 9 - 0
window/glfw.go

@@ -166,6 +166,15 @@ func newGLFW(width, height int, title string, full bool) (*GLFW, error) {
 	return w, nil
 }
 
+// GetScreenResolution returns the resolution of the primary screen in pixels.
+// The parameter is currently ignored
+func (w *GLFW) GetScreenResolution(p interface{}) (width, height int) {
+
+	mon := glfw.GetPrimaryMonitor()
+	vmode := mon.GetVideoMode()
+	return vmode.Width, vmode.Height
+}
+
 func (w *GLFW) SwapInterval(interval int) {
 
 	glfw.SwapInterval(interval)

+ 6 - 1
window/window.go

@@ -4,7 +4,7 @@
 
 /*
  Package window abstracts the OpenGL Window manager
- Currently only glfw is supported
+ Currently only "glfw" is supported
 */
 package window
 
@@ -18,6 +18,7 @@ import (
 //
 type IWindow interface {
 	core.IDispatcher
+	GetScreenResolution(interface{}) (width, height int)
 	SwapInterval(interval int)
 	MakeContextCurrent()
 	GetSize() (width int, height int)
@@ -304,6 +305,10 @@ type ScrollEvent struct {
 	Yoffset float32
 }
 
+// New creates and returns a new window of the specified type, width, height and title.
+// If full is true, the window will be opened in full screen and the width and height
+// parameters will be ignored.
+// Currently only "glfw" type is supported.
 func New(wtype string, width, height int, title string, full bool) (IWindow, error) {
 
 	if wtype != "glfw" {