Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (542)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Color- and texture-anomalities when using Vertex Buffers.  (Read 1196 times)
0 Members and 1 Guest are viewing this topic.
Offline Bvsemmer

Junior Newbie





« Posted 2005-10-20 20:45:45 »

Hi list,

I'm having trouble adding color and texture-coordinates to my vertices in a Vertex Buffer.  I use this to fill my colorbuffer and put them into a Vertex Buffer (like I do for the vertices and indices) :
1  
2  
3  
4  
5  
6  
7  
8  
9  
colorbuffer = BufferUtils.createFloatBuffer(4 * 4);
colorbuffer.put(255).put(0).put(0).put(255);
colorbuffer.put(255).put(0).put(0).put(255);
colorbuffer.put(255).put(0).put(0).put(255);
colorbuffer.put(255).put(0).put(0).put(255);
colorbuffer.flip();

ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_COLOR_ARRAY_BUFFER_BINDING_ARB, colorbufferID);
ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_COLOR_ARRAY_BUFFER_BINDING_ARB, colorbuffer, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);

This gives the following compile error:
"Unsupported VBO target 34970"

I'm pretty sure I know what this means, but what kind of buffer should I use then?  Perhaps I'm doing something terribly wrong?

If I use the GL_ARRAY_BUFFER_ARB flag, everything seems to work:
1  
2  
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, colorbufferID);
ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, colorbuffer, ARBVertexBufferObject.GL_STATIC_DRAW_ARB);
...but then I'm overwriting my vertex buffer ofcourse. 
How can I avoid this please?  What is the correct way to use this?

Thank you!
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 849
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #1 - Posted 2005-10-20 20:59:28 »

You're not overriding your vertex data this way (or at least: shouldn't be)

it's like this:

1  
2  
3  
4  
5  
bindBuffer(..., x)
bufferData(..., dataX, ...)

bindBuffer(..., y)
bufferData(..., dataY, ...)


now buffer x holds dataX
now buffer y holds dataY

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 849
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #2 - Posted 2005-10-20 21:02:40 »

According to your topic-title, you see artifacts.

This happens when your VBO has less elements than required.
like if vertex-array has 12 elements and color-array has 9 elements... the last 3 elements will be garbage colors

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline anarchotron

Junior Devvie




...precious bodily fluids.


« Reply #3 - Posted 2005-10-21 03:24:44 »

One problem I see with this is that you are specifying your color buffer as a FloatBuffer, but specifying your colors as 255,0,0,255 (red, presumably).  The valid range of a float color component is [0..1].  Try using 1.0f instead of 255.  It may look ok because the values are being clamped to the proper range for you.

At any rate, the GL_ARRAY_BUFFER_ARB usage you mentioned secondly is the correct usage, not GL_COLOR_ARRAY_BUFFER_BINDING_ARB.  Why do you think this is incorrect?  (Maybe I'm misuing my VBOs but I use G_ARRAY_BUFFER_ARB to create & load my vbos with data).
Offline Bvsemmer

Junior Newbie





« Reply #4 - Posted 2005-10-21 12:48:13 »

You're not overriding your vertex data this way (or at least: shouldn't be)
Thank you, that was indeed my problem (stupid mistake, if you think about it Smiley).  Everything works like a charm now. 

At any rate, the GL_ARRAY_BUFFER_ARB usage you mentioned secondly is the correct usage, not GL_COLOR_ARRAY_BUFFER_BINDING_ARB. Why do you think this is incorrect?
I guess I was a bit confused with the "glEnableClientState()"-method where they explicitly use different states, like "GL11.GL_TEXTURE_COORD_ARRAY" and "GL11.GL_COLOR_ARRAY".

Thanks again for the help!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

CopyableCougar4 (14 views)
2014-12-28 02:10:29

BurntPizza (17 views)
2014-12-27 22:38:51

Mr.CodeIt (13 views)
2014-12-27 04:03:04

TheDudeFromCI (17 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (86 views)
2014-12-05 12:39:02
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!