1 /* 2 * Copyright (c) 2002-2008 LWJGL Project 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: 8 * 9 * * Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 12 * * Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * * Neither the name of 'LWJGL' nor the names of 17 * its contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 22 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 27 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 28 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 29 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 package org.lwjgl.opengl; 33 34 import org.lwjgl.util.generator.*; 35 import org.lwjgl.util.generator.Alternate; 36 import org.lwjgl.util.generator.opengl.*; 37 38 import java.nio.Buffer; 39 import java.nio.ByteBuffer; 40 import java.nio.IntBuffer; 41 42 @Extension(postfix = "ARB", isFinal = false) 43 public interface ARB_buffer_object { 44 45 /** Accepted by the <usage> parameter of BufferDataARB: */ 46 int GL_STREAM_DRAW_ARB = 0x88E0; 47 int GL_STREAM_READ_ARB = 0x88E1; 48 int GL_STREAM_COPY_ARB = 0x88E2; 49 int GL_STATIC_DRAW_ARB = 0x88E4; 50 int GL_STATIC_READ_ARB = 0x88E5; 51 int GL_STATIC_COPY_ARB = 0x88E6; 52 int GL_DYNAMIC_DRAW_ARB = 0x88E8; 53 int GL_DYNAMIC_READ_ARB = 0x88E9; 54 int GL_DYNAMIC_COPY_ARB = 0x88EA; 55 56 /** Accepted by the <access> parameter of MapBufferARB: */ 57 int GL_READ_ONLY_ARB = 0x88B8; 58 int GL_WRITE_ONLY_ARB = 0x88B9; 59 int GL_READ_WRITE_ARB = 0x88BA; 60 61 /** Accepted by the <pname> parameter of GetBufferParameterivARB: */ 62 int GL_BUFFER_SIZE_ARB = 0x8764; 63 int GL_BUFFER_USAGE_ARB = 0x8765; 64 int GL_BUFFER_ACCESS_ARB = 0x88BB; 65 int GL_BUFFER_MAPPED_ARB = 0x88BC; 66 int GL_BUFFER_MAP_POINTER_ARB = 0x88BD; 67 68 @Code(" StateTracker.bindBuffer(caps, target, buffer);") glBindBufferARB(@Lenum int target, @GLuint int buffer)69 void glBindBufferARB(@GLenum int target, @GLuint int buffer); 70 glDeleteBuffersARB(@utoSizeR) @Lsizei int n, @Const @GLuint IntBuffer buffers)71 void glDeleteBuffersARB(@AutoSize("buffers") @GLsizei int n, @Const @GLuint IntBuffer buffers); 72 73 @Alternate("glDeleteBuffersARB") glDeleteBuffersARB(@onstantR) @Lsizei int n, @Constant(value = R, keepParam = true) int buffer)74 void glDeleteBuffersARB(@Constant("1") @GLsizei int n, @Constant(value = "APIUtil.getInt(caps, buffer)", keepParam = true) int buffer); 75 glGenBuffersARB(@utoSizeR) @Lsizei int n, @OutParameter @GLuint IntBuffer buffers)76 void glGenBuffersARB(@AutoSize("buffers") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); 77 78 @Alternate("glGenBuffersARB") 79 @GLreturn("buffers") glGenBuffersARB2(@onstantR) @Lsizei int n, @OutParameter @GLuint IntBuffer buffers)80 void glGenBuffersARB2(@Constant("1") @GLsizei int n, @OutParameter @GLuint IntBuffer buffers); 81 glIsBufferARB(@Luint int buffer)82 boolean glIsBufferARB(@GLuint int buffer); 83 84 @GenerateAutos glBufferDataARB(@Lenum int target, @AutoSize(R) @GLsizeiptrARB long size, @Check @Const @GLbyte @GLshort @GLint @GLfloat @GLdouble Buffer data, @GLenum int usage)85 void glBufferDataARB(@GLenum int target, @AutoSize("data") @GLsizeiptrARB long size, 86 @Check 87 @Const 88 @GLbyte 89 @GLshort 90 @GLint 91 @GLfloat 92 @GLdouble Buffer data, @GLenum int usage); 93 glBufferSubDataARB(@Lenum int target, @GLintptrARB long offset, @AutoSize(R) @GLsizeiptrARB long size, @Check @Const @GLbyte @GLshort @GLint @GLfloat @GLdouble Buffer data)94 void glBufferSubDataARB(@GLenum int target, @GLintptrARB long offset, @AutoSize("data") @GLsizeiptrARB long size, 95 @Check 96 @Const 97 @GLbyte 98 @GLshort 99 @GLint 100 @GLfloat 101 @GLdouble Buffer data); 102 glGetBufferSubDataARB(@Lenum int target, @GLintptrARB long offset, @AutoSize(R) @GLsizeiptrARB long size, @OutParameter @Check @GLbyte @GLshort @GLint @GLfloat @GLdouble Buffer data)103 void glGetBufferSubDataARB(@GLenum int target, @GLintptrARB long offset, @AutoSize("data") @GLsizeiptrARB long size, 104 @OutParameter 105 @Check 106 @GLbyte 107 @GLshort 108 @GLint 109 @GLfloat 110 @GLdouble Buffer data); 111 112 /** 113 * glMapBufferARB maps a GL buffer object to a ByteBuffer. The old_buffer argument can be null, 114 * in which case a new ByteBuffer will be created, pointing to the returned memory. If old_buffer is non-null, 115 * it will be returned if it points to the same mapped memory and has the same capacity as the buffer object, 116 * otherwise a new ByteBuffer is created. That way, an application will normally use glMapBufferARB like this: 117 * <p/> 118 * ByteBuffer mapped_buffer; mapped_buffer = glMapBufferARB(..., ..., null); ... // Another map on the same buffer mapped_buffer = glMapBufferARB(..., ..., mapped_buffer); 119 * <p/> 120 * Only ByteBuffers returned from this method are to be passed as the old_buffer argument. User-created ByteBuffers cannot be reused. 121 * <p/> 122 * The version of this method without an explicit length argument calls glGetBufferParameterARB internally to 123 * retrieve the current buffer object size, which may cause a pipeline flush and reduce application performance. 124 * <p/> 125 * The version of this method with an explicit length argument is a fast alternative to the one without. No GL call 126 * is made to retrieve the buffer object size, so the user is responsible for tracking and using the appropriate length.<br> 127 * Security warning: The length argument should match the buffer object size. Reading from or writing to outside 128 * the memory region that corresponds to the mapped buffer object will cause native crashes. 129 * 130 * @param length the length of the mapped memory in bytes. 131 * @param old_buffer A ByteBuffer. If this argument points to the same address and has the same capacity as the new mapping, it will be returned and no new buffer will be created. 132 * 133 * @return A ByteBuffer representing the mapped buffer memory. 134 */ 135 @CachedResult 136 @GLvoid 137 @AutoSize("glGetBufferParameteriARB(target, GL_BUFFER_SIZE_ARB)") glMapBufferARB(@Lenum int target, @GLenum int access)138 ByteBuffer glMapBufferARB(@GLenum int target, @GLenum int access); 139 glUnmapBufferARB(@Lenum int target)140 boolean glUnmapBufferARB(@GLenum int target); 141 142 @StripPostfix("params") glGetBufferParameterivARB(@Lenum int target, @GLenum int pname, @OutParameter @Check(R) IntBuffer params)143 void glGetBufferParameterivARB(@GLenum int target, @GLenum int pname, @OutParameter @Check("4") IntBuffer params); 144 145 /** @deprecated Will be removed in 3.0. Use {@link #glGetBufferParameteriARB} instead. */ 146 @Alternate("glGetBufferParameterivARB") 147 @GLreturn("params") 148 @StripPostfix("params") 149 @Reuse(value = "ARBBufferObject", method = "glGetBufferParameteriARB") 150 @Deprecated glGetBufferParameterivARB2(@Lenum int target, @GLenum int pname, @OutParameter IntBuffer params)151 void glGetBufferParameterivARB2(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); 152 153 @Alternate("glGetBufferParameterivARB") 154 @GLreturn("params") 155 @StripPostfix(value = "params", hasPostfix = false) glGetBufferParameterivARB3(@Lenum int target, @GLenum int pname, @OutParameter IntBuffer params)156 void glGetBufferParameterivARB3(@GLenum int target, @GLenum int pname, @OutParameter IntBuffer params); 157 158 @StripPostfix("pointer") 159 @AutoSize("glGetBufferParameteriARB(target, GL_BUFFER_SIZE_ARB)") glGetBufferPointervARB(@Lenum int target, @GLenum int pname, @Result @GLvoid ByteBuffer pointer)160 void glGetBufferPointervARB(@GLenum int target, @GLenum int pname, @Result @GLvoid ByteBuffer pointer); 161 } 162