This commit is contained in:
InventorXtreme 2024-04-21 14:53:02 -04:00
parent 55713fff8c
commit ae33c14eb5
3 changed files with 49 additions and 3 deletions

View file

@ -3,6 +3,8 @@ package main
import ( import (
"fmt" "fmt"
"git.dummkopf.live/InventorX/pinwindows"
gui "github.com/gen2brain/raylib-go/raygui"
rl "github.com/gen2brain/raylib-go/raylib" rl "github.com/gen2brain/raylib-go/raylib"
) )
@ -27,6 +29,13 @@ type wall struct {
direction rl.Vector2 direction rl.Vector2
} }
func UpdateRenderTexture(texture *rl.RenderTexture2D) {
if rl.IsWindowResized() {
rl.UnloadRenderTexture(*texture)
*texture = rl.LoadRenderTexture(int32(rl.GetScreenWidth()), int32(rl.GetScreenHeight()))
}
}
func (w wall) Draw() { func (w wall) Draw() {
rl.DrawLineV(w.v1, w.v2, rl.White) rl.DrawLineV(w.v1, w.v2, rl.White)
midpoint := rl.Vector2MoveTowards(w.v1, w.v2, rl.Vector2Distance(w.v1, w.v2)/2) midpoint := rl.Vector2MoveTowards(w.v1, w.v2, rl.Vector2Distance(w.v1, w.v2)/2)
@ -53,25 +62,49 @@ func main() {
var frametime float32 = 0 var frametime float32 = 0
walltest := wall{rl.Vector2{X: 50, Y: 50}, rl.Vector2{X: 100, Y: 100}, rl.Vector2{X: 50, Y: 50}} walltest := wall{rl.Vector2{X: 50, Y: 50}, rl.Vector2{X: 100, Y: 100}, rl.Vector2{X: 50, Y: 50}}
var MapOrigWalls []wall
MapOrigWalls = append(MapOrigWalls, walltest)
mainwindowmanager := pinwindows.NewRayGuiWindowManager()
raywin := pinwindows.NewRayGuiWindow(100, 100, 200, 200)
mainwindowmanager.AddWindow(&raywin)
for !rl.WindowShouldClose() { for !rl.WindowShouldClose() {
mainwindowmanager.ManageWindowlist()
mainwindowmanager.ProcessUserWindowMovement()
raywin.BeginDrawMode()
rl.ClearBackground(rl.White)
rl.DrawText("erm", 0, 0, 012, rl.Black)
raywin.EndDrawMode()
frametime = rl.GetFrameTime() frametime = rl.GetFrameTime()
UpdateRenderTexture(&rendertexture)
mainwindowmanager.DrawInternalWindowList()
//camera.Target = rl.Vector2{0, 0} //camera.Target = rl.Vector2{0, 0}
rl.BeginTextureMode(rendertexture) rl.BeginTextureMode(rendertexture)
rl.ClearBackground(rl.Black) rl.ClearBackground(rl.Black)
mainwindowmanager.DrawWindowlist()
//rl.EndMode2D() //rl.EndMode2D()
//draw Scaled UI (buttons wont work here) //draw Scaled UI (buttons wont work here)
rl.DrawText(fmt.Sprintf("%f", frametime), 0, 0, 22, rl.Black) rl.DrawText(fmt.Sprintf("%f", frametime), 0, 0, 22, rl.Black)
walltest.Draw() walltest.Draw()
rl.DrawCircle(int32(rl.GetMousePosition().X), int32(rl.GetMousePosition().Y), 10, rl.Blue)
rl.EndTextureMode() rl.EndTextureMode()
rl.BeginDrawing() rl.BeginDrawing()
rl.DrawTexturePro(rendertexture.Texture, rl.NewRectangle(0, 0, float32(rendertexture.Texture.Width), -float32(rendertexture.Texture.Height)), rl.NewRectangle(0, 0, float32(rl.GetScreenWidth()), float32(rl.GetScreenHeight())), rl.NewVector2(0, 0), 0, rl.White) rl.DrawTexturePro(rendertexture.Texture, rl.NewRectangle(0, 0, float32(rendertexture.Texture.Width), -float32(rendertexture.Texture.Height)), rl.NewRectangle(0, 0, float32(rl.GetScreenWidth()), float32(rl.GetScreenHeight())), rl.NewVector2(0, 0), 0, rl.White)
gui.Button(rl.NewRectangle(1000, 600, 50, 50), "erm")
var sind int32 = 0
gui.ListView(rl.NewRectangle(0, 0, 100, 500), "test\n,; test", &sind, 0)
//Absoulte drawing //Absoulte drawing
rl.EndDrawing() rl.EndDrawing()
} }

5
go.mod
View file

@ -3,11 +3,12 @@ module git.dummkopf.live/InventorX/bsptest
go 1.22.2 go 1.22.2
require ( require (
git.dummkopf.live/InventorX/pinwindows v0.0.0-20240421060047-a58c367a1d9f
github.com/gen2brain/raylib-go/raygui v0.0.0-20240418150228-9548fadb54e6 github.com/gen2brain/raylib-go/raygui v0.0.0-20240418150228-9548fadb54e6
github.com/gen2brain/raylib-go/raylib v0.0.0-20240418150228-9548fadb54e6 github.com/gen2brain/raylib-go/raylib v0.0.0-20240418150228-9548fadb54e6
) )
require ( require (
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa // indirect github.com/ebitengine/purego v0.7.1 // indirect
golang.org/x/sys v0.14.0 // indirect golang.org/x/sys v0.19.0 // indirect
) )

12
go.sum
View file

@ -1,8 +1,20 @@
git.dummkopf.live/InventorX/pinwindows v0.0.0-20240421041403-1fd13fa66f1c h1:u/dL6KY+u7q+0XsvVs5/yLghcwkTzBe94EsFjwAjPCQ=
git.dummkopf.live/InventorX/pinwindows v0.0.0-20240421041403-1fd13fa66f1c/go.mod h1:nkyhUxcpBZlUgL0IU/wCFtcTJjQ6V/r2kBzdMWKimNQ=
git.dummkopf.live/InventorX/pinwindows v0.0.0-20240421053049-34b3c75bf99a h1:xZ3JdZboTfYRG6z9dzSAcnxsWx5GKK3SorM2I0Ft/qM=
git.dummkopf.live/InventorX/pinwindows v0.0.0-20240421053049-34b3c75bf99a/go.mod h1:nkyhUxcpBZlUgL0IU/wCFtcTJjQ6V/r2kBzdMWKimNQ=
git.dummkopf.live/InventorX/pinwindows v0.0.0-20240421055100-1eca7bfb5c2b h1:8hn/ASa144aUDKUKWEcTyJ14QiqEK+RlWHZGq102FSw=
git.dummkopf.live/InventorX/pinwindows v0.0.0-20240421055100-1eca7bfb5c2b/go.mod h1:nkyhUxcpBZlUgL0IU/wCFtcTJjQ6V/r2kBzdMWKimNQ=
git.dummkopf.live/InventorX/pinwindows v0.0.0-20240421060047-a58c367a1d9f h1:WjV8Ow4fcSWouY5I6jWaPtwB0CyfbVng3SSNwma6eD0=
git.dummkopf.live/InventorX/pinwindows v0.0.0-20240421060047-a58c367a1d9f/go.mod h1:nkyhUxcpBZlUgL0IU/wCFtcTJjQ6V/r2kBzdMWKimNQ=
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa h1:Ik7QikRgeH+bFOfAcMpttCbs6XxWXxCLXMm4awxtOXk= github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa h1:Ik7QikRgeH+bFOfAcMpttCbs6XxWXxCLXMm4awxtOXk=
github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ= github.com/ebitengine/purego v0.6.0-alpha.1.0.20231122024802-192c5e846faa/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/ebitengine/purego v0.7.1 h1:6/55d26lG3o9VCZX8lping+bZcmShseiqlh2bnUDiPA=
github.com/ebitengine/purego v0.7.1/go.mod h1:ah1In8AOtksoNK6yk5z1HTJeUkC1Ez4Wk2idgGslMwQ=
github.com/gen2brain/raylib-go/raygui v0.0.0-20240418150228-9548fadb54e6 h1:50+kpfeZzxc1A2FralhIzPMJH9gprSm6+36EMlkbyMA= github.com/gen2brain/raylib-go/raygui v0.0.0-20240418150228-9548fadb54e6 h1:50+kpfeZzxc1A2FralhIzPMJH9gprSm6+36EMlkbyMA=
github.com/gen2brain/raylib-go/raygui v0.0.0-20240418150228-9548fadb54e6/go.mod h1:Ra1zgJP7vnGst+STvzPPiVJhjicklFWONCz5nu6MnOM= github.com/gen2brain/raylib-go/raygui v0.0.0-20240418150228-9548fadb54e6/go.mod h1:Ra1zgJP7vnGst+STvzPPiVJhjicklFWONCz5nu6MnOM=
github.com/gen2brain/raylib-go/raylib v0.0.0-20240418150228-9548fadb54e6 h1:mNKFgLZIU0eEHKHjb7Uk9ZuSy65DdgmEf2xxum0Tof4= github.com/gen2brain/raylib-go/raylib v0.0.0-20240418150228-9548fadb54e6 h1:mNKFgLZIU0eEHKHjb7Uk9ZuSy65DdgmEf2xxum0Tof4=
github.com/gen2brain/raylib-go/raylib v0.0.0-20240418150228-9548fadb54e6/go.mod h1:P/hDjVwz/9fhR0ww3+umzDpDA7Bf7Tce4xNChHIEFqE= github.com/gen2brain/raylib-go/raylib v0.0.0-20240418150228-9548fadb54e6/go.mod h1:P/hDjVwz/9fhR0ww3+umzDpDA7Bf7Tce4xNChHIEFqE=
golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=
golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/sys v0.19.0 h1:q5f1RH2jigJ1MoAWp2KTp3gm5zAGFUTarQZ5U386+4o=
golang.org/x/sys v0.19.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=