LWJGL
May 22, 2012, 04:05:06 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: glMapBuffer  (Read 3760 times)
theplayer
Newbie
*
Posts: 8


« on: May 07, 2009, 08:47:18 »

hi @ all

i want to use glMapBuffer to update VBOs dynamicly. i want to use it for my map editor. the map contains of quads. each quad is rendererd as vbo.

i use these methods to map and unmap the buffer
Code:

        public static int READ_ONLY = ARBVertexBufferObject.GL_READ_ONLY_ARB;
public static int WRITE_ONLY = ARBVertexBufferObject.GL_WRITE_ONLY_ARB;
public static int READ_WRITE = ARBVertexBufferObject.GL_READ_WRITE_ARB;

public static void mapBuffer(int id, int status, ByteBuffer oldBuffer) {
ARBVertexBufferObject.glMapBufferARB(id, status, oldBuffer);
}

        public static void unmapBuffer(int id) {
               ARBVertexBufferObject.glUnmapBufferARB(id);
        }

and this code to map a vbo to the bytebuffer.

Code:
        int size = 3 * getVBOSize() * getVBOSize();
        ByteBuffer vertices = BufferUtils.createByteBuffer(size);
        vertices.clear();
        VBO.mapBuffer(selectedVBO, VBO.READ_WRITE, vertices);
        vertices.rewind();
        VBO.unmapBuffer(selectedVBO);

if i use it, i get the error
Exception in thread "main" org.lwjgl.opengl.OpenGLException: Invalid enum (1280)

i thought in the vbo are float values from my vertices and no byte values. how can i map a float buffer or is it possible to calculate from byte to float or should i use byte values and why comes the error?
many questions and my bad english i hope you understand my problem and could help me

thanks for your help

theplayer
Logged
theplayer
Newbie
*
Posts: 8


« Reply #1 on: May 10, 2009, 22:50:20 »

hi,

nobody here who could help me? i only want to update vbos dynamicaly.

greetings theplayer
Logged
Ciardhubh
Talks Too Much
***
Posts: 159


« Reply #2 on: May 11, 2009, 05:13:50 »

i thought in the vbo are float values from my vertices and no byte values. how can i map a float buffer or is it possible to calculate from byte to float or should i use byte values and why comes the error?

I haven't done anything with Vertex Buffer Objects yet so I have no definitive answer. However you can add a call to glGetError() after every gl... call to find out where it originates from. LWJGL only checks for GL errors when you call Display.update(), so it could have been any call that caused the error. Alternatively you could comment out all calls and try each one seperately.

As for the byte buffer, you can put floats into a bytebuffer by calling .putFloat(...) on the byte buffer instance. This takes a float and stores it as 4 bytes. Keep in mind that one value now occupies 4 indices. Depending on how and where you use the buffer, you may have to specify a bigger stride. This works with other data types too, e.g. putInt(...)

Also I think you can remove the .clear and .rewind calls to your buffer in your example.
Logged
VeAr
Newbie
*
Posts: 13


« Reply #3 on: May 11, 2009, 14:00:54 »

hi,

nobody here who could help me? i only want to update vbos dynamicaly.

greetings theplayer

VBO handling/mapping functions:
http://code.google.com/p/vlengine/source/browse/trunk/vle_cleanup/src/com/vlengine/renderer/lwjgl/LWJGLRenderer.java#1133

Code for doing software skinning with mapped buffers:
http://code.google.com/p/vlengine/source/browse/trunk/vle_cleanup/src/com/vlengine/scene/animation/x/XSoftSkinner.java

Hope it helps.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!