graphics

package
v0.0.0-...-ef9f46b Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ColorWhite       = Color{1, 1, 1, 1}
	ColorBlack       = Color{0, 0, 0, 1}
	ColorRed         = Color{1, 0, 0, 1}
	ColorGreen       = Color{0, 1, 0, 1}
	ColorBlue        = Color{0, 0, 1, 1}
	ColorYellow      = Color{1, 1, 0, 1}
	ColorCyan        = Color{0, 1, 1, 1}
	ColorMagenta     = Color{1, 0, 1, 1}
	ColorTransparent = Color{0, 0, 0, 0}
)

Предопределенные цвета

Functions

This section is empty.

Types

type BlendMode

type BlendMode int

BlendMode режим смешивания

const (
	BlendModeNone BlendMode = iota
	BlendModeAlpha
	BlendModeAdditive
	BlendModeMultiply
)

type Color

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

Color представляет цвет в формате RGBA

func NewColor

func NewColor(r, g, b, a uint8) Color

NewColor создает цвет из значений 0-255

func NewColorF

func NewColorF(r, g, b, a float32) Color

NewColorF создает цвет из значений 0-1

func (Color) ToVec4

func (c Color) ToVec4() mgl32.Vec4

ToVec4 конвертирует цвет в Vec4

type CullMode

type CullMode int

CullMode режим отсечения граней

const (
	CullModeNone CullMode = iota
	CullModeBack
	CullModeFront
	CullModeFrontAndBack
)

type DepthTestMode

type DepthTestMode int

DepthTestMode режим теста глубины

const (
	DepthTestNone DepthTestMode = iota
	DepthTestLess
	DepthTestLessOrEqual
	DepthTestGreater
	DepthTestGreaterOrEqual
	DepthTestEqual
	DepthTestNotEqual
	DepthTestAlways
)

type GraphicsAPI

type GraphicsAPI interface {
	// Initialize инициализирует графический API
	Initialize() error

	// Shutdown завершает работу с графическим API
	Shutdown()

	// Clear очищает экран
	Clear(r, g, b, a float32)

	// SetViewport устанавливает область отрисовки
	SetViewport(x, y, width, height int)

	// Present отображает кадр
	Present()
}

GraphicsAPI интерфейс для абстракции графического API

type Material

type Material struct {
	DiffuseTexture  TextureID
	SpecularTexture TextureID
	NormalTexture   TextureID
	Shininess       float32
	Color           mgl32.Vec4
}

Material описывает материал для рендеринга

type Mesh

type Mesh struct {
	Vertices []Vertex
	Indices  []uint32
}

Mesh представляет 3D меш

type MeshID

type MeshID uint32

MeshID представляет идентификатор меша

type RenderCommand

type RenderCommand struct {
	Mesh      MeshID
	Shader    ShaderID
	Texture   TextureID
	Transform mgl32.Mat4
	Material  *Material
}

RenderCommand команда рендеринга

type RenderState

type RenderState struct {
	BlendMode     BlendMode
	CullMode      CullMode
	DepthTest     DepthTestMode
	DepthWrite    bool
	Wireframe     bool
	ScissorTest   bool
	ScissorX      int
	ScissorY      int
	ScissorWidth  int
	ScissorHeight int
}

RenderState состояние рендеринга

func DefaultRenderState

func DefaultRenderState() RenderState

DefaultRenderState возвращает состояние рендеринга по умолчанию

type ShaderID

type ShaderID uint32

ShaderID представляет идентификатор шейдера

type SpriteVertex

type SpriteVertex struct {
	Position mgl32.Vec3
	TexCoord mgl32.Vec2
	Color    mgl32.Vec4
}

SpriteVertex вершина спрайта для батчинга

type Texture

type Texture struct {
	ID     uint32
	Width  int
	Height int
	Path   string
}

Texture представляет OpenGL текстуру

func LoadTexture

func LoadTexture(path string) (*Texture, error)

LoadTexture загружает текстуру из файла

func (*Texture) Bind

func (t *Texture) Bind()

Bind привязывает текстуру для использования

func (*Texture) Delete

func (t *Texture) Delete()

Delete удаляет текстуру

func (*Texture) Unbind

func (t *Texture) Unbind()

Unbind отвязывает текстуру

type TextureConfig

type TextureConfig struct {
	MinFilter       TextureFilter
	MagFilter       TextureFilter
	WrapS           TextureWrap
	WrapT           TextureWrap
	GenerateMipmaps bool
}

TextureConfig конфигурация текстуры

func DefaultTextureConfig

func DefaultTextureConfig() TextureConfig

DefaultTextureConfig возвращает конфигурацию текстуры по умолчанию

type TextureFilter

type TextureFilter int

TextureFilter режим фильтрации текстур

const (
	TextureFilterNearest TextureFilter = iota
	TextureFilterLinear
	TextureFilterMipmap
)

type TextureID

type TextureID uint32

TextureID представляет идентификатор текстуры

type TextureWrap

type TextureWrap int

TextureWrap режим повторения текстур

const (
	TextureWrapRepeat TextureWrap = iota
	TextureWrapClampToEdge
	TextureWrapMirroredRepeat
)

type Vertex

type Vertex struct {
	Position mgl32.Vec3
	Normal   mgl32.Vec3
	TexCoord mgl32.Vec2
	Color    mgl32.Vec4
}

Vertex представляет вершину меша

type VertexAttribute

type VertexAttribute struct {
	Name       string
	Size       int32  // Количество компонентов (1, 2, 3, или 4)
	Type       uint32 // Тип данных (GL_FLOAT и т.д.)
	Normalized bool
	Stride     int32
	Offset     int
}

VertexAttribute описывает атрибут вершины

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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