chunqian / go-raylib

go-raylib is a simple and easy-to-use library to enjoy videogames programming
zlib License
44 stars 3 forks source link

Visual glitch until moving window MacOS #7

Open hfabre opened 3 years ago

hfabre commented 3 years ago

Hi not sure if this come from Raylib itself or the bindings, but I got a weird glitch on my Mac. I just want to draw a rectangle, and it is drawn very small until I move the window, see the video:

https://user-images.githubusercontent.com/4941447/113511980-cdfa5200-9562-11eb-9039-2190dc5f6a8f.mp4

The code itself is really simple:

package main

import (
    rl "github.com/chunqian/go-raylib/raylib"
    "runtime"
)

const screenWidth = 1280
const screenHeight = 720

type Game struct {
    player *Player
}

func NewGame() Game {
    player := Player{
        pos:      rl.Vector2{20, 20},
        velocity: rl.Vector2{0, 0},
        size:     rl.Vector2{32, 64},
    }
    g := Game{player: &player}

    return g
}

type Player struct {
    pos, velocity, size rl.Vector2
}

func (g Game) Run() {
    rl.InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")
    defer rl.CloseWindow()

    rl.SetTargetFPS(60)

    for !rl.WindowShouldClose() {
        g.Update()
        g.Draw()
    }
}

func (g Game) Update() {

}

func (g Game) Draw() {
    rl.BeginDrawing()
    defer rl.EndDrawing()

    rl.ClearBackground(rl.RayWhite)
    rl.DrawRectangleV(g.player.pos, g.player.size, rl.Green)
}

func init() {
    runtime.LockOSThread()
}

func main() {
    g := NewGame()
    g.Run()
}

Anyway, thanks for your work on this binding !

hfabre commented 3 years ago

Just tried the 2D platformer example in the repo and got the same glitch for what it worth

chunqian commented 3 years ago

@hfabre I didn't find similar problem on my mac, my macos version 10.14.6 intel cpu Can you tell me the version number of your mac system? Or compile and run the 2D platformer example with the same raylib c version to see if there is a similar problem? I think it's a problem with raylib c version

makew0rld commented 3 years ago

Make sure you're using the latest version of the library. Use Go modules and set up a project, and then run this import: go get github.com/chunqian/go-raylib@master. This will use the latest commit of the library.

hfabre commented 3 years ago

Don't know what the problem was, but it works well on the last commit of the binding, thanks @makeworld-the-better-one.

FYI I was using require github.com/chunqian/go-raylib v0.0.0-20210327031704-6ee277f768c6 and now I'm using: require github.com/chunqian/go-raylib v0.0.0-20210322143257-7fdd615788b9

thanks guys !

chunqian commented 3 years ago

It may be a problem with the static libraries generated by cmake Can you tell me the version of macOS to help me solve this problem?

makew0rld commented 3 years ago

@chunqian I don't think either of those are a problem. It was just the old code was broken and now it's fixed.

chunqian commented 3 years ago

@hfabre @makeworld-the-better-one I found the same problem on macos 10.15.6 I can confirm that it is a problem with raylib 3.5 std version When raylib 3.6 std version is released, I will update it at the same time Then close the issue Thanks for the feedback!

hfabre commented 3 years ago

FYI i'm on macOS 10.15.4. Anyway thanks for your work and your fast answer !