gui folder

This commit is contained in:
Konstantin8105 2022-11-23 12:26:13 +03:00
parent fe6d2c0ed3
commit 7a467d5aae
4 changed files with 15 additions and 6 deletions

View file

@ -2,6 +2,10 @@ module example
go 1.19 go 1.19
require github.com/Konstantin8105/raylib-go/raylib v0.0.0-20221122153952-2f5d9114177b require (
github.com/Konstantin8105/raylib-go/raygui v0.0.0-20221122151443-e8a384ed1346
github.com/Konstantin8105/raylib-go/raylib v0.0.0-20221122153952-2f5d9114177b
)
replace github.com/Konstantin8105/raylib-go/raylib => ../../../raylib replace github.com/Konstantin8105/raylib-go/raylib => ../../../raylib
replace github.com/Konstantin8105/raylib-go/raygui => ../../../raygui

View file

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
rl "github.com/Konstantin8105/raylib-go/raylib" rl "github.com/Konstantin8105/raylib-go/raylib"
gui "github.com/Konstantin8105/raylib-go/raygui"
) )
func main() { func main() {
@ -18,7 +19,7 @@ func main() {
rl.ClearBackground(rl.Black) rl.ClearBackground(rl.Black)
button = rl.Button(rl.NewRectangle(50, 150, 100, 40), "Click") button = gui.Button(rl.NewRectangle(50, 150, 100, 40), "Click")
if button { if button {
fmt.Println("Clicked on button") fmt.Println("Clicked on button")
} }

3
raygui/go.mod Normal file
View file

@ -0,0 +1,3 @@
module github.com/Konstantin8105/raylib-go/raygui
go 1.19

View file

@ -1,18 +1,19 @@
package rl package raygui
/* /*
#cgo CFLAGS: -DRAYGUI_IMPLEMENTATION #cgo CFLAGS: -DRAYGUI_IMPLEMENTATION
#include "raygui.h" #include "../raylib/raygui.h"
#include <stdlib.h> #include <stdlib.h>
*/ */
import "C" import "C"
import ( import (
"unsafe" "unsafe"
rl "github.com/Konstantin8105/raylib-go/raylib"
) )
// int GuiToggleGroup(Rectangle bounds, const char *text, int active) // int GuiToggleGroup(Rectangle bounds, const char *text, int active)
func ToggleGroup(bounds Rectangle, text string, active int) int { func ToggleGroup(bounds rl.Rectangle, text string, active int) int {
var cbounds C.struct_Rectangle var cbounds C.struct_Rectangle
cbounds.x = C.float(bounds.X) cbounds.x = C.float(bounds.X)
cbounds.y = C.float(bounds.Y) cbounds.y = C.float(bounds.Y)
@ -26,7 +27,7 @@ func ToggleGroup(bounds Rectangle, text string, active int) int {
} }
// bool GuiButton(Rectangle bounds, const char *text) // bool GuiButton(Rectangle bounds, const char *text)
func Button(bounds Rectangle, text string) bool { func Button(bounds rl.Rectangle, text string) bool {
var cbounds C.struct_Rectangle var cbounds C.struct_Rectangle
cbounds.x = C.float(bounds.X) cbounds.x = C.float(bounds.X)
cbounds.y = C.float(bounds.Y) cbounds.y = C.float(bounds.Y)