Closed azul3d-bot closed 8 years ago
Comment by slimsag Saturday Jan 03, 2015 at 21:25 GMT
Thanks, I can reproduce the issue.
// Copyright 2014 The Azul3D Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// Issue 88 test.
package main
import (
"log"
"azul3d.org/gfx.v2-dev"
"azul3d.org/gfx.v2-dev/gfxutil"
"azul3d.org/gfx.v2-dev/window"
math "azul3d.org/lmath.v1"
)
// gfxLoop is responsible for drawing things to the window.
func gfxLoop(w window.Window, d gfx.Device) {
// Setup a camera to use a perspective projection.
camera := gfx.NewCamera()
camera.SetPersp(d.Bounds(), 75.0, 0.0001, 1000.0)
camera.SetPos(math.Vec3{0, -2, 0})
// Read the GLSL shaders from disk.
shader, err := gfxutil.OpenShader("basic")
if err != nil {
log.Fatal(err)
}
// Initialize the triangle mesh.
triMesh := gfx.NewMesh()
triMesh.Vertices = []gfx.Vec3{
// Top
{0, 0, 1},
{-.5, 0, 0},
{.5, 0, 0},
}
triMesh.Colors = []gfx.Color{
{1, 0, 0, 1},
{0, 1, 0, 1},
{0, 0, 1, 1},
}
// Do not set the data slices to nil when loading is complete.
triMesh.KeepDataOnLoad = true
// Create a triangle object.
triangle := gfx.NewObject()
triangle.Shader = shader
triangle.State = gfx.NewState()
triangle.Meshes = []*gfx.Mesh{triMesh}
for {
for i, c := range triMesh.Colors {
c.R += 0.01
if c.R > 1.0 {
c.R = 0.0
}
triMesh.Colors[i] = c
}
log.Println(triMesh.Colors[0])
triMesh.ColorsChanged = true
// Clear color and depth buffers.
d.Clear(d.Bounds(), gfx.Color{1, 1, 1, 1})
d.ClearDepth(d.Bounds(), 1.0)
// Draw the triangle to the screen.
d.Draw(d.Bounds(), triangle, camera)
// Render the whole frame.
d.Render()
}
}
func main() {
window.Run(gfxLoop, nil)
}
Comment by slimsag Saturday Jan 03, 2015 at 21:38 GMT
@oal please pull the changes I've just made and see if that fixes the issue:
go get -u azul3d.org/gfx.v2-dev
P.S. I just saw the v2-dev
in the title -- sorry bout that!
Comment by oal Saturday Jan 03, 2015 at 21:43 GMT
Yes, it works now! Thanks again for a quick and helpful response. :+1:
Fixed/merged as part of https://github.com/azul3d/engine/issues/1
Issue by oal Saturday Jan 03, 2015 at 20:21 GMT Originally opened as https://github.com/azul3d/gfx/issues/88
When I get an existing mesh like this, and try to change vertices and other attributes, the changes never show up on screen. I can set vertices and make changes before I start rendering anything, but as soon as the render loop starts, no changes are picked up. So it appears that the changed arrays aren't uploaded to the GPU.
Let me know if you need more information.