Git Product home page Git Product logo

Comments (5)

rougier avatar rougier commented on May 20, 2024

On Aug 27, 2013, at 1:03 PM, Almar Klein [email protected] wrote:

Summary

We discussed this approach (which I know think really sucks):

program['a_pos'] = my_array # Creates a VBO
program['a_pos'] = ClientArray(my_array) # Uses the array directly

WTF!

I agree that seen like this it's a bit weird and should not be allowed and I think your approach is right, let's forget about the ClientArray and do not create anything for the user.

We should add something in the (future) FAQ, "Why is my program so slow" and explain the problem.

from vispy.

rossant avatar rossant commented on May 20, 2024

I strongly disagree with that. Having the syntax "program['a_pos'] =
my_array" work but much slower than "program['a_pos'] =
VertexBuffer(my_array)" is a terrible idea in my opinion. No documentation
will ever change the fact that tons of users will do it wrong regularly (me
the first). At the very least, we should completely disable the syntax
"program['a_pos'] = my_array" which should throw an exception and tell the
user what to do.

2013/8/27 Almar Klein [email protected]

Summary

We discussed this approach (which I know think really sucks):

program['a_pos'] = my_array # Creates a VBO
program['a_pos'] = ClientArray(my_array) # Uses the array directly

WTF!

Besides being confusing it allows a sloppy style of using oogl that can
byte the user in the ass when he starts using updating attributes in this
way.

I propose to not do any magic VertexBuffer creating and instead just
document well that specifying an array as an attribute works, but is not
very efficient.
What we discussed

During Euroscipy we discussed about creating a VertexBuffer automatically
when the user does:
program['a_position'] = position_array

He could also do (to make it explicit):
program['a_position'] = VertexBuffer(position_array)

Similarly, we could allow: program['s_texture'] = image_array

Further there is a Program.set_var() function that can be used to set
VertexBuffers that contain structured data (from a structured numpy array).
It also allows setting attributes and uniforms as keyword arguments.

Finally, we discussed that to explicitly use a client-side array, the user
should do something like:
program['a_position'] = ClientArray(position_array)
What I did

The above is l currently mostly implemented. When the user uses this
syntax to update a texture or attribute, a warning is given, because he
should use a VBO (and update that) or explicitly use a client side array.

What I did not (yet) do is the ClientArray syntax. Instead if a user uses
Program.set_var() there is no auto-conversion.
My worries

I think it is bad practice to automatically convert a given numpy array to
a VertexBufer (let alone a Texture), because it allows a style of
programming that can become very inefficient if the user makes his code
more complex and starts updating stuff. Sure, we warn the user, but this is
not optimal.

Also, I think the ClientArray syntax really sucks:

program['a_position'] = my_array # Creates a VBO
program['a_position'] = oogl.ClientArray(my_array) # Uses the array directly

WTF

The approach that I took now (Program.set_var() does not do magic) is
also far from optimal, because it is confusing.
Proposal

I propose that we force the user to a way of working that is clear and
efficient.

I propose that Program does not automatically create VertexBuffers or
Textures.

There are two downsides:

  1. The user will have to type a tiny bit more.
  2. The unattentive user may forget to use oogl.VertexBuffer and use a
    client-side array.

I think (1) is worth it, since it just makes things more explicit and much
less confusion. For (2) I would argue that this is an API to OpenGL, and
users should know a bit about it when they use it. We document this
behaviour well and place a warning in the documentation. Further, most
examples will use an VBO anyway.


Reply to this email directly or view it on GitHubhttps://github.com//issues/46
.

from vispy.

campagnola avatar campagnola commented on May 20, 2024

On Tue, Aug 27, 2013 at 9:48 AM, Cyrille Rossant
[email protected]:

I strongly disagree with that. Having the syntax "program['a_pos'] =
my_array" work but much slower than "program['a_pos'] =
VertexBuffer(my_array)" is a terrible idea in my opinion. No documentation
will ever change the fact that tons of users will do it wrong regularly
(me
the first). At the very least, we should completely disable the syntax
"program['a_pos'] = my_array" which should throw an exception and tell the
user what to do.

Agreed. I think it is very important to keep track of and manage your own
VertexArrays, Textures, etc. Too many things can go wrong trying to
automate this.

from vispy.

almarklein avatar almarklein commented on May 20, 2024

So can we agree on this?

program['a_pos'] = my_array  # Raises ValueError with some helpful info
program['a_pos'] = VertexBuffer(my_array)  # OK!
program['a_pos'] = ClientArray(my_array)  # OK!

from vispy.

rossant avatar rossant commented on May 20, 2024

Yes, it looks good!

2013/8/27 Almar Klein [email protected]

So can we agree on this?

program['a_pos'] = my_array # Raises ValueError with some helpful info
program['a_pos'] = VertexBuffer(my_array) # OK!
program['a_pos'] = ClientArray(my_array) # OK!


Reply to this email directly or view it on GitHubhttps://github.com//issues/46#issuecomment-23367494
.

from vispy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.