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

GLOW.ShaderUtils.createMultiple only supports triangles #5

Open
neilmendoza opened this issue Dec 25, 2011 · 7 comments
Open

GLOW.ShaderUtils.createMultiple only supports triangles #5

neilmendoza opened this issue Dec 25, 2011 · 7 comments

Comments

@neilmendoza
Copy link

GLOW.ShaderUtils.createMultiple doesn't work for points. As far as I can see Glow only deals with indexed rendering, i.e. glDrawElements rather than glDrawArrays. For drawing points, glDrawArrays would may be better anyway, as there wouldn't be shared vertices. This function would then no longer be necessary as the limitation is on the size of the data type of the index array.

@empaempa
Copy link
Owner

Good point! (pun intended)
I haven't really dealt with DrawArrays before but I guess a nice way of implementing it would be to simply NOT have elements/points/triangles/triangleFan/triangleStrip in the shader config object. If it's lacking, we simply make a drawArrays instead of drawElements. I'll look into it - do you need it quickly?

@empaempa
Copy link
Owner

...or not. You need to know what type (TRIANGLE etc.) to draw. Any suggestions on how to set this up in a nice, consistent maner?

@empaempa
Copy link
Owner

Ok, I did like this now... in the shader config object, set the length as a number where elements used to be. For example...

myShaderConfig = {
triangles: 10 * 3,
data: {
// your data here
}
}

...to use drawArrays for 10 triangles. Side note: I've also added .offset to GLOW.Elements (which is still used in the drawArray case, just that its .elements is undefined) so you can offset or set the first when drawing.

If you have a better idea on how to handle this, please let me know - I'm all ears :)

@neilmendoza
Copy link
Author

Thanks for the quick update! I should probably have better things to do than creating issues on Xmas day ;) Hopefully DrawArrays isn't using 16 bit indices under the hood otherwise the 65536 limit will still be there, will give it a go.

Off the top of my head, coming from OpenGL, I might have done something like this...

Indexed

myShaderConfig = {
  indices: myIndices, 
  data: {
    vertices: myVerts,
    primitive: GL.TRIANGLES
  }
}

Non-indexed

myShaderConfig = {
  data: {
    vertices: myVerts, 
    primitive: GL.TRIANGLES
  }
}

...where primitive defaults to something (maybe triangles), and if there's no index array then it just works out what to do from the size of the vertex array. Will have a think about it some more.

Happy holidays!

@empaempa
Copy link
Owner

I should, too, but things like these are just too much fun :)

Yeah, I was thinking about figuring out the length using one of the attributes but I thought the ability to set the amount was nice. Now I think about it, you're probably right - most times you're not interested in setting the length but just get them all drawn. I'd look into changing into...

Indexed

myShaderConfig = {
  indices: myIndices, // the 'indices' property could also be triangles/points/etc and then you don't have to define...
  primitive: GL.POINTS, // if left out, defaults to GL.TRIANGLES
  data: {
    // attributes and uniforms
  }
};

Non-Indexed

myShaderConfig = {
  primitive: GL.POINTS, // if left out, defaults to GL.TRIANGLES
  data: {
    // attributes and uniforms
  }
};

Thanks for the input!
Happy new year!

(BTW: if you publish anything using GLOW, please let me know!)

@empaempa
Copy link
Owner

Ok, done. Please pull. And read the latest post on http://i-am-glow.com :D

@neilmendoza
Copy link
Author

Changes look great! Thanks for the mention on the blog :)

Will let you know when I get around to publishing something...

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

No branches or pull requests

2 participants