Update C sources and examples
|
@ -1,220 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const numTextures = 24
|
||||
|
||||
// Formats
|
||||
const (
|
||||
PngR8g8b8a8 = iota
|
||||
PvrGrayscale
|
||||
PvrGrayAlpha
|
||||
PvrR5g6b5
|
||||
PvrR5g5b5a1
|
||||
PvrR4g4b4a4
|
||||
DdsR5g6b5
|
||||
DdsR5g5b5a1
|
||||
DdsR4g4b4a4
|
||||
DdsR8g8b8a8
|
||||
DdsDxt1Rgb
|
||||
DdsDxt1Rgba
|
||||
DdsDxt3Rgba
|
||||
DdsDxt5Rgba
|
||||
PkmEtc1Rgb
|
||||
PkmEtc2Rgb
|
||||
PkmEtc2EacRgba
|
||||
KtxEtc1Rgb
|
||||
KtxEtc2Rgb
|
||||
KtxEtc2EacRgba
|
||||
Astc4x4Ldr
|
||||
Astc8x8Ldr
|
||||
PvrPvrtRgb
|
||||
PvrPvrtRgba
|
||||
)
|
||||
|
||||
var formatText = []string{
|
||||
"PNG_R8G8B8A8",
|
||||
"PVR_GRAYSCALE",
|
||||
"PVR_GRAY_ALPHA",
|
||||
"PVR_R5G6B5",
|
||||
"PVR_R5G5B5A1",
|
||||
"PVR_R4G4B4A4",
|
||||
"DDS_R5G6B5",
|
||||
"DDS_R5G5B5A1",
|
||||
"DDS_R4G4B4A4",
|
||||
"DDS_R8G8B8A8",
|
||||
"DDS_DXT1_RGB",
|
||||
"DDS_DXT1_RGBA",
|
||||
"DDS_DXT3_RGBA",
|
||||
"DDS_DXT5_RGBA",
|
||||
"PKM_ETC1_RGB",
|
||||
"PKM_ETC2_RGB",
|
||||
"PKM_ETC2_EAC_RGBA",
|
||||
"KTX_ETC1_RGB",
|
||||
"KTX_ETC2_RGB",
|
||||
"KTX_ETC2_EAC_RGBA",
|
||||
"ASTC_4x4_LDR",
|
||||
"ASTC_8x8_LDR",
|
||||
"PVR_PVRT_RGB",
|
||||
"PVR_PVRT_RGBA",
|
||||
}
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture formats loading")
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
|
||||
sonic := make([]raylib.Texture2D, numTextures)
|
||||
|
||||
sonic[PngR8g8b8a8] = raylib.LoadTexture("texture_formats/sonic.png")
|
||||
|
||||
// Load UNCOMPRESSED PVR texture data
|
||||
sonic[PvrGrayscale] = raylib.LoadTexture("texture_formats/sonic_GRAYSCALE.pvr")
|
||||
sonic[PvrGrayAlpha] = raylib.LoadTexture("texture_formats/sonic_L8A8.pvr")
|
||||
sonic[PvrR5g6b5] = raylib.LoadTexture("texture_formats/sonic_R5G6B5.pvr")
|
||||
sonic[PvrR5g5b5a1] = raylib.LoadTexture("texture_formats/sonic_R5G5B5A1.pvr")
|
||||
sonic[PvrR4g4b4a4] = raylib.LoadTexture("texture_formats/sonic_R4G4B4A4.pvr")
|
||||
|
||||
// Load UNCOMPRESSED DDS texture data
|
||||
sonic[DdsR5g6b5] = raylib.LoadTexture("texture_formats/sonic_R5G6B5.dds")
|
||||
sonic[DdsR5g5b5a1] = raylib.LoadTexture("texture_formats/sonic_A1R5G5B5.dds")
|
||||
sonic[DdsR4g4b4a4] = raylib.LoadTexture("texture_formats/sonic_A4R4G4B4.dds")
|
||||
sonic[DdsR8g8b8a8] = raylib.LoadTexture("texture_formats/sonic_A8R8G8B8.dds")
|
||||
|
||||
// Load COMPRESSED DXT DDS texture data (if supported)
|
||||
sonic[DdsDxt1Rgb] = raylib.LoadTexture("texture_formats/sonic_DXT1_RGB.dds")
|
||||
sonic[DdsDxt1Rgba] = raylib.LoadTexture("texture_formats/sonic_DXT1_RGBA.dds")
|
||||
sonic[DdsDxt3Rgba] = raylib.LoadTexture("texture_formats/sonic_DXT3_RGBA.dds")
|
||||
sonic[DdsDxt5Rgba] = raylib.LoadTexture("texture_formats/sonic_DXT5_RGBA.dds")
|
||||
|
||||
// Load COMPRESSED ETC texture data (if supported)
|
||||
sonic[PkmEtc1Rgb] = raylib.LoadTexture("texture_formats/sonic_ETC1_RGB.pkm")
|
||||
sonic[PkmEtc2Rgb] = raylib.LoadTexture("texture_formats/sonic_ETC2_RGB.pkm")
|
||||
sonic[PkmEtc2EacRgba] = raylib.LoadTexture("texture_formats/sonic_ETC2_EAC_RGBA.pkm")
|
||||
|
||||
sonic[KtxEtc1Rgb] = raylib.LoadTexture("texture_formats/sonic_ETC1_RGB.ktx")
|
||||
sonic[KtxEtc2Rgb] = raylib.LoadTexture("texture_formats/sonic_ETC2_RGB.ktx")
|
||||
sonic[KtxEtc2EacRgba] = raylib.LoadTexture("texture_formats/sonic_ETC2_EAC_RGBA.ktx")
|
||||
|
||||
// Load COMPRESSED ASTC texture data (if supported)
|
||||
sonic[Astc4x4Ldr] = raylib.LoadTexture("texture_formats/sonic_ASTC_4x4_ldr.astc")
|
||||
sonic[Astc8x8Ldr] = raylib.LoadTexture("texture_formats/sonic_ASTC_8x8_ldr.astc")
|
||||
|
||||
// Load COMPRESSED PVR texture data (if supported)
|
||||
sonic[PvrPvrtRgb] = raylib.LoadTexture("texture_formats/sonic_PVRT_RGB.pvr")
|
||||
sonic[PvrPvrtRgba] = raylib.LoadTexture("texture_formats/sonic_PVRT_RGBA.pvr")
|
||||
|
||||
selectedFormat := PngR8g8b8a8
|
||||
|
||||
selectRecs := make([]raylib.Rectangle, numTextures)
|
||||
|
||||
for i := 0; i < numTextures; i++ {
|
||||
if i < numTextures/2 {
|
||||
selectRecs[i] = raylib.NewRectangle(40, int32(30+32*i), 150, 30)
|
||||
} else {
|
||||
selectRecs[i] = raylib.NewRectangle(40+152, int32(30+32*(i-numTextures/2)), 150, 30)
|
||||
}
|
||||
}
|
||||
|
||||
// Texture sizes in KB
|
||||
var textureSizes = [numTextures]int{
|
||||
512 * 512 * 32 / 8 / 1024, //PNG_R8G8B8A8 (32 bpp)
|
||||
512 * 512 * 8 / 8 / 1024, //PVR_GRAYSCALE (8 bpp)
|
||||
512 * 512 * 16 / 8 / 1024, //PVR_GRAY_ALPHA (16 bpp)
|
||||
512 * 512 * 16 / 8 / 1024, //PVR_R5G6B5 (16 bpp)
|
||||
512 * 512 * 16 / 8 / 1024, //PVR_R5G5B5A1 (16 bpp)
|
||||
512 * 512 * 16 / 8 / 1024, //PVR_R4G4B4A4 (16 bpp)
|
||||
512 * 512 * 16 / 8 / 1024, //DDS_R5G6B5 (16 bpp)
|
||||
512 * 512 * 16 / 8 / 1024, //DDS_R5G5B5A1 (16 bpp)
|
||||
512 * 512 * 16 / 8 / 1024, //DDS_R4G4B4A4 (16 bpp)
|
||||
512 * 512 * 32 / 8 / 1024, //DDS_R8G8B8A8 (32 bpp)
|
||||
512 * 512 * 4 / 8 / 1024, //DDS_DXT1_RGB (4 bpp) -Compressed-
|
||||
512 * 512 * 4 / 8 / 1024, //DDS_DXT1_RGBA (4 bpp) -Compressed-
|
||||
512 * 512 * 8 / 8 / 1024, //DDS_DXT3_RGBA (8 bpp) -Compressed-
|
||||
512 * 512 * 8 / 8 / 1024, //DDS_DXT5_RGBA (8 bpp) -Compressed-
|
||||
512 * 512 * 4 / 8 / 1024, //PKM_ETC1_RGB (4 bpp) -Compressed-
|
||||
512 * 512 * 4 / 8 / 1024, //PKM_ETC2_RGB (4 bpp) -Compressed-
|
||||
512 * 512 * 8 / 8 / 1024, //PKM_ETC2_EAC_RGBA (8 bpp) -Compressed-
|
||||
512 * 512 * 4 / 8 / 1024, //KTX_ETC1_RGB (4 bpp) -Compressed-
|
||||
512 * 512 * 4 / 8 / 1024, //KTX_ETC2_RGB (4 bpp) -Compressed-
|
||||
512 * 512 * 8 / 8 / 1024, //KTX_ETC2_EAC_RGBA (8 bpp) -Compressed-
|
||||
512 * 512 * 8 / 8 / 1024, //ASTC_4x4_LDR (8 bpp) -Compressed-
|
||||
512 * 512 * 2 / 8 / 1024, //ASTC_8x8_LDR (2 bpp) -Compressed-
|
||||
512 * 512 * 4 / 8 / 1024, //PVR_PVRT_RGB (4 bpp) -Compressed-
|
||||
512 * 512 * 4 / 8 / 1024, //PVR_PVRT_RGBA (4 bpp) -Compressed-
|
||||
}
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
// Update
|
||||
|
||||
if raylib.IsKeyPressed(raylib.KeyDown) {
|
||||
selectedFormat++
|
||||
if selectedFormat >= numTextures {
|
||||
selectedFormat = 0
|
||||
}
|
||||
} else if raylib.IsKeyPressed(raylib.KeyUp) {
|
||||
selectedFormat--
|
||||
if selectedFormat < 0 {
|
||||
selectedFormat = numTextures - 1
|
||||
}
|
||||
} else if raylib.IsKeyPressed(raylib.KeyRight) {
|
||||
if selectedFormat < numTextures/2 {
|
||||
selectedFormat += numTextures / 2
|
||||
}
|
||||
} else if raylib.IsKeyPressed(raylib.KeyLeft) {
|
||||
if selectedFormat >= numTextures/2 {
|
||||
selectedFormat -= numTextures / 2
|
||||
}
|
||||
}
|
||||
|
||||
// Draw
|
||||
|
||||
raylib.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
|
||||
// Draw rectangles
|
||||
for i := 0; i < numTextures; i++ {
|
||||
if i == selectedFormat {
|
||||
raylib.DrawRectangleRec(selectRecs[i], raylib.SkyBlue)
|
||||
raylib.DrawRectangleLines(selectRecs[i].X, selectRecs[i].Y, selectRecs[i].Width, selectRecs[i].Height, raylib.Blue)
|
||||
raylib.DrawText(formatText[i], selectRecs[i].X+selectRecs[i].Width/2-raylib.MeasureText(formatText[i], 10)/2, selectRecs[i].Y+11, 10, raylib.DarkBlue)
|
||||
} else {
|
||||
raylib.DrawRectangleRec(selectRecs[i], raylib.LightGray)
|
||||
raylib.DrawRectangleLines(selectRecs[i].X, selectRecs[i].Y, selectRecs[i].Width, selectRecs[i].Height, raylib.Gray)
|
||||
raylib.DrawText(formatText[i], selectRecs[i].X+selectRecs[i].Width/2-raylib.MeasureText(formatText[i], 10)/2, selectRecs[i].Y+11, 10, raylib.DarkGray)
|
||||
}
|
||||
}
|
||||
|
||||
// Draw selected texture
|
||||
if sonic[selectedFormat].ID != 0 {
|
||||
raylib.DrawTexture(sonic[selectedFormat], 350, -10, raylib.White)
|
||||
} else {
|
||||
raylib.DrawRectangleLines(488, 165, 200, 110, raylib.DarkGray)
|
||||
raylib.DrawText("FORMAT", 550, 180, 20, raylib.Maroon)
|
||||
raylib.DrawText("NOT SUPPORTED", 500, 210, 20, raylib.Maroon)
|
||||
raylib.DrawText("ON YOUR GPU", 520, 240, 20, raylib.Maroon)
|
||||
}
|
||||
|
||||
raylib.DrawText("Select texture format (use cursor keys):", 40, 10, 10, raylib.DarkGray)
|
||||
raylib.DrawText("Required GPU memory size (VRAM):", 40, 427, 10, raylib.DarkGray)
|
||||
raylib.DrawText(fmt.Sprintf("%4.0d KB", textureSizes[selectedFormat]), 240, 420, 20, raylib.DarkBlue)
|
||||
|
||||
raylib.EndDrawing()
|
||||
}
|
||||
|
||||
for i := 0; i < numTextures; i++ {
|
||||
raylib.UnloadTexture(sonic[i])
|
||||
}
|
||||
|
||||
raylib.CloseWindow()
|
||||
}
|
Before Width: | Height: | Size: 114 KiB |
|
@ -22,7 +22,7 @@ func main() {
|
|||
screenHeight := int32(450)
|
||||
|
||||
//raylib.SetConfigFlags(raylib.FlagVsyncHint)
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles trail blending")
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [textures] example - particles blending")
|
||||
|
||||
// Particles pool, reuse them!
|
||||
mouseTail := make([]particle, maxParticles)
|
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 15 KiB |
|
@ -12,10 +12,10 @@ func main() {
|
|||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
|
||||
// Load RAW image data (512x512, 32bit RGBA, no file header)
|
||||
sonicRaw := raylib.LoadImageRaw("texture_formats/sonic_R8G8B8A8.raw", 512, 512, raylib.UncompressedR8g8b8a8, 0)
|
||||
sonic := raylib.LoadTextureFromImage(sonicRaw) // Upload CPU (RAM) image to GPU (VRAM)
|
||||
raylib.UnloadImage(sonicRaw) // Unload CPU (RAM) image data
|
||||
// Load RAW image data (384x512, 32bit RGBA, no file header)
|
||||
fudesumiRaw := raylib.LoadImageRaw("texture_formats/fudesumi.raw", 384, 512, raylib.UncompressedR8g8b8a8, 0)
|
||||
fudesumi := raylib.LoadTextureFromImage(fudesumiRaw) // Upload CPU (RAM) image to GPU (VRAM)
|
||||
raylib.UnloadImage(fudesumiRaw) // Unload CPU (RAM) image data
|
||||
|
||||
// Generate a checked texture by code (1024x1024 pixels)
|
||||
width := 1024
|
||||
|
@ -27,9 +27,9 @@ func main() {
|
|||
for y := 0; y < height; y++ {
|
||||
for x := 0; x < width; x++ {
|
||||
if ((x/32+y/32)/1)%2 == 0 {
|
||||
pixels[y*height+x] = raylib.DarkBlue
|
||||
pixels[y*height+x] = raylib.Orange
|
||||
} else {
|
||||
pixels[y*height+x] = raylib.SkyBlue
|
||||
pixels[y*height+x] = raylib.Gold
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,18 +46,18 @@ func main() {
|
|||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
|
||||
raylib.DrawTexture(checked, screenWidth/2-checked.Width/2, screenHeight/2-checked.Height/2, raylib.Fade(raylib.White, 0.3))
|
||||
raylib.DrawTexture(sonic, 330, -20, raylib.White)
|
||||
raylib.DrawTexture(checked, screenWidth/2-checked.Width/2, screenHeight/2-checked.Height/2, raylib.Fade(raylib.White, 0.5))
|
||||
raylib.DrawTexture(fudesumi, 430, -30, raylib.White)
|
||||
|
||||
raylib.DrawText("CHECKED TEXTURE ", 84, 100, 30, raylib.DarkBlue)
|
||||
raylib.DrawText("GENERATED by CODE", 72, 164, 30, raylib.DarkBlue)
|
||||
raylib.DrawText("and RAW IMAGE LOADING", 46, 226, 30, raylib.DarkBlue)
|
||||
raylib.DrawText("CHECKED TEXTURE ", 84, 100, 30, raylib.Brown)
|
||||
raylib.DrawText("GENERATED by CODE", 72, 164, 30, raylib.Brown)
|
||||
raylib.DrawText("and RAW IMAGE LOADING", 46, 226, 30, raylib.Brown)
|
||||
|
||||
raylib.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadTexture(sonic) // Texture unloading
|
||||
raylib.UnloadTexture(checked) // Texture unloading
|
||||
raylib.UnloadTexture(fudesumi) // Texture unloading
|
||||
raylib.UnloadTexture(checked) // Texture unloading
|
||||
|
||||
raylib.CloseWindow()
|
||||
}
|
||||
|
|
BIN
examples/textures/raw_data/texture_formats/fudesumi.raw
Normal file
Before Width: | Height: | Size: 83 KiB |
|
@ -1,9 +1,16 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gen2brain/raylib-go/raylib"
|
||||
)
|
||||
|
||||
const (
|
||||
maxFrameSpeed = 15
|
||||
minFrameSpeed = 1
|
||||
)
|
||||
|
||||
func main() {
|
||||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
@ -11,47 +18,70 @@ func main() {
|
|||
raylib.InitWindow(screenWidth, screenHeight, "raylib [textures] example - texture loading and drawing")
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
guybrush := raylib.LoadTexture("guybrush.png") // Texture loading
|
||||
scarfy := raylib.LoadTexture("scarfy.png") // Texture loading
|
||||
|
||||
position := raylib.NewVector2(350.0, 240.0)
|
||||
frameRec := raylib.NewRectangle(0, 0, guybrush.Width/7, guybrush.Height)
|
||||
position := raylib.NewVector2(350.0, 280.0)
|
||||
frameRec := raylib.NewRectangle(0, 0, scarfy.Width/6, scarfy.Height)
|
||||
currentFrame := int32(0)
|
||||
|
||||
framesCounter := 0
|
||||
framesSpeed := 8 // Number of spritesheet frames shown by second
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
if raylib.IsKeyPressed(raylib.KeyRight) {
|
||||
framesCounter++
|
||||
|
||||
if framesCounter >= (60 / framesSpeed) {
|
||||
framesCounter = 0
|
||||
currentFrame++
|
||||
|
||||
if currentFrame > 6 {
|
||||
if currentFrame > 5 {
|
||||
currentFrame = 0
|
||||
}
|
||||
|
||||
frameRec.X = currentFrame * guybrush.Width / 7
|
||||
frameRec.X = currentFrame * scarfy.Width / 6
|
||||
}
|
||||
|
||||
if raylib.IsKeyPressed(raylib.KeyRight) {
|
||||
framesSpeed++
|
||||
} else if raylib.IsKeyPressed(raylib.KeyLeft) {
|
||||
framesSpeed--
|
||||
}
|
||||
|
||||
if framesSpeed > maxFrameSpeed {
|
||||
framesSpeed = maxFrameSpeed
|
||||
} else if framesSpeed < minFrameSpeed {
|
||||
framesSpeed = minFrameSpeed
|
||||
}
|
||||
|
||||
raylib.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
|
||||
raylib.DrawTexture(guybrush, 35, 40, raylib.White)
|
||||
raylib.DrawRectangleLines(35, 40, guybrush.Width, guybrush.Height, raylib.Lime)
|
||||
raylib.DrawTexture(scarfy, 15, 40, raylib.White)
|
||||
raylib.DrawRectangleLines(15, 40, scarfy.Width, scarfy.Height, raylib.Lime)
|
||||
raylib.DrawRectangleLines(15+frameRec.X, 40+frameRec.Y, frameRec.Width, frameRec.Height, raylib.Red)
|
||||
|
||||
raylib.DrawTextureRec(guybrush, frameRec, position, raylib.White) // Draw part of the texture
|
||||
raylib.DrawText("FRAME SPEED: ", 165, 210, 10, raylib.DarkGray)
|
||||
raylib.DrawText(fmt.Sprintf("%02d FPS", framesSpeed), 575, 210, 10, raylib.DarkGray)
|
||||
raylib.DrawText("PRESS RIGHT/LEFT KEYS to CHANGE SPEED!", 290, 240, 10, raylib.DarkGray)
|
||||
|
||||
raylib.DrawRectangleLines(35+frameRec.X, 40+frameRec.Y, frameRec.Width, frameRec.Height, raylib.Red)
|
||||
for i := 0; i < maxFrameSpeed; i++ {
|
||||
if i < framesSpeed {
|
||||
raylib.DrawRectangle(int32(250+21*i), 205, 20, 20, raylib.Red)
|
||||
}
|
||||
raylib.DrawRectangleLines(int32(250+21*i), 205, 20, 20, raylib.Maroon)
|
||||
}
|
||||
|
||||
raylib.DrawText("PRESS RIGHT KEY TO", 540, 310, 10, raylib.Gray)
|
||||
raylib.DrawText("CHANGE DRAWING RECTANGLE", 520, 330, 10, raylib.Gray)
|
||||
raylib.DrawTextureRec(scarfy, frameRec, position, raylib.White) // Draw part of the texture
|
||||
|
||||
raylib.DrawText("Guybrush Ulysses Threepwood,", 100, 300, 10, raylib.Gray)
|
||||
raylib.DrawText("main character of the Monkey Island series", 80, 320, 10, raylib.Gray)
|
||||
raylib.DrawText("of computer adventure games by LucasArts.", 80, 340, 10, raylib.Gray)
|
||||
raylib.DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth-200, screenHeight-20, 10, raylib.Gray)
|
||||
|
||||
raylib.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadTexture(guybrush)
|
||||
raylib.UnloadTexture(scarfy)
|
||||
|
||||
raylib.CloseWindow()
|
||||
}
|
||||
|
|
BIN
examples/textures/rectangle/scarfy.png
Normal file
After Width: | Height: | Size: 32 KiB |
Before Width: | Height: | Size: 83 KiB |
|
@ -11,10 +11,10 @@ func main() {
|
|||
raylib.InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles")
|
||||
|
||||
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
|
||||
guybrush := raylib.LoadTexture("guybrush.png") // Texture loading
|
||||
scarfy := raylib.LoadTexture("scarfy.png") // Texture loading
|
||||
|
||||
frameWidth := guybrush.Width / 7
|
||||
frameHeight := guybrush.Height
|
||||
frameWidth := scarfy.Width / 7
|
||||
frameHeight := scarfy.Height
|
||||
|
||||
// NOTE: Source rectangle (part of the texture to use for drawing)
|
||||
sourceRec := raylib.NewRectangle(0, 0, int32(frameWidth), int32(frameHeight))
|
||||
|
@ -43,15 +43,17 @@ func main() {
|
|||
// destRec defines the rectangle where our texture part will fit (scaling it to fit)
|
||||
// origin defines the point of the texture used as reference for rotation and scaling
|
||||
// rotation defines the texture rotation (using origin as rotation point)
|
||||
raylib.DrawTexturePro(guybrush, sourceRec, destRec, origin, rotation, raylib.White)
|
||||
raylib.DrawTexturePro(scarfy, sourceRec, destRec, origin, rotation, raylib.White)
|
||||
|
||||
raylib.DrawLine(destRec.X, 0, destRec.X, screenHeight, raylib.Gray)
|
||||
raylib.DrawLine(0, destRec.Y, screenWidth, destRec.Y, raylib.Gray)
|
||||
|
||||
raylib.DrawText("(c) Scarfy sprite by Eiden Marsal", screenWidth-200, screenHeight-20, 10, raylib.Gray)
|
||||
|
||||
raylib.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadTexture(guybrush)
|
||||
raylib.UnloadTexture(scarfy)
|
||||
|
||||
raylib.CloseWindow()
|
||||
}
|
||||
|
|
BIN
examples/textures/srcrec_dstrec/scarfy.png
Normal file
After Width: | Height: | Size: 32 KiB |