コード例 #1
0
ファイル: test_array.py プロジェクト: mario007/renmas
    def test_array(self):

        p = SuperPoint(3.0, 4.0)
        arr = Array(p)
        arr.append(p)
        arr.append(p)
        p = SuperPoint(7.0, 9.0)
        arr.append(p)

        code = """
index = 2
temp = arr[index]
p1 = temp.x
temp.y = 12.34
        """
        arg = ArrayArg("arr", arr)
        arg1 = FloatArg("p1", 4.4)
        shader = Shader(code=code, args=[arg, arg1])
        shader.compile()
        shader.prepare([Runtime()])
        shader.execute()
        val = shader.get_value("p1")
        self.assertAlmostEqual(val, 7.0)
        obj = arr[2]
        self.assertAlmostEqual(obj.y, 12.34, 6)
コード例 #2
0
ファイル: shp_mgr.py プロジェクト: mario007/renmas
    def add(self, name, shape):
        if name in self._shape_names:
            raise ValueError("Shape %s allready exist" % name)

        if shape in self._shape_addr:
            raise ValueError("Shape allready exist", shape)

        self._shape_names[name] = shape
        if type(shape) not in self._shape_arrays:
            darr = Array(shape)
            self._shape_arrays[type(shape)] = darr
            idx = 0
        else:
            darr = self._shape_arrays[type(shape)]
            idx = len(darr)

        darr.append(shape)
        self._shape_addr[shape] = idx
コード例 #3
0
    def test_array(self):

        p = SuperPoint(3.0, 4.0)
        arr = Array(p)
        arr.append(p)
        arr.append(p)
        p = SuperPoint(7.0, 9.0)
        arr.append(p)

        code = """
index = 2
temp = arr[index]
p1 = temp.x
temp.y = 12.34
        """
        arg = ArrayArg('arr', arr)
        arg1 = FloatArg('p1', 4.4)
        shader = Shader(code=code, args=[arg, arg1])
        shader.compile()
        shader.prepare([Runtime()])
        shader.execute()
        val = shader.get_value('p1')
        self.assertAlmostEqual(val, 7.0)
        obj = arr[2]
        self.assertAlmostEqual(obj.y, 12.34, 6)