예제 #1
0
static enum piglit_result
do_copy()
{
	GLuint buffer_handles[2];

	glGenBuffersARB(2, buffer_handles);

	glBindBufferARB(GL_COPY_READ_BUFFER, buffer_handles[0]);
	glBindBufferARB(GL_COPY_WRITE_BUFFER, buffer_handles[1]);
	glBufferData(GL_COPY_READ_BUFFER, COPY_BUFFER_SIZE, src_data,
		     GL_STREAM_COPY);
	glBufferData(GL_COPY_WRITE_BUFFER, COPY_BUFFER_SIZE, NULL,
		     GL_STREAM_READ);

	glCopyBufferSubData(GL_COPY_READ_BUFFER, GL_COPY_WRITE_BUFFER, 0, 0,
			    COPY_BUFFER_SIZE);

	glGetBufferSubDataARB(GL_COPY_WRITE_BUFFER, 0, COPY_BUFFER_SIZE,
			      dest_data);

	if (memcmp(src_data, dest_data, COPY_BUFFER_SIZE) != 0)
		return PIGLIT_FAIL;

	return PIGLIT_PASS;
}
예제 #2
0
void *VBO::map()
{
	// mapping twice could result in memory leaks
	if (mapped)
		throw love::Exception("VBO is already mapped!");

	mapped = malloc(getSize());
	if (!mapped)
		throw love::Exception("Out of memory (oh the humanity!)");
	glGetBufferSubDataARB(getTarget(), 0, getSize(), mapped);

	return mapped;
}
	//---------------------------------------------------------------------
    void GLHardwareIndexBuffer::readData(size_t offset, size_t length, 
        void* pDest)
    {
        if(mUseShadowBuffer)
        {
            // get data from the shadow buffer
            void* srcData = mpShadowBuffer->lock(offset, length, HBL_READ_ONLY);
            memcpy(pDest, srcData, length);
            mpShadowBuffer->unlock();
        }
        else
        {
            glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId );
            glGetBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, pDest);
        }
    }
예제 #4
0
	//---------------------------------------------------------------------
    void GLHardwareVertexBuffer::readData(size_t offset, size_t length, 
        void* pDest)
    {
        if(mUseShadowBuffer)
        {
            // get data from the shadow buffer
            void* srcData = mShadowBuffer->lock(offset, length, HBL_READ_ONLY);
            memcpy(pDest, srcData, length);
            mShadowBuffer->unlock();
        }
        else
        {
            // get data from the real buffer
            static_cast<GLHardwareBufferManagerBase*>(mMgr)->getStateCacheManager()->bindGLBuffer(GL_ARRAY_BUFFER_ARB, mBufferId);

            glGetBufferSubDataARB(GL_ARRAY_BUFFER_ARB, offset, length, pDest);
        }
    }
예제 #5
0
void *VBO::map()
{
	if (is_mapped)
		return memory_map;

	if (!memory_map)
	{
		memory_map = malloc(getSize());
		if (!memory_map)
			throw love::Exception("Out of memory (oh the humanity!)");
	}

	if (is_dirty)
		glGetBufferSubDataARB(getTarget(), 0, getSize(), memory_map);

	is_mapped = true;
	is_dirty = false;

	return memory_map;
}
예제 #6
0
 void PixelBuffer::getSubData ( unsigned offs , unsigned size , void * data )
 {
         // TODO Tests if the Buffer is bound. Is this really important ?
         glGetBufferSubDataARB ( target_ , offs , size , data );
 }
예제 #7
0
	void	VertexBuffer::readData(uint offset,uint length,void* pDest)
	{
		glBindBufferARB(GL_ARRAY_BUFFER,m_ui32BufferID);
		glGetBufferSubDataARB(GL_ARRAY_BUFFER,offset,length,pDest);
		glBindBufferARB(GL_ARRAY_BUFFER,0);
	}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBBufferObject_nglGetBufferSubDataARB(JNIEnv *env, jclass clazz, jint target, jlong offset, jlong size, jlong data, jlong function_pointer) {
	GLvoid *data_address = (GLvoid *)(intptr_t)data;
	glGetBufferSubDataARBPROC glGetBufferSubDataARB = (glGetBufferSubDataARBPROC)((intptr_t)function_pointer);
	glGetBufferSubDataARB(target, offset, size, data_address);
}
JNIEXPORT void JNICALL Java_org_lwjgl_opengl_ARBBufferObject_nglGetBufferSubDataARB(JNIEnv *env, jclass clazz, jint target, jlong offset, jlong size, jobject data, jint data_position, jlong function_pointer) {
	GLvoid *data_address = ((GLvoid *)(((char *)(*env)->GetDirectBufferAddress(env, data)) + data_position));
	glGetBufferSubDataARBPROC glGetBufferSubDataARB = (glGetBufferSubDataARBPROC)((intptr_t)function_pointer);
	glGetBufferSubDataARB(target, offset, size, data_address);
}
예제 #10
0
 void DiGLIndexBuffer::ReadData(uint32 offset, uint32 length, void* pDest)
 {
     glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, mBufferId);
     glGetBufferSubDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB, offset, length, pDest);
 }