Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh not being updated when data changes in v2-dev #139

Closed
azul3d-bot opened this issue Mar 6, 2016 · 7 comments
Closed

Mesh not being updated when data changes in v2-dev #139

azul3d-bot opened this issue Mar 6, 2016 · 7 comments

Comments

@azul3d-bot
Copy link

Issue by oal
Saturday Jan 03, 2015 at 20:21 GMT
Originally opened as azul3d-legacy/gfx#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.

    mesh := t.Meshes[0] // has .Dynamic = true

    mesh.Vertices = verts
    mesh.VerticesChanged = true

    mesh.TexCoords = []gfx.TexCoordSet{
        {
            Slice:   texCoords,
            Changed: true,
        },
    }

Let me know if you need more information.

@azul3d-bot azul3d-bot added this to the Version 2 milestone Mar 6, 2016
@azul3d-bot
Copy link
Author

Comment by slimsag
Saturday Jan 03, 2015 at 20:45 GMT


Is this with v2-dev still, or v1?

@azul3d-bot
Copy link
Author

Comment by oal
Saturday Jan 03, 2015 at 20:48 GMT


Yes, v2-dev master.

@azul3d-bot
Copy link
Author

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)
}

@azul3d-bot
Copy link
Author

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!

@azul3d-bot
Copy link
Author

Comment by oal
Saturday Jan 03, 2015 at 21:43 GMT


Yes, it works now! Thanks again for a quick and helpful response. 👍

@azul3d-bot
Copy link
Author

Comment by slimsag
Saturday Jan 03, 2015 at 21:44 GMT


Awesome. 👍 Thank you for the bug report.

@azul3d-bot
Copy link
Author

Fixed/merged as part of #1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant