Beispiel #1
0
int opengl_create_texture_buffer_object()
{
	if ( GLSL_version < 130 ) {
		return -1;
	}

	// create the buffer
	int buffer_object_handle = opengl_create_buffer_object(GL_TEXTURE_BUFFER, GL_DYNAMIC_DRAW);

	opengl_check_for_errors();

	opengl_buffer_object &buffer_obj = GL_buffer_objects[buffer_object_handle];

	// create the texture
	glGenTextures(1, &buffer_obj.texture);
	glBindTexture(GL_TEXTURE_BUFFER, buffer_obj.texture);

	gr_opengl_update_buffer_data(buffer_object_handle, 100, NULL);

	glTexBuffer(GL_TEXTURE_BUFFER, GL_RGBA32F, buffer_obj.buffer_id);

	opengl_check_for_errors();

	return buffer_object_handle;
}
Beispiel #2
0
uint opengl_add_to_immediate_buffer(uint size, void *data)
{
	if ( GL_immediate_buffer_handle < 0 ) {
		GL_immediate_buffer_handle = opengl_create_buffer_object(GL_ARRAY_BUFFER, GL_STREAM_DRAW);
	}

	Assert(size > 0 && data != NULL);

	if ( GL_immediate_buffer_offset + size > GL_immediate_buffer_size ) {
		// incoming data won't fit the immediate buffer. time to reallocate.
		GL_immediate_buffer_offset = 0;
		GL_immediate_buffer_size += MAX(IMMEDIATE_BUFFER_RESIZE_BLOCK_SIZE, size);
		
		gr_opengl_update_buffer_data(GL_immediate_buffer_handle, GL_immediate_buffer_size, NULL);
	}

	// only update a section of the immediate vertex buffer
	opengl_update_buffer_data_offset(GL_immediate_buffer_handle, GL_immediate_buffer_offset, size, data);

	uint old_offset = GL_immediate_buffer_offset;

	GL_immediate_buffer_offset += size;

	return old_offset;
}
Beispiel #3
0
int gr_opengl_create_index_buffer(bool static_buffer)
{
	return opengl_create_buffer_object(GL_ELEMENT_ARRAY_BUFFER, static_buffer ? GL_STATIC_DRAW : GL_STREAM_DRAW);
}
int gr_opengl_create_buffer(BufferType type, BufferUsageHint usage)
{
	return opengl_create_buffer_object(convertBufferType(type), convertUsageHint(usage));
}