Author: ArcRiley
Date: 2007-07-07 02:54:18 -0400 (Sat, 07 Jul 2007)
New Revision: 396
Modified:
trunk/pysoy/include/gl.pxd
trunk/pysoy/src/textures/Texture.pxi
trunk/pysoy/src/textures/Video.pxi
trunk/pysoy/src/textures/soy.textures.pxd
trunk/pysoy/tests/tex_pyramid.py
Log:
Theora video is working (it's greyscale, uncropped, and unpaced tho)
Modified: trunk/pysoy/include/gl.pxd
===================================================================
--- trunk/pysoy/include/gl.pxd 2007-07-07 05:17:33 UTC (rev 395)
+++ trunk/pysoy/include/gl.pxd 2007-07-07 06:54:18 UTC (rev 396)
@@ -998,19 +998,19 @@
cdef void glOrtho( GLdouble left, GLdouble right, \
GLdouble bottom, GLdouble top, \
GLdouble near_val, GLdouble far_val )
- cdef void glViewport( GLint x, GLint y, GLsizei, GLsizei height )
+ cdef void glViewport( GLint, GLint, GLsizei, GLsizei height )
cdef void glPushMatrix()
cdef void glPopMatrix()
cdef void glLoadIdentity()
cdef void glLoadMatrixf( GLfloat * m )
cdef void glMultMatrixf( GLfloat * m )
- cdef void glTranslatef( GLfloat x, GLfloat y, GLfloat z )
+ cdef void glTranslatef( GLfloat, GLfloat, GLfloat z )
# Legacy Functions
cdef void glBegin( GLenum )
cdef void glEnd()
- cdef void glVertex2f( GLfloat x, GLfloat y )
- cdef void glVertex3f( GLfloat x, GLfloat y, GLfloat z )
+ cdef void glVertex2f( GLfloat, GLfloat y )
+ cdef void glVertex3f( GLfloat, GLfloat, GLfloat z )
cdef void glColor3f( GLfloat r, GLfloat g, GLfloat b )
cdef void glColor3ub( GLubyte r, GLubyte g, GLubyte b )
cdef void glColor4ub( GLubyte r, GLubyte g, GLubyte b, GLubyte a )
@@ -1071,9 +1071,25 @@
cdef void glGenTextures ( GLsizei, GLuint* )
cdef void glDeleteTextures ( GLsizei, GLuint* )
cdef void glBindTexture ( GLenum, GLuint )
+ cdef void glPrioritizeTextures( GLsizei, GLuint*, GLclampf* )
+ cdef GLboolean glAreTexturesResident( GLsizei, GLuint*, GLboolean* )
cdef GLboolean glIsTexture ( GLuint )
+ cdef void glTexSubImage1D ( GLenum, GLint, GLint, GLsizei, GLenum,
+ GLenum, GLvoid* )
+ cdef void glTexSubImage2D ( GLenum, GLint, GLint, GLint, GLsizei, GLsizei,
+ GLenum, GLenum, GLvoid* )
+ cdef void glTexSubImage3D ( GLenum, GLint, GLint, GLint, GLint, GLsizei,
+ GLsizei, GLsizei, GLenum, GLenum, GLvoid* )
+ cdef void glCopyTexImage1D ( GLenum, GLint, GLenum, GLint, GLint,
+ GLsizei, GLint )
+ cdef void glCopyTexImage2D ( GLenum, GLint, GLenum, GLint, GLint,
+ GLsizei, GLsizei, GLint )
+ cdef void glCopyTexSubImage1D( GLenum, GLint, GLint, GLint, GLint, GLsizei )
+ cdef void glCopyTexSubImage2D( GLenum, GLint, GLint, GLint, GLint, GLint,
+ GLsizei, GLsizei )
+ cdef void glCopyTexSubImage3D( GLenum, GLint, GLint, GLint, GLint, GLint,
+ GLint, GLsizei, GLsizei )
-
# GLU
cdef void gluPerspective( GLdouble, GLdouble,
GLdouble, GLdouble )
Modified: trunk/pysoy/src/textures/Texture.pxi
===================================================================
--- trunk/pysoy/src/textures/Texture.pxi 2007-07-07 05:17:33 UTC (rev
395)
+++ trunk/pysoy/src/textures/Texture.pxi 2007-07-07 06:54:18 UTC (rev
396)
@@ -94,6 +94,8 @@
gl.GL_LINEAR)
gl.glTexParameteri(self._textureTarget, gl.GL_TEXTURE_MIN_FILTER,
gl.GL_LINEAR)
+ self._update = 1
+ if self._update :
if self._textureTarget == gl.GL_TEXTURE_1D :
gl.glTexImage1D(gl.GL_TEXTURE_1D, 0, self._iFormats[self._chans],
self._width, 0,
@@ -109,7 +111,7 @@
self._width, self._height, self._depth, 0,
self._oFormats[self._chans], gl.GL_UNSIGNED_BYTE,
self._texels)
-
+ self._update = 0
else :
gl.glBindTexture(self._textureTarget, self._textureID)
Modified: trunk/pysoy/src/textures/Video.pxi
===================================================================
--- trunk/pysoy/src/textures/Video.pxi 2007-07-07 05:17:33 UTC (rev 395)
+++ trunk/pysoy/src/textures/Video.pxi 2007-07-07 06:54:18 UTC (rev 396)
@@ -37,37 +37,47 @@
self._stage == -1
return 0
_page = <ogg.ogg_page *> data
+ # Read Page 0
if self._stage == 0 :
ogg.ogg_stream_init(&self._stream, ogg.ogg_page_serialno(_page))
ogg.theora_info_init(&self._info)
ogg.theora_comment_init(&self._comment)
self._stage = 1
+ # Read in the page if not -1
if self._stage > 0 :
- if ogg.ogg_page_granulepos(_page) != 0 :
+ ogg.ogg_stream_pagein(&self._stream, _page)
+ # Read pre-data pages (if any)
+ if self._stage == 1 :
+ if ogg.ogg_page_granulepos(_page) == 0 :
+ while ogg.ogg_stream_packetout(&self._stream, &_packet) :
+ if ogg.theora_decode_header(&self._info, &self._comment,&_packet)<0 :
+ # Error in header, clear what we've setup and bail
+ ogg.ogg_stream_clear(&self._stream)
+ ogg.theora_info_clear(&self._info)
+ ogg.theora_comment_clear(&self._comment)
+ self._stage = -1
+ return 0
+ if ogg.ogg_page_pageno(_page) == 0 :
+ self._resize(1, self._squareup(self._info.frame_width),
+ self._squareup(self._info.frame_height), 1)
+ self._aspect = ( <float> self._info.frame_width / \
+ <float> self._info.frame_height ) * \
+ ( <float> self._info.aspect_numerator / \
+ <float> self._info.aspect_denominator )
+ else :
ogg.theora_decode_init(&self._decode, &self._info)
- self._resize(1, self._squareup(self._info.width),
- self._squareup(self._info.height), 1)
- stdio.printf('resized\n')
self._stage = 2
- ogg.ogg_stream_pagein(&self._stream, _page)
- if self._stage == 1 :
- while ogg.ogg_stream_packetout(&self._stream, &_packet) :
- if ogg.theora_decode_header(&self._info, &self._comment, &_packet)<0 :
- # Error in header, clear what we've setup and bail
- ogg.ogg_stream_clear(&self._stream)
- ogg.theora_info_clear(&self._info)
- ogg.theora_comment_clear(&self._comment)
- self._stage = -1
- return 0
if self._stage == 2 :
# Theora frames are 1:1 with Ogg packets, but packets != pages
while ogg.ogg_stream_packetout(&self._stream, &_packet) :
ogg.theora_decode_packetin(&self._decode, &_packet)
# _time=theora_granule_time(&self._decode, self._decode.granulepos)
ogg.theora_decode_YUVout(&self._decode, &_yuv)
- for y from 0 <= y < _yuv.y_height :
- for x from 0 <= x < _yuv.y_width :
- self._texels[(y*self._width)+x] = _yuv.y[(_yuv.y_stride*y)+x]
+ for y from 0 <= y < self._info.frame_height :
+ for x from 0 <= x < self._info.frame_width :
+ self._texels[((self._info.frame_height-y)*self._width)+x] = \
+ _yuv.y[(_yuv.y_stride*y)+x]
+ self._update = 1
return 1
cdef int _save(self, void *data) :
Modified: trunk/pysoy/src/textures/soy.textures.pxd
===================================================================
--- trunk/pysoy/src/textures/soy.textures.pxd 2007-07-07 05:17:33 UTC (rev
395)
+++ trunk/pysoy/src/textures/soy.textures.pxd 2007-07-07 06:54:18 UTC (rev
396)
@@ -23,14 +23,16 @@
cimport stdio
cimport soy._internals
+
cdef class Texture (soy._internals.Loadable) :
cdef gl.GLuint _textureID
cdef gl.GLenum _textureTarget
cdef int _chans
- cdef int _width
- cdef int _height
- cdef int _depth
+ cdef gl.GLsizei _width
+ cdef gl.GLsizei _height
+ cdef gl.GLsizei _depth
cdef float _aspect
+ cdef int _update
cdef gl.GLubyte *_texels
#
# Lookup Arrays
@@ -42,6 +44,7 @@
cdef void _resize(self, int, int, int, int)
cdef int _squareup(self, int)
+
cdef class Video (Texture) :
cdef int _stage # -1=Null, 0=New, 1=Header, 2=Decode
cdef ogg.ogg_stream_state _stream
Modified: trunk/pysoy/tests/tex_pyramid.py
===================================================================
--- trunk/pysoy/tests/tex_pyramid.py 2007-07-07 05:17:33 UTC (rev 395)
+++ trunk/pysoy/tests/tex_pyramid.py 2007-07-07 06:54:18 UTC (rev 396)
@@ -20,10 +20,15 @@
cam = soy.bodies.Camera(sce)
cam.position = (0.0, 0.0, 5.0)
-stk = soy.widgets.StackZ(win, margin=10)
-ca1 = soy.widgets.Canvas(stk, aspect=0.0, texture=lava)
-pro = soy.widgets.Projector(stk, camera=cam)
-ca2 = soy.widgets.Canvas(stk, texture=face)
+stz = soy.widgets.StackZ(win, margin=10)
+ca1 = soy.widgets.Canvas(stz, aspect=0.0, texture=lava)
+pro = soy.widgets.Projector(stz, camera=cam)
+stx = soy.widgets.StackX(stz)
+sp1 = soy.widgets.Widget(stx)
+sp2 = soy.widgets.Widget(stx)
+sty = soy.widgets.StackY(stx)
+sp3 = soy.widgets.Widget(sty)
+ca2 = soy.widgets.Canvas(sty, texture=face)
pyr = soy.bodies.Pyramid(sce, luma)
pyr.rotation = (1.0, 1.0, 0.0)
_______________________________________________
PySoy-SVN mailing list
[email protected]
http://www.pysoy.org/mailman/listinfo/pysoy-svn