oglwnd

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2021 License: BSL-1.0 Imports: 1 Imported by: 0

README

oglwnd

GoDoc

About

oglwnd is a package for Go to create a window with OpenGL 3.0 context. It is published on https://github.com/vbsw/oglwnd.

Copyright 2021, Vitali Baumtrok (vbsw@mailbox.org).

oglwnd is distributed under the Boost Software License, version 1.0. (See accompanying file LICENSE or copy at http://www.boost.org/LICENSE_1_0.txt)

oglwnd is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Boost Software License for more details.

Compile

Install Go (https://golang.org/doc/install). For Cgo install a C compiler (https://jmeubank.github.io/tdm-gcc/).

// example
package main
import "github.com/vbsw/oglwnd"
import "fmt"

type myHandler struct {
	oglwnd.DefaultHandler
}

func (h *myHandler) OnUpdate(window *oglwnd.Window) error {
	oglwnd.Clear(0.2, 0.2, 0.2, 0)
	return nil
}

func main() {
	err := oglwnd.Start(new(myHandler))
	if err == nil {
		fmt.Println(err.Error())
	}
}

To compile without console on windows use

-ldflags -H=windowsgui

References

Documentation

Overview

Package oglwnd creates a window with OpenGL 3.0 context.

Package oglwnd creates a window with OpenGL 3.0 context.

Index

Constants

View Source
const (
	KeyA           = 4
	KeyB           = 5
	KeyC           = 6
	KeyD           = 7
	KeyE           = 8
	KeyF           = 9
	KeyG           = 10
	KeyH           = 11
	KeyI           = 12
	KeyJ           = 13
	KeyK           = 14
	KeyL           = 15
	KeyM           = 16
	KeyN           = 17
	KeyO           = 18
	KeyP           = 19
	KeyQ           = 20
	KeyR           = 21
	KeyS           = 22
	KeyT           = 23
	KeyU           = 24
	KeyV           = 25
	KeyW           = 26
	KeyX           = 27
	KeyY           = 28
	KeyZ           = 29
	Key1           = 30
	Key2           = 31
	Key3           = 32
	Key4           = 33
	Key5           = 34
	Key6           = 35
	Key7           = 36
	Key8           = 37
	Key9           = 38
	Key0           = 39
	KeyEnter       = 40
	KeyEsc         = 41
	KeyBackspace   = 42
	KeyTab         = 43
	KeySpace       = 44
	KeyMinus       = 45
	KeyEqual       = 46
	KeyLBrace      = 47
	KeyRBrace      = 48
	KeyBSlash      = 49
	KeyTilde       = 50
	KeySemicolon   = 51
	KeyApostrophe  = 52
	KeyGrave       = 53
	KeyComma       = 54
	KeyDot         = 55
	KeySlash       = 56
	KeyCaps        = 57
	KeyF1          = 58
	KeyF2          = 59
	KeyF3          = 60
	KeyF4          = 61
	KeyF5          = 62
	KeyF6          = 63
	KeyF7          = 64
	KeyF8          = 65
	KeyF9          = 66
	KeyF10         = 67
	KeyF11         = 68
	KeyF12         = 69
	KeyScroll      = 71
	KeyPause       = 72
	KeyInsert      = 73
	KeyHome        = 74
	KeyPageUp      = 75
	KeyDelete      = 76
	KeyEnd         = 77
	KeyPageDown    = 78
	KeyRight       = 79
	KeyLeft        = 80
	KeyDown        = 81
	KeyUp          = 82
	KeyNumLock     = 83
	KeyPadSlash    = 84
	KeyPadAsterisk = 85
	KeyPadMinus    = 86
	KeyPadPlus     = 87
	KeyPadEnter    = 88
	KeyPad1        = 89
	KeyPad2        = 90
	KeyPad3        = 91
	KeyPad4        = 92
	KeyPad5        = 93
	KeyPad6        = 94
	KeyPad7        = 95
	KeyPad8        = 96
	KeyPad9        = 97
	KeyPad0        = 98
	KeyPadDot      = 99
	KeyPipe        = 100
	KeyPadEqual    = 103
	KeyMenu        = 118
	KeyPadComma    = 133
	KeyLCtrl       = 224
	KeyLShift      = 225
	KeyLAlt        = 226
	KeyRCtrl       = 228
	KeyRShift      = 229
	KeyRAlt        = 230
)

Variables

This section is empty.

Functions

func Start

func Start(handler Handler) error

Start creates a window with OpenGL 3.0 context and starts the main loop.

Types

type Config

type Config struct {
	X, Y                  int
	Width, Height         uint
	MinWidth, MinHeight   uint
	MaxWidth, MaxHeight   uint
	Quit, Centered        bool
	Borderless, Dragable  bool
	Resizable, Fullscreen bool
	MouseLocked           bool
}

type DefaultHandler

type DefaultHandler struct {
}

func (*DefaultHandler) OnButtonDown

func (dhn *DefaultHandler) OnButtonDown(window *Window, button int, doubleClick bool) error

func (*DefaultHandler) OnButtonUp

func (dhn *DefaultHandler) OnButtonUp(window *Window, button int) error

func (*DefaultHandler) OnClose

func (dhn *DefaultHandler) OnClose(window *Window) error

func (*DefaultHandler) OnConfig

func (dhn *DefaultHandler) OnConfig(config *Config) error

func (*DefaultHandler) OnFirstUpdate

func (dhn *DefaultHandler) OnFirstUpdate(window *Window) error

func (*DefaultHandler) OnFirstWindowSize

func (dhn *DefaultHandler) OnFirstWindowSize(window *Window) error

func (*DefaultHandler) OnFocusGain

func (dhn *DefaultHandler) OnFocusGain(window *Window) error

func (*DefaultHandler) OnFocusLoose

func (dhn *DefaultHandler) OnFocusLoose(window *Window) error

func (*DefaultHandler) OnKeyDown

func (dhn *DefaultHandler) OnKeyDown(window *Window, key, repeat int) error

func (*DefaultHandler) OnKeyUp

func (dhn *DefaultHandler) OnKeyUp(window *Window, key int) error

func (*DefaultHandler) OnMouseMove

func (dhn *DefaultHandler) OnMouseMove(window *Window) error

func (*DefaultHandler) OnMove

func (dhn *DefaultHandler) OnMove(window *Window) error

func (*DefaultHandler) OnOpenGLInit

func (dhn *DefaultHandler) OnOpenGLInit() error

func (*DefaultHandler) OnResize

func (dhn *DefaultHandler) OnResize(window *Window) error

func (*DefaultHandler) OnUpdate

func (dhn *DefaultHandler) OnUpdate(window *Window) error

func (*DefaultHandler) OnUpdateContinue

func (dhn *DefaultHandler) OnUpdateContinue(window *Window) error

func (*DefaultHandler) OnUpdateStop

func (dhn *DefaultHandler) OnUpdateStop(window *Window) error

func (*DefaultHandler) OnWheel

func (dhn *DefaultHandler) OnWheel(window *Window, wheel float32) error

type Handler

type Handler interface {
	OnConfig(config *Config) error
	OnClose(window *Window) error
	OnOpenGLInit() error
	OnFirstUpdate(window *Window) error
	OnUpdate(window *Window) error
	OnKeyDown(window *Window, key, repeat int) error
	OnKeyUp(window *Window, key int) error
	OnMove(window *Window) error
	OnResize(window *Window) error
	OnFirstWindowSize(window *Window) error
	OnFocusLoose(window *Window) error
	OnFocusGain(window *Window) error
	OnMouseMove(window *Window) error
	OnUpdateStop(window *Window) error
	OnUpdateContinue(window *Window) error
	OnButtonDown(window *Window, button int, doubleClick bool) error
	OnButtonUp(window *Window, button int) error
	OnWheel(window *Window, wheel float32) error
}

type Window

type Window struct {
	ClientX, ClientY      int
	ClientW, ClientH      uint
	MinWidth, MinHeight   uint
	MaxWidth, MaxHeight   uint
	Quit                  bool
	Borderless, Dragable  bool
	Resizable, Fullscreen bool
	MouseLocked           bool
}

Jump to

Keyboard shortcuts

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