Graphics

package
v0.0.0-...-2fed24c Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SQUAREVertices = []float32{

		-1, -1, 0, 0, 1,
		1, -1, 0, 1, 1,
		-1, 1, 0, 0, 0,
		1, 1, 0, 1, 0,
	}
	SQUAREIndices = []uint32{
		0, 1, 2,
		1, 2, 3,
	}

	CUBEVertices = []float32{}/* 180 elements not displayed */

	PYRAMIDVertices = []float32{

		-1, -1, -1, 1, 1,
		1, -1, -1, 0, 1,
		0, 1, 0, 0.5, 0,

		-1, -1, -1, 0, 1,
		-1, -1, 1, 1, 1,
		0, 1, 0, 0.5, 0,

		1, -1, -1, 1, 1,
		1, -1, 1, 0.5, 1,
		0, 1, 0, 0.5, 0,

		-1, -1, 1, 0, 1,
		1, -1, 1, 1, 1,
		0, 1, 0, 0.5, 0,

		-1, -1, -1, 0, 0,
		-1, -1, 1, 0, 1,
		1, -1, -1, 1, 0,

		-1, -1, 1, 0, 1,
		1, -1, -1, 1, 0,
		1, -1, 1, 1, 1,
	}
)
View Source
var ShaderManager t_ShaderManager

Functions

func CheckForGLError

func CheckForGLError() bool

func FramebufferSizeCallback

func FramebufferSizeCallback(w *glfw.Window, width int, height int)

FramebufferSizeCallback Called when resizing window

func InitCamera

func InitCamera(pos mgl32.Vec3, up mgl32.Vec3)

func InitFontManager

func InitFontManager()

func InitGraphicalManager

func InitGraphicalManager() error

func InitObjectManager

func InitObjectManager()

func InitShaderManager

func InitShaderManager()

func InitTextRenderer

func InitTextRenderer() error

func InitTextureManager

func InitTextureManager()

func LoadFont

func LoadFont(fontPath string) error

func LoadModel

func LoadModel(dir, file string) error

func MouseCallback

func MouseCallback(window *glfw.Window, xposi float64, yposi float64)

func NewAtlas

func NewAtlas(path string) error

func ScrollWheelCallback

func ScrollWheelCallback(window *glfw.Window, xOffset float64, yoffset float64)

Types

type CameraDirection

type CameraDirection int
const (
	CameraForward CameraDirection = iota
	CameraBackward
	CameraLeft
	CameraRight
	CameraUp
	CameraDown
)

type CameraT

type CameraT struct {
	Pos     mgl32.Vec3
	Front   mgl32.Vec3
	Up      mgl32.Vec3
	Right   mgl32.Vec3
	WorldUp mgl32.Vec3

	MoveSpeed float32

	Yaw   float32
	Pitch float32
	Zoom  float32

	ProjectionMatrix mgl32.Mat4
	ViewMatrix       mgl32.Mat4
	// contains filtered or unexported fields
}
var Camera CameraT

func (*CameraT) Calculate

func (c *CameraT) Calculate()

func (*CameraT) MoveCamera

func (c *CameraT) MoveCamera(direction CameraDirection, deltaTime float32)

func (*CameraT) UpdateScreen

func (c *CameraT) UpdateScreen(width int, height int)

type Character

type Character struct {
	Size    [2]int32
	Bearing [2]int32
	Advance uint32
	TR, BL  mgl32.Vec2
}

type CharactersT

type CharactersT map[rune]Character

type Color

type Color struct {
	R, G, B, A float32
}

func (*Color) ToFloat32Array

func (c *Color) ToFloat32Array() []float32

type FontManager

type FontManager struct {
	Characters map[string]CharactersT
	// contains filtered or unexported fields
}
var FontMgr FontManager

type GlfwContext

type GlfwContext struct {
	Window *glfw.Window

	Programs []uint32

	Vao []uint32
	// contains filtered or unexported fields
}

func (*GlfwContext) Destroy

func (g *GlfwContext) Destroy()

func (*GlfwContext) Init

func (g *GlfwContext) Init() error

type GraphicalmanagerT

type GraphicalmanagerT struct {
	*GlfwContext
	// contains filtered or unexported fields
}
var GraphicalManager *GraphicalmanagerT

