%rename(Context) st_context;
%rename(Texture) pipe_texture;
%rename(Surface) pipe_surface;
-
-%rename(Buffer) pipe_buffer;
+%rename(Buffer) st_buffer;
%rename(BlendColor) pipe_blend_color;
%rename(Blend) pipe_blend_state;
%nodefaultctor st_context;
%nodefaultctor pipe_texture;
%nodefaultctor pipe_surface;
-%nodefaultctor pipe_buffer;
+%nodefaultctor st_buffer;
%nodefaultdtor st_device;
%nodefaultdtor st_context;
%nodefaultdtor pipe_texture;
%nodefaultdtor pipe_surface;
-%nodefaultdtor pipe_buffer;
+%nodefaultdtor st_buffer;
%ignore pipe_texture::screen;
struct st_context {
};
+struct st_buffer {
+};
+
%newobject st_device::texture_create;
%newobject st_device::context_create;
return $self->screen->texture_create($self->screen, &templat);
}
- struct pipe_buffer *
+ struct st_buffer *
buffer_create(unsigned size, unsigned alignment = 0, unsigned usage = 0) {
- return $self->screen->winsys->buffer_create($self->screen->winsys, alignment, usage, size);
+ return st_buffer_create($self, alignment, usage, size);
}
};
$self->pipe->draw_arrays($self->pipe, mode, start, count);
}
- void draw_elements( struct pipe_buffer *indexBuffer,
+ void draw_elements( struct st_buffer *indexBuffer,
unsigned indexSize,
unsigned mode, unsigned start, unsigned count) {
- $self->pipe->draw_elements($self->pipe, indexBuffer, indexSize, mode, start, count);
+ $self->pipe->draw_elements($self->pipe, indexBuffer->buffer, indexSize, mode, start, count);
}
void draw_vertices(unsigned prim,
};
+%extend st_buffer {
+
+ ~st_buffer() {
+ st_buffer_destroy($self);
+ }
+
+ void write( const char *STRING, unsigned LENGTH, unsigned offset = 0) {
+ struct pipe_winsys *winsys = $self->st_dev->screen->winsys;
+ char *map;
+
+ map = winsys->buffer_map(winsys, $self->buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
+ if(!map) {
+ memcpy(map + offset, STRING, LENGTH);
+ winsys->buffer_unmap(winsys, $self->buffer);
+ }
+ }
+};
+
+
%extend pipe_framebuffer_state {
pipe_framebuffer_state(void) {
return st_ctx;
}
+
+
+void
+st_buffer_destroy(struct st_buffer *st_buf)
+{
+ if(st_buf) {
+ struct pipe_winsys *winsys = st_buf->st_dev->screen->winsys;
+ pipe_buffer_reference(winsys, &st_buf->buffer, NULL);
+ FREE(st_buf);
+ }
+}
+
+
+struct st_buffer *
+st_buffer_create(struct st_device *st_dev,
+ unsigned alignment, unsigned usage, unsigned size)
+{
+ struct pipe_winsys *winsys = st_dev->screen->winsys;
+ struct st_buffer *st_buf;
+
+ st_buf = CALLOC_STRUCT(st_buffer);
+ if(!st_buf)
+ return NULL;
+
+ st_buf->st_dev = st_dev;
+
+ st_buf->buffer = winsys->buffer_create(winsys, alignment, usage, size);
+ if(!st_buf->buffer)
+ st_buffer_destroy(st_buf);
+
+ return st_buf;
+}
+