Update C sources, add new functions and rename package to
This commit is contained in:
parent
391c25482d
commit
08aa518a46
156 changed files with 34542 additions and 19573 deletions
|
@ -8,90 +8,90 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.SetConfigFlags(raylib.FlagMsaa4xHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - custom uniform variable")
|
||||
|
||||
camera := raylib.Camera{}
|
||||
camera.Position = raylib.NewVector3(3.0, 3.0, 3.0)
|
||||
camera.Target = raylib.NewVector3(0.0, 1.5, 0.0)
|
||||
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(3.0, 3.0, 3.0)
|
||||
camera.Target = rl.NewVector3(0.0, 1.5, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
|
||||
dwarf := raylib.LoadModel("dwarf.obj") // Load OBJ model
|
||||
texture := raylib.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
|
||||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
|
||||
dwarf.Material.Maps[raylib.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
||||
dwarf.Material.Maps[rl.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
||||
|
||||
position := raylib.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||
|
||||
shader := raylib.LoadShader("glsl330/base.vs", "glsl330/swirl.fs") // Load postpro shader
|
||||
shader := rl.LoadShader("glsl330/base.vs", "glsl330/swirl.fs") // Load postpro shader
|
||||
|
||||
// Get variable (uniform) location on the shader to connect with the program
|
||||
// NOTE: If uniform variable could not be found in the shader, function returns -1
|
||||
swirlCenterLoc := raylib.GetShaderLocation(shader, "center")
|
||||
swirlCenterLoc := rl.GetShaderLocation(shader, "center")
|
||||
|
||||
swirlCenter := make([]float32, 2)
|
||||
swirlCenter[0] = float32(screenWidth) / 2
|
||||
swirlCenter[1] = float32(screenHeight) / 2
|
||||
|
||||
// Create a RenderTexture2D to be used for render to texture
|
||||
target := raylib.LoadRenderTexture(screenWidth, screenHeight)
|
||||
target := rl.LoadRenderTexture(screenWidth, screenHeight)
|
||||
|
||||
// Setup orbital camera
|
||||
raylib.SetCameraMode(camera, raylib.CameraOrbital) // Set an orbital camera mode
|
||||
rl.SetCameraMode(camera, rl.CameraOrbital) // Set an orbital camera mode
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
for !rl.WindowShouldClose() {
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
mousePosition := raylib.GetMousePosition()
|
||||
mousePosition := rl.GetMousePosition()
|
||||
|
||||
swirlCenter[0] = mousePosition.X
|
||||
swirlCenter[1] = float32(screenHeight) - mousePosition.Y
|
||||
|
||||
// Send new value to the shader to be used on drawing
|
||||
raylib.SetShaderValue(shader, swirlCenterLoc, swirlCenter, 2)
|
||||
rl.SetShaderValue(shader, swirlCenterLoc, swirlCenter, 2)
|
||||
|
||||
raylib.UpdateCamera(&camera) // Update camera
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
raylib.BeginDrawing()
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.BeginTextureMode(target) // Enable drawing to texture
|
||||
rl.BeginTextureMode(target) // Enable drawing to texture
|
||||
|
||||
raylib.BeginMode3D(camera)
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
raylib.DrawModel(dwarf, position, 2.0, raylib.White) // Draw 3d model with texture
|
||||
rl.DrawModel(dwarf, position, 2.0, rl.White) // Draw 3d model with texture
|
||||
|
||||
raylib.DrawGrid(10, 1.0) // Draw a grid
|
||||
rl.DrawGrid(10, 1.0) // Draw a grid
|
||||
|
||||
raylib.EndMode3D()
|
||||
rl.EndMode3D()
|
||||
|
||||
raylib.DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, raylib.Red)
|
||||
rl.DrawText("TEXT DRAWN IN RENDER TEXTURE", 200, 10, 30, rl.Red)
|
||||
|
||||
raylib.EndTextureMode() // End drawing to texture (now we have a texture available for next passes)
|
||||
rl.EndTextureMode() // End drawing to texture (now we have a texture available for next passes)
|
||||
|
||||
raylib.BeginShaderMode(shader)
|
||||
rl.BeginShaderMode(shader)
|
||||
|
||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||
raylib.DrawTextureRec(target.Texture, raylib.NewRectangle(0, 0, float32(target.Texture.Width), float32(-target.Texture.Height)), raylib.NewVector2(0, 0), raylib.White)
|
||||
rl.DrawTextureRec(target.Texture, rl.NewRectangle(0, 0, float32(target.Texture.Width), float32(-target.Texture.Height)), rl.NewVector2(0, 0), rl.White)
|
||||
|
||||
raylib.EndShaderMode()
|
||||
rl.EndShaderMode()
|
||||
|
||||
raylib.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, raylib.Gray)
|
||||
rl.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, rl.Gray)
|
||||
|
||||
raylib.DrawFPS(10, 10)
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadShader(shader) // Unload shader
|
||||
raylib.UnloadTexture(texture) // Unload texture
|
||||
raylib.UnloadModel(dwarf) // Unload model
|
||||
raylib.UnloadRenderTexture(target) // Unload render texture
|
||||
rl.UnloadShader(shader) // Unload shader
|
||||
rl.UnloadTexture(texture) // Unload texture
|
||||
rl.UnloadModel(dwarf) // Unload model
|
||||
rl.UnloadRenderTexture(target) // Unload render texture
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -10,57 +10,57 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.SetConfigFlags(raylib.FlagMsaa4xHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - model shader")
|
||||
|
||||
camera := raylib.Camera{}
|
||||
camera.Position = raylib.NewVector3(3.0, 3.0, 3.0)
|
||||
camera.Target = raylib.NewVector3(0.0, 1.5, 0.0)
|
||||
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(3.0, 3.0, 3.0)
|
||||
camera.Target = rl.NewVector3(0.0, 1.5, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
|
||||
dwarf := raylib.LoadModel("dwarf.obj") // Load OBJ model
|
||||
texture := raylib.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
shader := raylib.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs") // Load model shader
|
||||
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
|
||||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
shader := rl.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs") // Load model shader
|
||||
|
||||
dwarf.Material.Shader = shader // Set shader effect to 3d model
|
||||
dwarf.Material.Maps[raylib.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
||||
dwarf.Material.Maps[rl.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
||||
|
||||
position := raylib.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||
|
||||
raylib.SetCameraMode(camera, raylib.CameraFree) // Set free camera mode
|
||||
rl.SetCameraMode(camera, rl.CameraFree) // Set free camera mode
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
raylib.UpdateCamera(&camera) // Update camera
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
raylib.BeginDrawing()
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.BeginMode3D(camera)
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
raylib.DrawModel(dwarf, position, 2.0, raylib.White) // Draw 3d model with texture
|
||||
rl.DrawModel(dwarf, position, 2.0, rl.White) // Draw 3d model with texture
|
||||
|
||||
raylib.DrawGrid(10, 1.0) // Draw a grid
|
||||
rl.DrawGrid(10, 1.0) // Draw a grid
|
||||
|
||||
raylib.EndMode3D()
|
||||
rl.EndMode3D()
|
||||
|
||||
raylib.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, raylib.Gray)
|
||||
rl.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, rl.Gray)
|
||||
|
||||
raylib.DrawText(fmt.Sprintf("Camera position: (%.2f, %.2f, %.2f)", camera.Position.X, camera.Position.Y, camera.Position.Z), 600, 20, 10, raylib.Black)
|
||||
raylib.DrawText(fmt.Sprintf("Camera target: (%.2f, %.2f, %.2f)", camera.Target.X, camera.Target.Y, camera.Target.Z), 600, 40, 10, raylib.Gray)
|
||||
rl.DrawText(fmt.Sprintf("Camera position: (%.2f, %.2f, %.2f)", camera.Position.X, camera.Position.Y, camera.Position.Z), 600, 20, 10, rl.Black)
|
||||
rl.DrawText(fmt.Sprintf("Camera target: (%.2f, %.2f, %.2f)", camera.Target.X, camera.Target.Y, camera.Target.Z), 600, 40, 10, rl.Gray)
|
||||
|
||||
raylib.DrawFPS(10, 10)
|
||||
rl.DrawFPS(10, 10)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadShader(shader) // Unload shader
|
||||
raylib.UnloadTexture(texture) // Unload texture
|
||||
raylib.UnloadModel(dwarf) // Unload model
|
||||
rl.UnloadShader(shader) // Unload shader
|
||||
rl.UnloadTexture(texture) // Unload texture
|
||||
rl.UnloadModel(dwarf) // Unload model
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -40,53 +40,53 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.SetConfigFlags(raylib.FlagMsaa4xHint | raylib.FlagVsyncHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||
rl.SetConfigFlags(rl.FlagMsaa4xHint | rl.FlagVsyncHint) // Enable Multi Sampling Anti Aliasing 4x (if available)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader")
|
||||
|
||||
camera := raylib.Camera{}
|
||||
camera.Position = raylib.NewVector3(3.0, 3.0, 3.0)
|
||||
camera.Target = raylib.NewVector3(0.0, 1.5, 0.0)
|
||||
camera.Up = raylib.NewVector3(0.0, 1.0, 0.0)
|
||||
camera := rl.Camera{}
|
||||
camera.Position = rl.NewVector3(3.0, 3.0, 3.0)
|
||||
camera.Target = rl.NewVector3(0.0, 1.5, 0.0)
|
||||
camera.Up = rl.NewVector3(0.0, 1.0, 0.0)
|
||||
camera.Fovy = 45.0
|
||||
|
||||
dwarf := raylib.LoadModel("dwarf.obj") // Load OBJ model
|
||||
texture := raylib.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
dwarf.Material.Maps[raylib.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
||||
dwarf := rl.LoadModel("dwarf.obj") // Load OBJ model
|
||||
texture := rl.LoadTexture("dwarf_diffuse.png") // Load model texture
|
||||
dwarf.Material.Maps[rl.MapDiffuse].Texture = texture // Set dwarf model diffuse texture
|
||||
|
||||
position := raylib.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||
position := rl.NewVector3(0.0, 0.0, 0.0) // Set model position
|
||||
|
||||
// Load all postpro shaders
|
||||
// NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
|
||||
shaders := make([]raylib.Shader, MaxPostproShaders)
|
||||
shaders[FxGrayscale] = raylib.LoadShader("", "glsl330/grayscale.fs")
|
||||
shaders[FxPosterization] = raylib.LoadShader("", "glsl330/posterization.fs")
|
||||
shaders[FxDreamVision] = raylib.LoadShader("", "glsl330/dream_vision.fs")
|
||||
shaders[FxPixelizer] = raylib.LoadShader("", "glsl330/pixelizer.fs")
|
||||
shaders[FxCrossHatching] = raylib.LoadShader("", "glsl330/cross_hatching.fs")
|
||||
shaders[FxCrossStitching] = raylib.LoadShader("", "glsl330/cross_stitching.fs")
|
||||
shaders[FxPredatorView] = raylib.LoadShader("", "glsl330/predator.fs")
|
||||
shaders[FxScanlines] = raylib.LoadShader("", "glsl330/scanlines.fs")
|
||||
shaders[FxFisheye] = raylib.LoadShader("", "glsl330/fisheye.fs")
|
||||
shaders[FxSobel] = raylib.LoadShader("", "glsl330/sobel.fs")
|
||||
shaders[FxBlur] = raylib.LoadShader("", "glsl330/blur.fs")
|
||||
shaders[FxBloom] = raylib.LoadShader("", "glsl330/bloom.fs")
|
||||
shaders := make([]rl.Shader, MaxPostproShaders)
|
||||
shaders[FxGrayscale] = rl.LoadShader("", "glsl330/grayscale.fs")
|
||||
shaders[FxPosterization] = rl.LoadShader("", "glsl330/posterization.fs")
|
||||
shaders[FxDreamVision] = rl.LoadShader("", "glsl330/dream_vision.fs")
|
||||
shaders[FxPixelizer] = rl.LoadShader("", "glsl330/pixelizer.fs")
|
||||
shaders[FxCrossHatching] = rl.LoadShader("", "glsl330/cross_hatching.fs")
|
||||
shaders[FxCrossStitching] = rl.LoadShader("", "glsl330/cross_stitching.fs")
|
||||
shaders[FxPredatorView] = rl.LoadShader("", "glsl330/predator.fs")
|
||||
shaders[FxScanlines] = rl.LoadShader("", "glsl330/scanlines.fs")
|
||||
shaders[FxFisheye] = rl.LoadShader("", "glsl330/fisheye.fs")
|
||||
shaders[FxSobel] = rl.LoadShader("", "glsl330/sobel.fs")
|
||||
shaders[FxBlur] = rl.LoadShader("", "glsl330/blur.fs")
|
||||
shaders[FxBloom] = rl.LoadShader("", "glsl330/bloom.fs")
|
||||
|
||||
currentShader := FxGrayscale
|
||||
|
||||
// Create a RenderTexture2D to be used for render to texture
|
||||
target := raylib.LoadRenderTexture(screenWidth, screenHeight)
|
||||
target := rl.LoadRenderTexture(screenWidth, screenHeight)
|
||||
|
||||
raylib.SetCameraMode(camera, raylib.CameraOrbital) // Set free camera mode
|
||||
rl.SetCameraMode(camera, rl.CameraOrbital) // Set free camera mode
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
raylib.UpdateCamera(&camera) // Update camera
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.UpdateCamera(&camera) // Update camera
|
||||
|
||||
if raylib.IsKeyPressed(raylib.KeyRight) {
|
||||
if rl.IsKeyPressed(rl.KeyRight) {
|
||||
currentShader++
|
||||
} else if raylib.IsKeyPressed(raylib.KeyLeft) {
|
||||
} else if rl.IsKeyPressed(rl.KeyLeft) {
|
||||
currentShader--
|
||||
}
|
||||
|
||||
|
@ -96,51 +96,51 @@ func main() {
|
|||
currentShader = MaxPostproShaders - 1
|
||||
}
|
||||
|
||||
raylib.BeginDrawing()
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
raylib.BeginTextureMode(target) // Enable drawing to texture
|
||||
rl.BeginTextureMode(target) // Enable drawing to texture
|
||||
|
||||
raylib.BeginMode3D(camera)
|
||||
rl.BeginMode3D(camera)
|
||||
|
||||
raylib.DrawModel(dwarf, position, 2.0, raylib.White) // Draw 3d model with texture
|
||||
rl.DrawModel(dwarf, position, 2.0, rl.White) // Draw 3d model with texture
|
||||
|
||||
raylib.DrawGrid(10, 1.0) // Draw a grid
|
||||
rl.DrawGrid(10, 1.0) // Draw a grid
|
||||
|
||||
raylib.EndMode3D()
|
||||
rl.EndMode3D()
|
||||
|
||||
raylib.EndTextureMode() // End drawing to texture (now we have a texture available for next passes)
|
||||
rl.EndTextureMode() // End drawing to texture (now we have a texture available for next passes)
|
||||
|
||||
// Render previously generated texture using selected postpro shader
|
||||
raylib.BeginShaderMode(shaders[currentShader])
|
||||
rl.BeginShaderMode(shaders[currentShader])
|
||||
|
||||
// NOTE: Render texture must be y-flipped due to default OpenGL coordinates (left-bottom)
|
||||
raylib.DrawTextureRec(target.Texture, raylib.NewRectangle(0, 0, float32(target.Texture.Width), float32(-target.Texture.Height)), raylib.NewVector2(0, 0), raylib.White)
|
||||
rl.DrawTextureRec(target.Texture, rl.NewRectangle(0, 0, float32(target.Texture.Width), float32(-target.Texture.Height)), rl.NewVector2(0, 0), rl.White)
|
||||
|
||||
raylib.EndShaderMode()
|
||||
rl.EndShaderMode()
|
||||
|
||||
raylib.DrawRectangle(0, 9, 580, 30, raylib.Fade(raylib.LightGray, 0.7))
|
||||
rl.DrawRectangle(0, 9, 580, 30, rl.Fade(rl.LightGray, 0.7))
|
||||
|
||||
raylib.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, raylib.DarkGray)
|
||||
rl.DrawText("(c) Dwarf 3D model by David Moreno", screenWidth-200, screenHeight-20, 10, rl.DarkGray)
|
||||
|
||||
raylib.DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, raylib.Black)
|
||||
raylib.DrawText(postproShaderText[currentShader], 330, 15, 20, raylib.Red)
|
||||
raylib.DrawText("< >", 540, 10, 30, raylib.DarkBlue)
|
||||
rl.DrawText("CURRENT POSTPRO SHADER:", 10, 15, 20, rl.Black)
|
||||
rl.DrawText(postproShaderText[currentShader], 330, 15, 20, rl.Red)
|
||||
rl.DrawText("< >", 540, 10, 30, rl.DarkBlue)
|
||||
|
||||
raylib.DrawFPS(700, 15)
|
||||
rl.DrawFPS(700, 15)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
// Unload all postpro shaders
|
||||
for i := 0; i < MaxPostproShaders; i++ {
|
||||
raylib.UnloadShader(shaders[i])
|
||||
rl.UnloadShader(shaders[i])
|
||||
}
|
||||
|
||||
raylib.UnloadTexture(texture) // Unload texture
|
||||
raylib.UnloadModel(dwarf) // Unload model
|
||||
raylib.UnloadRenderTexture(target) // Unload render texture
|
||||
rl.UnloadTexture(texture) // Unload texture
|
||||
rl.UnloadModel(dwarf) // Unload model
|
||||
rl.UnloadRenderTexture(target) // Unload render texture
|
||||
|
||||
raylib.CloseWindow()
|
||||
rl.CloseWindow()
|
||||
}
|
||||
|
|
|
@ -8,67 +8,67 @@ func main() {
|
|||
screenWidth := int32(800)
|
||||
screenHeight := int32(450)
|
||||
|
||||
raylib.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders")
|
||||
rl.InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shapes and texture shaders")
|
||||
|
||||
fudesumi := raylib.LoadTexture("fudesumi.png")
|
||||
fudesumi := rl.LoadTexture("fudesumi.png")
|
||||
|
||||
// NOTE: Using GLSL 330 shader version, on OpenGL ES 2.0 use GLSL 100 shader version
|
||||
shader := raylib.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs")
|
||||
shader := rl.LoadShader("glsl330/base.vs", "glsl330/grayscale.fs")
|
||||
|
||||
raylib.SetTargetFPS(60)
|
||||
rl.SetTargetFPS(60)
|
||||
|
||||
for !raylib.WindowShouldClose() {
|
||||
raylib.BeginDrawing()
|
||||
for !rl.WindowShouldClose() {
|
||||
rl.BeginDrawing()
|
||||
|
||||
raylib.ClearBackground(raylib.RayWhite)
|
||||
rl.ClearBackground(rl.RayWhite)
|
||||
|
||||
// Start drawing with default shader
|
||||
|
||||
raylib.DrawText("USING DEFAULT SHADER", 20, 40, 10, raylib.Red)
|
||||
rl.DrawText("USING DEFAULT SHADER", 20, 40, 10, rl.Red)
|
||||
|
||||
raylib.DrawCircle(80, 120, 35, raylib.DarkBlue)
|
||||
raylib.DrawCircleGradient(80, 220, 60, raylib.Green, raylib.SkyBlue)
|
||||
raylib.DrawCircleLines(80, 340, 80, raylib.DarkBlue)
|
||||
rl.DrawCircle(80, 120, 35, rl.DarkBlue)
|
||||
rl.DrawCircleGradient(80, 220, 60, rl.Green, rl.SkyBlue)
|
||||
rl.DrawCircleLines(80, 340, 80, rl.DarkBlue)
|
||||
|
||||
// Activate our custom shader to be applied on next shapes/textures drawings
|
||||
raylib.BeginShaderMode(shader)
|
||||
rl.BeginShaderMode(shader)
|
||||
|
||||
raylib.DrawText("USING CUSTOM SHADER", 190, 40, 10, raylib.Red)
|
||||
rl.DrawText("USING CUSTOM SHADER", 190, 40, 10, rl.Red)
|
||||
|
||||
raylib.DrawRectangle(250-60, 90, 120, 60, raylib.Red)
|
||||
raylib.DrawRectangleGradientH(250-90, 170, 180, 130, raylib.Maroon, raylib.Gold)
|
||||
raylib.DrawRectangleLines(250-40, 320, 80, 60, raylib.Orange)
|
||||
rl.DrawRectangle(250-60, 90, 120, 60, rl.Red)
|
||||
rl.DrawRectangleGradientH(250-90, 170, 180, 130, rl.Maroon, rl.Gold)
|
||||
rl.DrawRectangleLines(250-40, 320, 80, 60, rl.Orange)
|
||||
|
||||
// Activate our default shader for next drawings
|
||||
raylib.EndShaderMode()
|
||||
rl.EndShaderMode()
|
||||
|
||||
raylib.DrawText("USING DEFAULT SHADER", 370, 40, 10, raylib.Red)
|
||||
rl.DrawText("USING DEFAULT SHADER", 370, 40, 10, rl.Red)
|
||||
|
||||
raylib.DrawTriangle(raylib.NewVector2(430, 80),
|
||||
raylib.NewVector2(430-60, 150),
|
||||
raylib.NewVector2(430+60, 150), raylib.Violet)
|
||||
rl.DrawTriangle(rl.NewVector2(430, 80),
|
||||
rl.NewVector2(430-60, 150),
|
||||
rl.NewVector2(430+60, 150), rl.Violet)
|
||||
|
||||
raylib.DrawTriangleLines(raylib.NewVector2(430, 160),
|
||||
raylib.NewVector2(430-20, 230),
|
||||
raylib.NewVector2(430+20, 230), raylib.DarkBlue)
|
||||
rl.DrawTriangleLines(rl.NewVector2(430, 160),
|
||||
rl.NewVector2(430-20, 230),
|
||||
rl.NewVector2(430+20, 230), rl.DarkBlue)
|
||||
|
||||
raylib.DrawPoly(raylib.NewVector2(430, 320), 6, 80, 0, raylib.Brown)
|
||||
rl.DrawPoly(rl.NewVector2(430, 320), 6, 80, 0, rl.Brown)
|
||||
|
||||
// Activate our custom shader to be applied on next shapes/textures drawings
|
||||
raylib.BeginShaderMode(shader)
|
||||
rl.BeginShaderMode(shader)
|
||||
|
||||
raylib.DrawTexture(fudesumi, 500, -30, raylib.White) // Using custom shader
|
||||
rl.DrawTexture(fudesumi, 500, -30, rl.White) // Using custom shader
|
||||
|
||||
// Activate our default shader for next drawings
|
||||
raylib.EndShaderMode()
|
||||
rl.EndShaderMode()
|
||||
|
||||
raylib.DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight-20, 10, raylib.Gray)
|
||||
rl.DrawText("(c) Fudesumi sprite by Eiden Marsal", 380, screenHeight-20, 10, rl.Gray)
|
||||
|
||||
raylib.EndDrawing()
|
||||
rl.EndDrawing()
|
||||
}
|
||||
|
||||
raylib.UnloadShader(shader) // Unload shader
|
||||
raylib.UnloadTexture(fudesumi) // Unload texture
|
||||
rl.UnloadShader(shader) // Unload shader
|
||||
rl.UnloadTexture(fudesumi) // Unload texture
|
||||
|
||||
raylib.CloseWindow() // Close window and OpenGL context
|
||||
rl.CloseWindow() // Close window and OpenGL context
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue