Пример #1
0
def run():
    IwGxInit()
    IwGraphicsInit()

    IwGxSetPerspMul(IwGxGetScreenWidth() / 3)

    viewMat = CIwFMat()
    viewMat.SetIdentity()
    viewMat.SetRotZ(math.pi)
    viewMat.t.z = -200.0
    IwGxSetViewMatrix(viewMat)

    IwGetResManager().LoadGroup("model.group")

    model = AsIwModel(IwGetResManager().GetResNamed("FunkyVic", "CIwModel"))

    ents = []
    for i in range(0, 10):
        modMat = CIwFMat()
        modMat.SetRotY(random.random() * math.pi)
        modMat.t.x = random.random() * 1000.0 - 500.0
        modMat.t.y = random.random() * 1000.0 - 500.0
        ents.append(entity(model, modMat))

    done = False
    angle = 0.0

    while not done:

        IwGxClear()

        for e in ents:
            e.mat.PostRotateY(0.05)
            e.render()

        IwGxFlush()
        IwGxSwapBuffers()

        # To take advantage of IwGL's automatic screen rotation support, the
        # projection matrix and viewport should be set up every frame.
        if s3e.s3eDeviceCheckQuitRequest():
            done = True
        pass

        s3e.s3ePointerUpdate()

        state = s3e.s3ePointerGetState(s3e.S3E_POINTER_BUTTON_SELECT)
        if state & s3e.S3E_POINTER_STATE_PRESSED:
            lastPos = get_pointer_state()
        elif state & s3e.S3E_POINTER_STATE_DOWN:
            pos = get_pointer_state()
            viewMat.PostRotateY((pos[0] - lastPos[0]) * 0.05)
            viewMat.PreRotateX((pos[1] - lastPos[1]) * 0.05)
            lastPos = pos
            IwGxSetViewMatrix(viewMat)

        s3e.s3eDeviceYield(0)

    IwGraphicsTerminate()
    IwGxTerminate()
Пример #2
0
def run():
    print 'hello, this is python code speaking'

    count = 0

    s3e.s3eSurfaceClear(00,0xFF,0x12)
 
    width = s3e.s3eSurfaceGetInt(s3e.S3E_SURFACE_WIDTH)
    height = s3e.s3eSurfaceGetInt(s3e.S3E_SURFACE_HEIGHT)
    pitch = s3e.s3eSurfaceGetInt(s3e.S3E_SURFACE_PITCH)
    
    print "Width %d Height %d Pitch %d" % (width, height, pitch)
    bytes = height * pitch

    surface = s3e.s3eSurfacePtr()
    print type(surface)
    print len(surface)

    colours = 360
    duration = 3.0
   
    starttime = time.time()
    # cycle through colour spectrum for duration
    for r in range(colours):
        val = getRgb565Bytes(*colorsys.hsv_to_rgb(r/float(colours), 1.0, 1.0))
        s3e.s3eSurfaceClear(*map(lambda c : int(c * 0xFF), colorsys.hsv_to_rgb(r/float(colours), 1.0, 1.0)))
        s3e.s3eSurfaceShow()

        if time.time < r * duration / colours:
            time.sleep(0.01)
    
    # copy to surface
    for i in range(1000):
        drawCircle(30,100, (0x200,0x30,0x66))
        s3e.s3eSurfaceShow()
        s3e.s3eDeviceYield(0)
    s3e.s3eSurfaceClear(0)
    s3e.s3eVideoPlay("angel_fish.jpg", 0, 0, 0, 320, 320)
    s3e.s3eAudioPlay("trumpet.wav", 0)
    time.sleep(3)
Пример #3
0
def run():
    print 'hello, this is python code speaking'

    iwgl.IwGLInit()

    print "Screen BPP  : %d\n" % (s3e.s3eSurfaceGetInt(s3e.S3E_SURFACE_PIXEL_TYPE) & s3e.S3E_SURFACE_PIXEL_SIZE_MASK)
    print "\n"
    print "Vendor     : %s\n" % glGetString(GL_VENDOR)
    print "Renderer   : %s\n" % glGetString(GL_RENDERER)
    print "Version    : %s\n" % glGetString(GL_VERSION)
    print "Extensions : %s\n" % glGetString(GL_EXTENSIONS)
    print "\n"

    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();

    glEnable(GL_DEPTH_TEST);

    glDepthFunc(GL_LESS);

    glShadeModel(GL_SMOOTH);

    start_time = datetime.now()
    frames = 0;
    done = False
    cube, color = getCube()

    while not done:
        #To take advantage of IwGL's automatic screen rotation support, the
        #projection matrix and viewport should be set up every frame.
        w = iwgl.IwGLGetInt(iwgl.IW_GL_WIDTH);
        h = iwgl.IwGLGetInt(iwgl.IW_GL_HEIGHT);
        glViewport(0, 0, w, h);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();

        glOrthof(-2.0, 2.0, -2.0, 2.0, -20.0, 20.0);

        # Do our drawing, too.
        glClearColor(0.0, 0.0, 0.0, 1.0);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glEnableClientState(GL_VERTEX_ARRAY);
        glEnableClientState(GL_COLOR_ARRAY);
        glColorPointer(4, GL_FLOAT, 0, color);
        glVertexPointer(3, GL_FLOAT, 0, cube);
        glDrawArrays(GL_TRIANGLE_STRIP, 0, 24);
        glDisableClientState(GL_VERTEX_ARRAY);
        glDisableClientState(GL_COLOR_ARRAY);
        glMatrixMode(GL_MODELVIEW);
        glRotatef(5.0, 1.0, 1.0, 1.0);

        # Call IwGL swap instead of egl directly
        iwgl.IwGLSwapBuffers();

        # Check for error conditions. #
        gl_error = glGetError();

        if gl_error != GL_NO_ERROR:
            fprintf(stderr, "testgl: OpenGL error: %#x\n", gl_error);

        frames += 1
        # Allow the user to see what's happening 
        #time.sleep(0.01)
        s3e.s3eDeviceYield(10);
        duration = datetime.now() - start_time
        if duration.seconds > 3:
            print duration
            print frames
            print "%f FPS" % (frames/duration.seconds)

    iwgl.IwGLTerminate()