view

package
v0.0.0-...-1050381 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 7, 2017 License: MIT Imports: 3 Imported by: 12

Documentation

Overview

view sets up and handles a glfw window.

Example
package main

import (
	"github.com/goxjs/gl"
	"github.com/goxjs/glfw"
	"github.com/omustardo/gome/view"
	"log"
	"time"
)

func main() {
	if err := view.Initialize(1280, 720, "Demo"); err != nil {
		log.Fatal(err)
	}
	defer view.Terminate()

	framerate := time.Second / 60
	ticker := time.NewTicker(framerate)
	for !view.Window.ShouldClose() {
		glfw.PollEvents() // Reads window events, like keyboard and mouse input. Necessary to do basic things, like resize the window.

		gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT)
		// TODO: Draw stuff here.

		view.Window.SwapBuffers()
		<-ticker.C // wait up to the framerate cap.
	}
}
Output:

Index

Examples

Constants

This section is empty.

Variables

View Source
var Window *glfw.Window

Window is the singleton glfw window. It should be initialized with view.Initialize(), and then all window related logic can access it directly. It should be closed with view.Terminate()

Functions

func Initialize

func Initialize(width, height int, windowName string) error

Initialize sets up the singleton view.Window.

func Terminate

func Terminate()

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL