admin管理员组文章数量:1289483
I have a Playersprite (currently a darkgreen 64x32 rect), thats a Texture2D and a generated map, stored in a Texture2D the size of the window, generated usiong perlin noise
If i draw the map i cant see the Player, if i dont draw the map i see the player, but i want to draw both at the same time.
engine.Begindrawing just begins drawmode and clears the screen, engine.EndDrawing just ends draw mode.
for Debugging im also drawing a Green Square.
the code(main.go):
package main
import (
"image/color"
"math"
"math/rand"
noise "github/aquilax/go-perlin"
rl "github/gen2brain/raylib-go/raylib"
engine "github/noschXL/Game/code/Engine"
)
func generateMap(seed int64, mapsize engine.Vector2D, gamemap rl.RenderTexture2D) (rl.RenderTexture2D, int32) {
Gamenoise := noise.NewPerlin(1.8, 2, 8, seed)
rl.BeginTextureMode(gamemap)
var whitepixels int32 = 0
for i := 0.0; i < float64(mapsize.X); i++ {
for j := 0.0; j < float64(mapsize.Y); j++ {
brightness := math.Round(Gamenoise.Noise2D(i/float64(mapsize.X), j/float64(mapsize.Y)) * 255)
if brightness < 100 {
brightness = 0
} else {
brightness = 255
whitepixels += 1
}
rl.DrawPixel(int32(i), int32(j), color.RGBA{uint8(brightness), uint8(brightness), uint8(brightness), 255})
}
}
return gamemap, whitepixels
}
func main() {
winsize := engine.Vector2D{X: 1280, Y: 920}
engine.Initialize(winsize, "Sole Survivor", 120)
running := true
defer rl.CloseWindow()
engine.BeginDrawing()
var tries int32 = 1
var valid bool = false
var whitepixel int32 = 0
minwhitepx := int32(winsize.X) * int32(winsize.Y) / 8
var gamemap rl.RenderTexture2D = rl.LoadRenderTexture(1280, 920)
var seed int64 = 0
for ; tries <= 30 && valid == false; tries++ {
whitepixel = 0
seed = rand.Int63()
println("on try: ", tries)
gamemap, whitepixel = generateMap(seed, winsize, gamemap)
valid = int32(whitepixel) > minwhitepx
}
println("seed for this map: ", seed)
rl.EndTextureMode()
player := engine.NewPlayer(winsize.X/2, winsize.Y/2, 0)
sprite := engine.LoadPlayerSprite(engine.AppendFilePath(engine.GetPath(), []string{"data", "img", "Entitys", "Player", "player.png"}))
for running {
deltatime := rl.GetFrameTime()
// Update
engine.UpdatePlayer(&player, deltatime)
// Draw
engine.BeginDrawing()
rl.BindImageTexture()
rl.DrawTexture(gamemap.Texture, 0, 0, rl.White)
rl.DrawRectangle(int32(player.Position.X), int32(player.Position.Y), 50, 50, rl.Green)
rl.DrawTexture(sprite, int32(player.Position.X), int32(player.Position.Y), rl.Green)
engine.EndDrawing()
//Other Logic
if rl.WindowShouldClose() {
running = false
}
}
}
the full code can be found at
I tried changing the the textures alpha color, it made the map slightly seethrough, did not let me see the playersprite.
Changed the tint of the playersprite, didnt let me se it
Changed the order of the drawcalls, didnt let me see it
tried drawing one texture, ending the drawcall, start a new one, draw the player. Result: the screen Draws the map and goes black and so on repeatedly, didnt see the playersprite.
本文标签: Raylibgo not drawing multiple Textures from one DrawcallStack Overflow
版权声明:本文标题:Raylib-go not drawing multiple Textures from one Drawcall - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741468901a2380480.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论