Golint
This commit is contained in:
parent
0682698f0b
commit
969ba1dc21
8 changed files with 125 additions and 81 deletions
|
@ -8,8 +8,8 @@ import "C"
|
|||
import "unsafe"
|
||||
import "reflect"
|
||||
|
||||
// Some basic Defines
|
||||
const (
|
||||
// Some basic Defines
|
||||
Pi = 3.1415927
|
||||
Deg2rad = 0.017453292
|
||||
Rad2deg = 57.295776
|
||||
|
@ -168,6 +168,7 @@ const (
|
|||
GamepadXboxAxisRt = 5
|
||||
)
|
||||
|
||||
// Gestures
|
||||
type Gestures int32
|
||||
|
||||
// Gestures type
|
||||
|
@ -186,6 +187,7 @@ const (
|
|||
GesturePinchOut Gestures = C.GESTURE_PINCH_OUT
|
||||
)
|
||||
|
||||
// Camera mode
|
||||
type CameraMode int32
|
||||
|
||||
// Camera system modes
|
||||
|
@ -201,57 +203,57 @@ const (
|
|||
// NOTE: Custom raylib color palette for amazing visuals on WHITE background
|
||||
var (
|
||||
// Light Gray
|
||||
LightGray Color = NewColor(200, 200, 200, 255)
|
||||
LightGray = NewColor(200, 200, 200, 255)
|
||||
// Gray
|
||||
Gray Color = NewColor(130, 130, 130, 255)
|
||||
Gray = NewColor(130, 130, 130, 255)
|
||||
// Dark Gray
|
||||
DarkGray Color = NewColor(80, 80, 80, 255)
|
||||
DarkGray = NewColor(80, 80, 80, 255)
|
||||
// Yellow
|
||||
Yellow Color = NewColor(253, 249, 0, 255)
|
||||
Yellow = NewColor(253, 249, 0, 255)
|
||||
// Gold
|
||||
Gold Color = NewColor(255, 203, 0, 255)
|
||||
Gold = NewColor(255, 203, 0, 255)
|
||||
// Orange
|
||||
Orange Color = NewColor(255, 161, 0, 255)
|
||||
Orange = NewColor(255, 161, 0, 255)
|
||||
// Pink
|
||||
Pink Color = NewColor(255, 109, 194, 255)
|
||||
Pink = NewColor(255, 109, 194, 255)
|
||||
// Red
|
||||
Red Color = NewColor(230, 41, 55, 255)
|
||||
Red = NewColor(230, 41, 55, 255)
|
||||
// Maroon
|
||||
Maroon Color = NewColor(190, 33, 55, 255)
|
||||
Maroon = NewColor(190, 33, 55, 255)
|
||||
// Green
|
||||
Green Color = NewColor(0, 228, 48, 255)
|
||||
Green = NewColor(0, 228, 48, 255)
|
||||
// Lime
|
||||
Lime Color = NewColor(0, 158, 47, 255)
|
||||
Lime = NewColor(0, 158, 47, 255)
|
||||
// Dark Green
|
||||
DarkGreen Color = NewColor(0, 117, 44, 255)
|
||||
DarkGreen = NewColor(0, 117, 44, 255)
|
||||
// Sky Blue
|
||||
SkyBlue Color = NewColor(102, 191, 255, 255)
|
||||
SkyBlue = NewColor(102, 191, 255, 255)
|
||||
// Blue
|
||||
Blue Color = NewColor(0, 121, 241, 255)
|
||||
Blue = NewColor(0, 121, 241, 255)
|
||||
// Dark Blue
|
||||
DarkBlue Color = NewColor(0, 82, 172, 255)
|
||||
DarkBlue = NewColor(0, 82, 172, 255)
|
||||
// Purple
|
||||
Purple Color = NewColor(200, 122, 255, 255)
|
||||
Purple = NewColor(200, 122, 255, 255)
|
||||
// Violet
|
||||
Violet Color = NewColor(135, 60, 190, 255)
|
||||
Violet = NewColor(135, 60, 190, 255)
|
||||
// Dark Purple
|
||||
DarkPurple Color = NewColor(112, 31, 126, 255)
|
||||
DarkPurple = NewColor(112, 31, 126, 255)
|
||||
// Beige
|
||||
Beige Color = NewColor(211, 176, 131, 255)
|
||||
Beige = NewColor(211, 176, 131, 255)
|
||||
// Brown
|
||||
Brown Color = NewColor(127, 106, 79, 255)
|
||||
Brown = NewColor(127, 106, 79, 255)
|
||||
// Dark Brown
|
||||
DarkBrown Color = NewColor(76, 63, 47, 255)
|
||||
DarkBrown = NewColor(76, 63, 47, 255)
|
||||
// White
|
||||
White Color = NewColor(255, 255, 255, 255)
|
||||
White = NewColor(255, 255, 255, 255)
|
||||
// Black
|
||||
Black Color = NewColor(0, 0, 0, 255)
|
||||
Black = NewColor(0, 0, 0, 255)
|
||||
// Blank (Transparent)
|
||||
Blank Color = NewColor(0, 0, 0, 0)
|
||||
Blank = NewColor(0, 0, 0, 0)
|
||||
// Magenta
|
||||
Magenta Color = NewColor(255, 0, 255, 255)
|
||||
Magenta = NewColor(255, 0, 255, 255)
|
||||
// Ray White (RayLib Logo White)
|
||||
RayWhite Color = NewColor(245, 245, 245, 255)
|
||||
RayWhite = NewColor(245, 245, 245, 255)
|
||||
)
|
||||
|
||||
// Vector2 type
|
||||
|
|
|
@ -28,9 +28,9 @@ type Mesh struct {
|
|||
// Vertex indices (in case vertex data comes indexed)
|
||||
Indices *uint16
|
||||
// OpenGL Vertex Array Object id
|
||||
VaoId uint32
|
||||
VaoID uint32
|
||||
// OpenGL Vertex Buffer Objects id (7 types of vertex data)
|
||||
VboId [7]uint32
|
||||
VboID [7]uint32
|
||||
}
|
||||
|
||||
func (m *Mesh) cptr() *C.Mesh {
|
||||
|
@ -38,8 +38,8 @@ func (m *Mesh) cptr() *C.Mesh {
|
|||
}
|
||||
|
||||
// Returns new Mesh
|
||||
func NewMesh(vertexCount, triangleCount int32, vertices, texcoords, texcoords2, normals, tangents *float32, colors *uint8, indices *uint16, vaoId uint32, vboId [7]uint32) Mesh {
|
||||
return Mesh{vertexCount, triangleCount, vertices, texcoords, texcoords2, normals, tangents, colors, indices, vaoId, vboId}
|
||||
func NewMesh(vertexCount, triangleCount int32, vertices, texcoords, texcoords2, normals, tangents *float32, colors *uint8, indices *uint16, vaoID uint32, vboID [7]uint32) Mesh {
|
||||
return Mesh{vertexCount, triangleCount, vertices, texcoords, texcoords2, normals, tangents, colors, indices, vaoID, vboID}
|
||||
}
|
||||
|
||||
// Returns new Mesh from pointer
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
// rRES file header (8 byte)
|
||||
type RRESFileHeader struct {
|
||||
// File identifier: rRES (4 byte)
|
||||
Id [4]int8
|
||||
ID [4]int8
|
||||
// File version and subversion (2 byte)
|
||||
Version uint16
|
||||
// Number of resources in this file (2 byte)
|
||||
|
@ -22,7 +22,7 @@ type RRESFileHeader struct {
|
|||
// rRES info header, every resource includes this header (16 byte + 16 byte)
|
||||
type RRESInfoHeader struct {
|
||||
// Resource unique identifier (4 byte)
|
||||
Id uint32
|
||||
ID uint32
|
||||
// Resource data type (1 byte)
|
||||
DataType uint8
|
||||
// Resource data compression type (1 byte)
|
||||
|
@ -71,6 +71,7 @@ const (
|
|||
RRESCompBrotli
|
||||
)
|
||||
|
||||
// Image formats
|
||||
const (
|
||||
// 8 bit per pixel (no alpha)
|
||||
RRESImUncompGrayscale = iota + 1
|
||||
|
@ -110,6 +111,7 @@ const (
|
|||
RRESImCompAstc8x8Rgba
|
||||
)
|
||||
|
||||
// RRESVert
|
||||
const (
|
||||
RRESVertPosition = iota
|
||||
RRESVertTexcoord1
|
||||
|
@ -122,6 +124,7 @@ const (
|
|||
RRESVertIndex
|
||||
)
|
||||
|
||||
// RRESVert
|
||||
const (
|
||||
RRESVertByte = iota
|
||||
RRESVertShort
|
||||
|
@ -133,12 +136,12 @@ const (
|
|||
// Load resource from file (only one)
|
||||
// NOTE: Returns uncompressed data with parameters, only first resource found
|
||||
func LoadResource(fileName string) []byte {
|
||||
return LoadResourceById(fileName, 0)
|
||||
return LoadResourceByID(fileName, 0)
|
||||
}
|
||||
|
||||
// Load resource from file by id
|
||||
// NOTE: Returns uncompressed data with parameters, search resource by id
|
||||
func LoadResourceById(fileName string, rresId int) (data []byte) {
|
||||
func LoadResourceByID(fileName string, rresID int) (data []byte) {
|
||||
file, err := os.Open(fileName)
|
||||
if err != nil {
|
||||
TraceLog(LogWarning, "[%s] rRES raylib resource file could not be opened", fileName)
|
||||
|
@ -159,7 +162,7 @@ func LoadResourceById(fileName string, rresId int) (data []byte) {
|
|||
//fmt.Printf("%+v\n", fileHeader)
|
||||
|
||||
// Verify "rRES" identifier
|
||||
id := fmt.Sprintf("%c", fileHeader.Id)
|
||||
id := fmt.Sprintf("%c", fileHeader.ID)
|
||||
if id != "[r R E S]" {
|
||||
TraceLog(LogWarning, "[%s] This is not a valid raylib resource file", fileName)
|
||||
return
|
||||
|
@ -179,7 +182,7 @@ func LoadResourceById(fileName string, rresId int) (data []byte) {
|
|||
|
||||
file.Seek(int64(unsafe.Sizeof(infoHeader)), os.SEEK_CUR)
|
||||
|
||||
if int(infoHeader.Id) == rresId {
|
||||
if int(infoHeader.ID) == rresID {
|
||||
// Read resource data block
|
||||
data = make([]byte, infoHeader.DataSize)
|
||||
file.Read(data)
|
||||
|
@ -194,7 +197,7 @@ func LoadResourceById(fileName string, rresId int) (data []byte) {
|
|||
}
|
||||
|
||||
if len(data) > 0 {
|
||||
TraceLog(LogInfo, "[%s][ID %d] Resource data loaded successfully", fileName, infoHeader.Id)
|
||||
TraceLog(LogInfo, "[%s][ID %d] Resource data loaded successfully", fileName, infoHeader.ID)
|
||||
}
|
||||
} else {
|
||||
// Skip required data to read next resource infoHeader
|
||||
|
@ -203,7 +206,7 @@ func LoadResourceById(fileName string, rresId int) (data []byte) {
|
|||
}
|
||||
|
||||
if len(data) == 0 {
|
||||
TraceLog(LogInfo, "[%s][ID %d] Requested resource could not be found", fileName, rresId)
|
||||
TraceLog(LogInfo, "[%s][ID %d] Requested resource could not be found", fileName, rresID)
|
||||
}
|
||||
|
||||
return
|
||||
|
|
|
@ -8,6 +8,7 @@ import "C"
|
|||
import "unsafe"
|
||||
import "reflect"
|
||||
|
||||
// Vr device
|
||||
type VrDevice int32
|
||||
|
||||
// Head Mounted Display devices
|
||||
|
@ -23,6 +24,7 @@ const (
|
|||
HmdFoveVr VrDevice = C.HMD_FOVE_VR
|
||||
)
|
||||
|
||||
// Blend mode
|
||||
type BlendMode int32
|
||||
|
||||
// Color blending modes (pre-defined)
|
||||
|
@ -35,7 +37,7 @@ const (
|
|||
// Shader type (generic shader)
|
||||
type Shader struct {
|
||||
// Shader program id
|
||||
Id uint32
|
||||
ID uint32
|
||||
// Vertex attribute location point (default-location = 0)
|
||||
VertexLoc int32
|
||||
// Texcoord attribute location point (default-location = 1)
|
||||
|
|
|
@ -7,6 +7,7 @@ package raylib
|
|||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// Texture format
|
||||
type TextureFormat int32
|
||||
|
||||
// Texture formats
|
||||
|
@ -50,6 +51,7 @@ const (
|
|||
CompressedAstc8x8Rgba TextureFormat = C.COMPRESSED_ASTC_8x8_RGBA
|
||||
)
|
||||
|
||||
// Texture filter mode
|
||||
type TextureFilterMode int32
|
||||
|
||||
// Texture parameters: filter mode
|
||||
|
@ -70,6 +72,7 @@ const (
|
|||
FilterAnisotropic16x TextureFilterMode = C.FILTER_ANISOTROPIC_16X
|
||||
)
|
||||
|
||||
// Texture wrap mode
|
||||
type TextureWrapMode int32
|
||||
|
||||
// Texture parameters: wrap mode
|
||||
|
@ -112,7 +115,7 @@ func NewImageFromPointer(ptr unsafe.Pointer) *Image {
|
|||
// NOTE: Data stored in GPU memory
|
||||
type Texture2D struct {
|
||||
// OpenGL texture id
|
||||
Id uint32
|
||||
ID uint32
|
||||
// Texture base width
|
||||
Width int32
|
||||
// Texture base height
|
||||
|
@ -140,7 +143,7 @@ func NewTexture2DFromPointer(ptr unsafe.Pointer) Texture2D {
|
|||
// RenderTexture2D type, for texture rendering
|
||||
type RenderTexture2D struct {
|
||||
// Render texture (fbo) id
|
||||
Id uint32
|
||||
ID uint32
|
||||
// Color buffer attachment texture
|
||||
Texture Texture2D
|
||||
// Depth buffer attachment texture
|
||||
|
|
|
@ -17,6 +17,7 @@ const (
|
|||
|
||||
var traceDebugMsgs = false
|
||||
|
||||
// Trace log
|
||||
func TraceLog(msgType int, text string, v ...interface{}) {
|
||||
switch msgType {
|
||||
case LogInfo:
|
||||
|
@ -33,6 +34,7 @@ func TraceLog(msgType int, text string, v ...interface{}) {
|
|||
}
|
||||
}
|
||||
|
||||
// Set debug messages
|
||||
func SetDebug(enabled bool) {
|
||||
traceDebugMsgs = enabled
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue