Hello Guest

glMapBuffer

  • 3 Replies
  • 11924 Views
glMapBuffer
« on: May 07, 2009, 15: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: [Select]

        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: [Select]
        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

Re: glMapBuffer
« Reply #1 on: May 11, 2009, 05:50:20 »
hi,

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

greetings theplayer

Re: glMapBuffer
« Reply #2 on: May 11, 2009, 12: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.
« Last Edit: May 11, 2009, 13:56:05 by Ciardhubh »

*

Offline VeAr

  • *
  • 18
Re: glMapBuffer
« Reply #3 on: May 11, 2009, 21:00:54 »