summaryrefslogtreecommitdiffstats
path: root/src/gallium/state_trackers/python/gallium.i
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2008-08-10 18:52:00 +0100
committerJosé Fonseca <[email protected]>2008-08-12 11:34:40 +0100
commita304d271185af935974850055da74ec8263b00e2 (patch)
treee9bb1f947ea408e60ccd2c0828529c394bb49e13 /src/gallium/state_trackers/python/gallium.i
parente5a606883f24980dd8e2378c25e6fb3b8f1937ce (diff)
python: Allow writing to buffers.
Diffstat (limited to 'src/gallium/state_trackers/python/gallium.i')
-rw-r--r--src/gallium/state_trackers/python/gallium.i37
1 files changed, 29 insertions, 8 deletions
diff --git a/src/gallium/state_trackers/python/gallium.i b/src/gallium/state_trackers/python/gallium.i
index 284ecb827df..8f731ca9054 100644
--- a/src/gallium/state_trackers/python/gallium.i
+++ b/src/gallium/state_trackers/python/gallium.i
@@ -65,8 +65,7 @@
%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;
@@ -88,13 +87,13 @@
%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;
@@ -114,6 +113,9 @@ struct st_device {
struct st_context {
};
+struct st_buffer {
+};
+
%newobject st_device::texture_create;
%newobject st_device::context_create;
@@ -197,9 +199,9 @@ struct st_context {
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);
}
};
@@ -323,10 +325,10 @@ struct st_context {
$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,
@@ -522,6 +524,25 @@ error1:
};
+%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) {