Crystal Space
Welcome, Guest. Please login or register.
October 02, 2014, 01:42:09 am

Login with username, password and session length
Search:     Advanced search
9020 Posts in 2053 Topics by 8569 Members
Latest Member: Embingos
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Blit in Python
« previous next »
Pages: [1] Print
Author Topic: Blit in Python  (Read 1841 times)
herks
Newbie
*
Posts: 2


View Profile Email
« on: April 19, 2006, 05:20:48 pm »

Hi, this may be a dumb question,  I'm working of the tutorial2.py file.  I have a Video Capture class that i wrote that captures video into a python string.

I'm trying to blit this string (buffer) onto a texture so i can have a wall with live video on it in crystal space.

Using the tutorial2 as a simple guide to try to get live video on those walls instead of the stone, i have the following code:

Code:
def SetupRoom(self):
       self.engine.SetLightingCacheMode(0)

        # l**** load video texture ****
        self.engine.CreateBlackTexture("video", 512, 256, csColor(0, 255, 0), CS_TEXTURE_2D )

        #if self.loader.LoadTexture("stone", "/lib/std/stone4.gif")==None:
        #    FatalError("Error: unable to load texture")

        # now get it as a material from the engine
        material=self.engine.GetMaterialList().FindByName("stone")

        # create the 'room' 
        room = self.engine.CreateSector("room")
        walls = self.engine.CreateSectorWallsMesh(room,"walls")
        walls_state = SCF_QUERY_INTERFACE(walls.GetMeshObject().GetFactory(), iThingFactoryState)
        walls_state.AddInsideBox (csVector3 (-5, 0, -5), csVector3 (5, 20, 5))
        walls_state.SetPolygonMaterial (CS_POLYRANGE_LAST, material);
        walls_state.SetPolygonTextureMapping (CS_POLYRANGE_LAST, 3);       
        return roomdef SetupRoom(self):

def SetupFrame (self):
        #print 'SetupFrame called',
        elapsed_time = self.vc.GetElapsedTicks()


        self.video.update()  #get new video frame, init'd in code i didnt post, but it works.
        self.video.listToBuffer() #creates the string buffer to pass to blit.

        tex = self.engine.FindTexture("video") #find the texture.
       
        tex.GetTextureHandle().Blit(0,0,self.video.width, self.video.height, self.video.buffer, iTextureHandle.RGBA8888)
               
        # Now rotate the camera according to keyboard state
        speed = (elapsed_time / 1000.) * (0.03 * 20);
        if self.keybd.GetKeyState(CSKEY_RIGHT):
            self.view.GetCamera().GetTransform().RotateThis(CS_VEC_ROT_RIGHT, speed)
        if self.keybd.GetKeyState(CSKEY_LEFT):
            self.view.GetCamera().GetTransform().RotateThis(CS_VEC_ROT_LEFT, speed)
        if self.keybd.GetKeyState(CSKEY_PGUP):
            self.view.GetCamera().GetTransform().RotateThis(CS_VEC_TILT_UP, speed)
        if self.keybd.GetKeyState(CSKEY_PGDN):
            self.view.GetCamera().GetTransform().RotateThis(CS_VEC_TILT_DOWN, speed)
        if self.keybd.GetKeyState(CSKEY_UP):
            self.view.GetCamera().Move(CS_VEC_FORWARD * 4 * speed)
        if self.keybd.GetKeyState(CSKEY_DOWN):
            self.view.GetCamera().Move(CS_VEC_BACKWARD * 4 * speed)
        # Tell 3D driver we're going to display 3D things.
        if not self.g3d.BeginDraw(self.engine.GetBeginDrawFlags() | CSDRAW_3DGRAPHICS):
            FatalError()
        self.view.Draw()
        #print 'SetupFrame done'
 


So it all seems to work, however, when i get to Blit() call, i get this error:

Code:
Blitting....Traceback (most recent call last):
  File "./scripts/python/tutorial2.py", line 238, in EventHandler
    app.SetupFrame()
  File "./scripts/python/tutorial2.py", line 191, in SetupFrame
    tex.GetTextureHandle().Blit(0,0,self.video.width, self.video.height, self.vi
deo.buffer, iTextureHandle.RGBA8888)
  File "/cygdrive/c/Documents and Settings/jricher/My Documents/Projects/Multi-U
AV/CrystalSpaceClient/CS/scripts/python/cspace.py", line 10417, in Blit
    def Blit(*args): return _cspace.iTextureHandle_Blit(*args)
NotImplementedError: No matching function for overloaded 'iTextureHandle_Blit'



Any idea on what i'm doing wrong?

Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 4.535 seconds with 16 queries.