func (*GraphicalmanagerT) AddObjectRenderer

func (ctx *GraphicalmanagerT) AddObjectRenderer(object IRenderable)

func (*GraphicalmanagerT) DrawBackground

func (ctx *GraphicalmanagerT) DrawBackground()

func (*GraphicalmanagerT) RemoveObjectRenderer

func (ctx *GraphicalmanagerT) RemoveObjectRenderer(object IRenderable)

func (*GraphicalmanagerT) Render

func (ctx *GraphicalmanagerT) Render(fps int, showFps bool) error

type IRenderable

type IRenderable interface {
	Draw() error
}

type LoadedTexture

type LoadedTexture struct {
	Texture
	// contains filtered or unexported fields
}

func (*LoadedTexture) GetImage

func (l *LoadedTexture) GetImage() (*image.Image, error)

func (*LoadedTexture) LoadImg

func (l *LoadedTexture) LoadImg() error

func (*LoadedTexture) UnloadImg

func (l *LoadedTexture) UnloadImg()

type ObjectManagerT

type ObjectManagerT struct {
	Objects []*Renderable
}
var ObjectManager ObjectManagerT

func (*ObjectManagerT) PushObject

func (o *ObjectManagerT) PushObject(object *Renderable)

type Renderable

type Renderable struct {
	Transform
	// contains filtered or unexported fields
}

func NewCube

func NewCube(transform Transform, texturePath string) *Renderable

func NewPyramid

func NewPyramid(transform Transform, texturePath string) *Renderable

func NewRenderable

func NewRenderable(options RenderableOptions) Renderable

func (*Renderable) Draw

func (r *Renderable) Draw() error

func (*Renderable) Render

func (r *Renderable) Render(shouldRender bool)

type RenderableOptions

type RenderableOptions struct {
	UseVertices bool
	UseIndices  bool
	IsTextured  bool
	IsColored   bool
}

type TextRendererT

type TextRendererT struct {
	TextProgram uint32
	Vao         uint32
	Vbo         uint32
}
var TextRenderer *TextRendererT

func (*TextRendererT) RenderText

func (r *TextRendererT) RenderText(text string, x, y float32, scale float32, color Color, fontName string) error

type Texture

type Texture struct {
	// contains filtered or unexported fields
}

type TextureManager_t

type TextureManager_t struct {
	// contains filtered or unexported fields
}
var TextureManager *TextureManager_t

func (*TextureManager_t) GetTexture

func (t *TextureManager_t) GetTexture(path string) (*LoadedTexture, error)

func (*TextureManager_t) UnloadTexture

func (t *TextureManager_t) UnloadTexture(img *image.Image)

func (*TextureManager_t) UnloadTextureByPath

func (t *TextureManager_t) UnloadTextureByPath(imgPath string)

type Transform

type Transform struct {
	Translation, Rotation mgl32.Vec3
	Scale                 float32

	Matrix mgl32.Mat4
}

func NewScaledTransform

func NewScaledTransform(Pos, Rot mgl32.Vec3, Scale float32) Transform

func NewTransform

func NewTransform(Pos, Rot mgl32.Vec3) Transform

func (*Transform) MovePos

func (t *Transform) MovePos(Position mgl32.Vec3)

func (*Transform) RotateX

func (t *Transform) RotateX(Angle float32)

func (*Transform) RotateY

func (t *Transform) RotateY(Angle float32)

func (*Transform) RotateZ

func (t *Transform) RotateZ(Angle float32)

func (*Transform) SetPos

func (t *Transform) SetPos(Position mgl32.Vec3)

type Triangle

type Triangle struct {
	Renderable
}

func NewTriangle

func NewTriangle(c Color) Triangle

func NewTriangleTextured

func NewTriangleTextured(path string) Triangle

type Vertex

type Vertex struct {
	Position  mgl32.Vec3
	Normal    mgl32.Vec3
	TexCoords mgl32.Vec2
	Tangent   mgl32.Vec3
	BitAgent  mgl32.Vec3
	MBoneids  [4]int
	//weights from each bone
	MWeights [4]float32
}

Jump to

Keyboard shortcuts

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