libgdx vertex attribute naming?

Anything libgdx related goes here!

libgdx vertex attribute naming?

Postby OutputStream » Sun Jun 05, 2011 10:52 pm

note: Cross-posted at http://www.java-gaming.org/index.php/topic,24336.0.html

Hi guys!

I just started looking into libgdx and OpenGL (ES 2). Once I felt comfortable with rendering some easy, basic shapes I decided to try to import a .obj file.
The file loaded fine, however it wouldn't render at all. So I started digging in the source code for the ObjLoader and found that the loader names the attributes as "a_Position" and "a_TexCoord" while both the tutorials and the SpriteBatch class names them "a_position" and "a_texCoords".
Doesn't that break functionality since the wrong variable names get sent to the shaders?

The model rendered (kinda) when I manually edited the attribute to "a_position" after loading the model.

I don't know, maybe I'm wrong and it's supposed to be like this? If so, please explain why.
OutputStream
 
Posts: 10
Joined: Sun Jun 05, 2011 10:47 pm

Re: libgdx vertex attribute naming?

Postby mzechner » Mon Jun 06, 2011 12:51 am

The current obj loader set sensible defaults. It has nothing to do with SpriteBatch, but i agree that the naming convention should be the same on all libgdx managed/loaded meshes. Your solution of manually changing the attribute names to what suites you is the best imo, attribute names are not meant to be static, we just have to settle for some defaults (unless you want to specify each attribute name on load time, yuck :(). I'll look into unifying the attribute names asap.
mzechner
Site Admin
 
Posts: 4721
Joined: Sat Jul 10, 2010 3:50 pm

Re: libgdx vertex attribute naming?

Postby OutputStream » Mon Jun 06, 2011 2:01 am

Thanks for the reply :)

Maybe store the names as static fields in some class. Like public static ATTRIBUTE_POSITION = "a_position"; and let the ObjLoader and the other classes get the attribute names from there.
OutputStream
 
Posts: 10
Joined: Sun Jun 05, 2011 10:47 pm


Return to Libgdx

Who is online

Users browsing this forum: Bing [Bot] and 13 guests