Python ctypes.c_float() Examples

The following are 30 code examples of ctypes.c_float(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module ctypes , or try the search function .
Example #1
Source File: io_can.py    From PythonPilot with Apache License 2.0 7 votes vote down vote up
def __init__(self, cfg):
        self.__is_use_can_port = cfg['use_can']

        # Data for store
        self.tx_counter_camera_unit = multiprocessing.Value(ctypes.c_int,0)
        self.tx_servo_on_flag = multiprocessing.Value(ctypes.c_bool,False)
        self.tx_target_angle = multiprocessing.Value(ctypes.c_float,0.0)
        self.can_error_count_tx = multiprocessing.Value(ctypes.c_int,0)

        # Initialize process
        self.__m = multiprocessing.Process(target=self.__update, \
                                           args=(cfg['can_name'], \
                                                 cfg['can_bustype'], \
                                                 cfg['can_bitrate'], \
                                                 cfg['can_dbc_path'], \
                                                 cfg['can_tx_interval']))
        # Start process
        self.__m.start()

        return 
Example #2
Source File: epanet2.py    From epynet with Apache License 2.0 6 votes vote down vote up
def ENgetcurve(self, curveIndex):
        curveid = ctypes.create_string_buffer(self._max_label_len)
        nValues = ctypes.c_int()
        xValues= (ctypes.c_float*100)()
        yValues= (ctypes.c_float*100)()
        ierr= self._lib.EN_getcurve(self.ph, curveIndex,
                              ctypes.byref(curveid),
                             ctypes.byref(nValues),
                             xValues,
                             yValues
                             )
        # strange behavior of ENgetcurve: it returns also curveID
        # better split in two distinct functions ....
        if ierr!=0: raise ENtoolkitError(self, ierr)
        curve= []
        for i in range(nValues.value):
           curve.append( (xValues[i],yValues[i]) )
        return curve 
Example #3
Source File: epanet2.py    From epynet with Apache License 2.0 6 votes vote down vote up
def ENsetcontrol(self, cindex, ctype, lindex, setting, nindex, level ):
        """Sets the parameters of a simple control statement.
        Arguments:
           cindex:  control statement index
           ctype:   control type code  EN_LOWLEVEL   (Low Level Control)
                                       EN_HILEVEL    (High Level Control)  
                                       EN_TIMER      (Timer Control)       
                                       EN_TIMEOFDAY  (Time-of-Day Control)
           lindex:  index of link being controlled
           setting: value of the control setting
           nindex:  index of controlling node
           level:   value of controlling water level or pressure for level controls
                    or of time of control action (in seconds) for time-based controls"""
        #int ENsetcontrol(int cindex, int* ctype, int* lindex, float* setting, int* nindex, float* level )
        ierr= self._lib.EN_setcontrol(self.ph, ctypes.c_int(cindex), ctypes.c_int(ctype),
                                ctypes.c_int(lindex), ctypes.c_float(setting), 
                                ctypes.c_int(nindex), ctypes.c_float(level) )
        if ierr!=0: raise ENtoolkitError(self, ierr) 
Example #4
Source File: epanet2.py    From epynet with Apache License 2.0 6 votes vote down vote up
def ENaddcontrol(self, ctype, lindex, setting, nindex, level ):
        """Sets the parameters of a simple control statement.
        Arguments:
           ctype:   control type code  EN_LOWLEVEL   (Low Level Control)
                                       EN_HILEVEL    (High Level Control)  
                                       EN_TIMER      (Timer Control)       
                                       EN_TIMEOFDAY  (Time-of-Day Control)
           lindex:  index of link being controlled
           setting: value of the control setting
           nindex:  index of controlling node
           level:   value of controlling water level or pressure for level controls
                    or of time of control action (in seconds) for time-based controls"""
        #int ENsetcontrol(int cindex, int* ctype, int* lindex, float* setting, int* nindex, float* level )
        cindex = ctypes.c_int()
        ierr= self._lib.EN_addcontrol(self.ph, ctypes.byref(cindex), ctypes.c_int(ctype),
                                ctypes.c_int(lindex), ctypes.c_float(setting), 
                                ctypes.c_int(nindex), ctypes.c_float(level))
        if ierr!=0: raise ENtoolkitError(self, ierr)
        return cindex 
Example #5
Source File: test_c_functions.py    From kernel_tuner with Apache License 2.0 6 votes vote down vote up
def test_ready_argument_list2():
    arg1 = numpy.array([1, 2, 3]).astype(numpy.float32)
    arg2 = numpy.int32(7)
    arg3 = numpy.float32(6.0)
    arguments = [arg1, arg2, arg3]

    cfunc = CFunctions()
    output = cfunc.ready_argument_list(arguments)
    print(output)

    output_arg1 = numpy.ctypeslib.as_array(output[0].ctypes, shape=arg1.shape)

    assert output_arg1.dtype == 'float32'
    assert isinstance(output[1].ctypes, C.c_int32)
    assert isinstance(output[2].ctypes, C.c_float)

    assert all(output_arg1 == arg1)
    assert output[1][1].value == arg2
    assert output[2][1].value == arg3 
Example #6
Source File: __init__.py    From Arnold-For-Blender with GNU General Public License v3.0 6 votes vote down vote up
def _AiNodeSetArray(node, param, value):
    t = value[0]
    _len = len(value)
    if type(t) is float:
        int_arr_type = ctypes.c_float * len(value)
        oftype = arnold.AI_TYPE_FLOAT
        _a = arnold.AiArrayConvert(_len, 1, oftype, int_arr_type(*value))
    if type(t) is list:
        oftype = arnold.AI_TYPE_RGB
        arr_t = ctypes.c_float * 3
        arr_of_arr_t = arr_t * len(value)
        _a = arnold.AiArrayConvert(_len, 1, oftype, arr_of_arr_t(arr_t(*value[0]), arr_t(*value[1])))
    if type(t) is int:
        int_arr_type = ctypes.c_int * len(value)
        oftype = arnold.AI_TYPE_INT
        _a = arnold.AiArrayConvert(_len, 1, oftype, int_arr_type(*value))
    arnold.AiNodeSetArray(node, param, _a) 
Example #7
Source File: libcudnn.py    From paleo with Apache License 2.0 6 votes vote down vote up
def cudnnSetTensor(handle, srcDesc, srcData, value):
    """"
    Set all data points of a tensor to a given value : srcDest = alpha.

    Parameters
    ----------
    handle : cudnnHandle
        Handle to a previously created cuDNN context.
    srcDesc : cudnnTensorDescriptor
        Handle to a previously initialized tensor descriptor.
    srcData : void_p
        Pointer to data of the tensor described by srcDesc descriptor.
    value : float
        Value that all elements of the tensor will be set to.
    """

    dataType, _, _, _, _, _, _, _, _ = cudnnGetTensor4dDescriptor(srcDesc)
    if dataType == cudnnDataType['CUDNN_DATA_DOUBLE']:
        alphaRef = ctypes.byref(ctypes.c_double(alpha))
    else:
        alphaRef = ctypes.byref(ctypes.c_float(alpha))

    status = _libcudnn.cudnnSetTensor(handle, srcDesc, srcData, alphaRef)
    cudnnCheckStatus(status) 
Example #8
Source File: messages.py    From olympe with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _ar_arsdk_encode_type_info(cls, ar_argtype):
        arsdk_encode_type_info_map = {
            arsdkparser.ArArgType.I8: (od.ARSDK_ARG_TYPE_I8, "i8", ctypes.c_int8),
            arsdkparser.ArArgType.U8: (od.ARSDK_ARG_TYPE_U8, "u8", ctypes.c_uint8),
            arsdkparser.ArArgType.I16: (od.ARSDK_ARG_TYPE_I16, "i16", ctypes.c_int16),
            arsdkparser.ArArgType.U16: (od.ARSDK_ARG_TYPE_U16, "u16", ctypes.c_uint16),
            arsdkparser.ArArgType.I32: (od.ARSDK_ARG_TYPE_I32, "i32", ctypes.c_int32),
            arsdkparser.ArArgType.U32: (od.ARSDK_ARG_TYPE_U32, "u32", ctypes.c_uint32),
            arsdkparser.ArArgType.I64: (od.ARSDK_ARG_TYPE_I64, "i64", ctypes.c_int64),
            arsdkparser.ArArgType.U64: (od.ARSDK_ARG_TYPE_U64, "u64", ctypes.c_uint64),
            arsdkparser.ArArgType.FLOAT: (od.ARSDK_ARG_TYPE_FLOAT, "f32", ctypes.c_float),
            arsdkparser.ArArgType.DOUBLE: (od.ARSDK_ARG_TYPE_DOUBLE, "f64", ctypes.c_double),
            arsdkparser.ArArgType.STRING: (od.ARSDK_ARG_TYPE_STRING, "cstr", od.char_pointer_cast),
            arsdkparser.ArArgType.ENUM: (od.ARSDK_ARG_TYPE_ENUM, "i32", ctypes.c_int32),
        }
        return arsdk_encode_type_info_map[ar_argtype] 
Example #9
Source File: quantization.py    From dynamic-training-with-apache-mxnet-on-aws with Apache License 2.0 6 votes vote down vote up
def _calibrate_quantized_sym(qsym, th_dict):
    """Given a dictionary containing the thresholds for quantizing the layers,
    set the thresholds into the quantized symbol as the params of requantize operators.
    """
    if th_dict is None or len(th_dict) == 0:
        return qsym
    num_layer_outputs = len(th_dict)
    layer_output_names = []
    min_vals = []
    max_vals = []
    for k, v in th_dict.items():
        layer_output_names.append(k)
        min_vals.append(v[0])
        max_vals.append(v[1])

    calibrated_sym = SymbolHandle()
    check_call(_LIB.MXSetCalibTableToQuantizedSymbol(qsym.handle,
                                                     mx_uint(num_layer_outputs),
                                                     c_str_array(layer_output_names),
                                                     c_array(ctypes.c_float, min_vals),
                                                     c_array(ctypes.c_float, max_vals),
                                                     ctypes.byref(calibrated_sym)))
    return Symbol(calibrated_sym) 
Example #10
Source File: io_can.py    From PythonPilot with Apache License 2.0 6 votes vote down vote up
def __init__(self, cfg):
        self.__is_use_can_port = cfg['use_can']

        # Data for store
        self.rx_counter_servo_unit = multiprocessing.Value(ctypes.c_int,0)
        self.rx_time_us_diff = multiprocessing.Value(ctypes.c_int,0)
        self.rx_button_y = multiprocessing.Value(ctypes.c_bool,False)
        self.rx_button_g = multiprocessing.Value(ctypes.c_bool,False)
        self.rx_button_r = multiprocessing.Value(ctypes.c_bool,False)
        self.rx_actual_angle = multiprocessing.Value(ctypes.c_float,0.0)
        self.can_error_count_rx = multiprocessing.Value(ctypes.c_int,0)

        # Initialize process
        self.__m = multiprocessing.Process(target=self.__process_can, \
                                           args=(cfg['can_name'], \
                                                 cfg['can_bustype'], \
                                                 cfg['can_bitrate'], \
                                                 cfg['can_dbc_path'], \
                                                 cfg['can_rx_interval']))
        # Start process
        self.__m.start()

        return 
Example #11
Source File: m_blas_wrapper.py    From pyscf with Apache License 2.0 6 votes vote down vote up
def spmv_wrapper(n, alpha, ap, x, beta = 0.0, incx = 1, incy = 1, lower=0):
  """ Small blas wrapper that is missing in scipy.linalg.blas in scipy.version<=1 """

  if ap.size != n*(n+1)//2:
    raise ValueError("simple wrapper, you MUST provide x.size = n, ap.size = n*(n+1)/2")
    
  if ap.dtype == np.float32:
    y = np.zeros((n), dtype=np.float32)
    libsparsetools.SSPMV_wrapper(c_int(lower), c_int(n), c_float(alpha),
                ap.ctypes.data_as(POINTER(c_float)),
                x.ctypes.data_as(POINTER(c_float)), c_int(incx), c_float(beta),
                y.ctypes.data_as(POINTER(c_float)), c_int(incy))
  elif ap.dtype == np.float64:
    y = np.zeros((n), dtype=np.float64)
    libsparsetools.DSPMV_wrapper(c_int(lower), c_int(n), c_double(alpha),
                ap.ctypes.data_as(POINTER(c_double)),
                x.ctypes.data_as(POINTER(c_double)), c_int(incx), c_double(beta),
                y.ctypes.data_as(POINTER(c_double)), c_int(incy))
  else:
    raise ValueError("dtype error, only np.float32 and np.float64 implemented")

  return y 
Example #12
Source File: test_c_functions.py    From kernel_tuner with Apache License 2.0 5 votes vote down vote up
def test_memcpy_htod():
    a = [1, 2, 3, 4]
    src = numpy.array(a).astype(numpy.float32)
    x = numpy.zeros_like(src)
    x_c = x.ctypes.data_as(C.POINTER(C.c_float))
    arg = Argument(numpy=x, ctypes=x_c)

    cfunc = CFunctions()
    cfunc.memcpy_htod(arg, src)

    assert all(arg.numpy == a) 
Example #13
Source File: actor_learner.py    From async-deep-rl with Apache License 2.0 5 votes vote down vote up
def sync_net_with_shared_memory(self, dest_net, shared_mem_vars):
        feed_dict = {}
        offset = 0
        params = np.frombuffer(shared_mem_vars.vars, 
                                  ctypes.c_float)
        for i in xrange(len(dest_net.params)):
            shape = shared_mem_vars.var_shapes[i]
            size = np.prod(shape)
            feed_dict[dest_net.params_ph[i]] = \
                    params[offset:offset+size].reshape(shape)
            offset += size
        
        self.session.run(dest_net.sync_with_shared_memory, 
                feed_dict=feed_dict) 
Example #14
Source File: cpp32.py    From msl-loadlib with MIT License 5 votes vote down vote up
def subtract(self, a, b):
        """Subtract two floating-point numbers *('float' refers to the C++ data type)*.

        The corresponding C++ code is

        .. code-block:: cpp

            float subtract(float a, float b) {
                return a - b;
            }

        See the corresponding 64-bit :meth:`~.cpp64.Cpp64.subtract` method.

        Parameters
        ----------
        a : :class:`float`
            The first floating-point number.
        b : :class:`float`
            The second floating-point number.

        Returns
        -------
        :class:`float`
            The difference between `a` and `b`.
        """
        self.lib.subtract.restype = ctypes.c_float
        return self.lib.subtract(ctypes.c_float(a), ctypes.c_float(b)) 
Example #15
Source File: fortran32.py    From msl-loadlib with MIT License 5 votes vote down vote up
def multiply_float32(self, a, b):
        """Multiply two FORTRAN floating-point numbers.

        The corresponding FORTRAN code is

        .. code-block:: fortran

            function multiply_float32(a, b) result(value)
                !DEC$ ATTRIBUTES DLLEXPORT, ALIAS:'multiply_float32' :: multiply_float32
                implicit none
                real(4) :: a, b, value
                value = a * b
            end function multiply_float32

        See the corresponding 64-bit :meth:`~.fortran64.Fortran64.multiply_float32` method.

        Parameters
        ----------
        a : :class:`float`
            The first floating-point number.
        b : :class:`float`
            The second floating-point number.

        Returns
        -------
        :class:`float`
            The product of `a` and `b`.
        """
        ac = ctypes.c_float(a)
        bc = ctypes.c_float(b)
        self.lib.multiply_float32.restype = ctypes.c_float
        return self.lib.multiply_float32(ctypes.byref(ac), ctypes.byref(bc)) 
Example #16
Source File: actor_learner.py    From async-deep-rl with Apache License 2.0 5 votes vote down vote up
def apply_gradients_to_shared_memory_vars(self, grads):
            #Flatten grads
            offset = 0
            for g in grads:
                self.flat_grads[offset:offset + g.size] = g.reshape(-1)
                offset += g.size
            g = self.flat_grads
            
            if self.optimizer_type == "adam" and self.optimizer_mode == "shared":
                p = np.frombuffer(self.learning_vars.vars, ctypes.c_float)
                p_size = self.learning_vars.size
                m = np.frombuffer(self.opt_st.ms, ctypes.c_float)
                v = np.frombuffer(self.opt_st.vs, ctypes.c_float)
                T = self.global_step.value() 
                self.opt_st.lr.value =  1.0 * self.opt_st.lr.value * (1 - self.b2**T)**0.5 / (1 - self.b1**T) 
                
                apply_grads_adam(m, v, g, p, p_size, self.opt_st.lr.value, self.b1, self.b2, self.e)
                    
            else: #local or shared rmsprop/momentum
                lr = self.decay_lr()
                if (self.optimizer_mode == "local"):
                    m = self.opt_st
                else: #shared 
                    m = np.frombuffer(self.opt_st.vars, ctypes.c_float)
                
                p = np.frombuffer(self.learning_vars.vars, ctypes.c_float)
                p_size = self.learning_vars.size
                _type = 0 if self.optimizer_type == "momentum" else 1
                    
                #print "BEFORE", "RMSPROP m", m[0], "GRAD", g[0], self.flat_grads[0], self.flat_grads2[0]
                apply_grads_mom_rmsprop(m, g, p, p_size, _type, lr, self.alpha, self.e)
                #print "AFTER", "RMSPROP m", m[0], "GRAD", g[0], self.flat_grads[0], self.flat_grads2[0] 
Example #17
Source File: io_gps.py    From PythonPilot with Apache License 2.0 5 votes vote down vote up
def __init__(self, cfg):
        self.__is_use_gps_port = cfg['use_gps']

        # Data for store
        self.latitude = multiprocessing.Value(ctypes.c_float,cfg['latitude_init'])
        self.longitude = multiprocessing.Value(ctypes.c_float,cfg['longitude_init'])

        # Initialize process
        self.__m = multiprocessing.Process(target=self.__process_gps, \
                                           args=(cfg['gps_interval'],))
        # Start process
        self.__m.start()
        return 
Example #18
Source File: shared_utils.py    From async-deep-rl with Apache License 2.0 5 votes vote down vote up
def malloc_contiguous(self, size, initial_val=None):
        if initial_val is None:
            return RawArray(ctypes.c_float, size)
        else:
            return RawArray(ctypes.c_float, initial_val) 
Example #19
Source File: actor_learner.py    From async-deep-rl with Apache License 2.0 5 votes vote down vote up
def init_shared_memory(self):
        # Initialize shared memory with tensorflow var values
        params = self.session.run(self.local_network.params)            
        # Merge all param matrices into a single 1-D array
        params = np.hstack([p.reshape(-1) for p in params])
        np.frombuffer(self.learning_vars.vars, ctypes.c_float)[:] = params
        if self.alg_type <> "a3c":
            np.frombuffer(self.target_vars.vars, ctypes.c_float)[:] = params
        #memoryview(self.learning_vars.vars)[:] = params
        #memoryview(self.target_vars.vars)[:] = memoryview(self.learning_vars.vars) 
Example #20
Source File: libcudnn.py    From paleo with Apache License 2.0 5 votes vote down vote up
def cudnnConvolutionBackwardFilter(handle, alpha, xDesc, x, dyDesc, dy,
                                   convDesc, algo, workspace,
                                   workSpaceSizeInBytes, beta, dwDesc, dw):
    dataType = cudnnGetTensor4dDescriptor(dyDesc)[0]
    if dataType == cudnnDataType['CUDNN_DATA_DOUBLE']:
        alphaRef = ctypes.byref(ctypes.c_double(alpha))
        betaRef = ctypes.byref(ctypes.c_double(beta))
    else:
        alphaRef = ctypes.byref(ctypes.c_float(alpha))
        betaRef = ctypes.byref(ctypes.c_float(beta))

    status = _libcudnn.cudnnConvolutionBackwardFilter(
        handle, alphaRef, xDesc, x, dyDesc, dy, convDesc, algo, workspace,
        workSpaceSizeInBytes, betaRef, dwDesc, dw)
    cudnnCheckStatus(status) 
Example #21
Source File: test_c_functions.py    From kernel_tuner with Apache License 2.0 5 votes vote down vote up
def test_memcpy_dtoh():
    a = [1, 2, 3, 4]
    x = numpy.array(a).astype(numpy.float32)
    x_c = x.ctypes.data_as(C.POINTER(C.c_float))
    arg = Argument(numpy=x, ctypes=x_c)
    output = numpy.zeros_like(x)

    cfunc = CFunctions()
    cfunc.memcpy_dtoh(output, arg)

    print(a)
    print(output)

    assert all(output == a)
    assert all(x == a) 
Example #22
Source File: test_c_functions.py    From kernel_tuner with Apache License 2.0 5 votes vote down vote up
def test_memset():
    a = [1, 2, 3, 4]
    x = numpy.array(a).astype(numpy.float32)
    x_c = x.ctypes.data_as(C.POINTER(C.c_float))
    arg = Argument(numpy=x, ctypes=x_c)

    cfunc = CFunctions()
    cfunc.memset(arg, 0, x.nbytes)

    output = numpy.ctypeslib.as_array(x_c, shape=(4,))

    print(output)
    assert all(output == numpy.zeros(4))
    assert all(x == numpy.zeros(4)) 
Example #23
Source File: epanet2.py    From epynet with Apache License 2.0 5 votes vote down vote up
def ENgetcurvevalue(self, curveIndex, point):
        x = ctypes.c_float()
        y = ctypes.c_float()
        ierr= self._lib.EN_getcurvevalue(self.ph, ctypes.c_int(curveIndex), ctypes.c_int(point-1), ctypes.byref(x), ctypes.byref(y))
        if ierr!=0: raise ENtoolkitError(self, ierr)
        return x.value, y.value 
Example #24
Source File: common.py    From MobulaOP with MIT License 5 votes vote down vote up
def _get_numpy_type():
        name2ctype = dict()
        pairs = [
            (np.dtype('int8'), ctypes.c_int8),
            (np.dtype('int16'), ctypes.c_int16),
            (np.dtype('int32'), ctypes.c_int32),
            (np.dtype('int64'), ctypes.c_int64),  # alias: np.int
            (np.dtype('float32'), ctypes.c_float),
            (np.dtype('float64'), ctypes.c_double),  # alias: np.float
        ]
        for dtype, ctype in pairs:
            name2ctype[dtype.name] = ctype
        return name2ctype 
Example #25
Source File: test_func.py    From MobulaOP with MIT License 5 votes vote down vote up
def test_const_template():
    shape = (5, 5)
    value = 3939
    cs = [ctypes.c_int, ctypes.c_float, ctypes.c_double]
    vs = [3, 9.9, 3.9]
    atols = [0, 1e-6, 1e-6]
    for ctype, value, atol in zip(cs, vs, atols):
        c_value = ctype(value)
        a = np.empty(shape)
        mobula.func.test_const_template(a.size, c_value, a)
        assert_almost_equal(np.tile(value, shape), a, atol=atol) 
Example #26
Source File: epanet2.py    From epynet with Apache License 2.0 5 votes vote down vote up
def ENsetcurve(self, curveIndex, values):
        nValues = len(values)
        Values_type = ctypes.c_float* nValues
        xValues = Values_type()
        yValues = Values_type()
        for i in range(nValues):
            xValues[i] = float(values[i][0])
            yValues[i] = float(values[i][1])

        ierr = self._lib.EN_setcurve(self.ph, curveIndex, xValues, yValues, nValues)
        if ierr!=0: raise ENtoolkitError(self, ierr) 
Example #27
Source File: vrep.py    From vrep-api-python with GNU General Public License v2.0 5 votes vote down vote up
def simxGetJointPosition(clientID, jointHandle, operationMode):
    '''
    Please have a look at the function description/documentation in the V-REP user manual
    '''
    position = ct.c_float()
    return c_GetJointPosition(clientID, jointHandle, ct.byref(position), operationMode), position.value 
Example #28
Source File: epanet2.py    From epynet with Apache License 2.0 5 votes vote down vote up
def ENsetoption(self, optioncode, value):
        """Sets the value of a particular analysis option.

        Arguments:
          optioncode: option code EN_TRIALS
                                  EN_ACCURACY  
                                  EN_TOLERANCE 
                                  EN_EMITEXPON 
                                  EN_DEMANDMULT
          value:  option value"""
        ierr= self._lib.EN_setoption(self.ph, ctypes.c_int(paramcode), ctypes.c_float(value))
        if ierr!=0: raise ENtoolkitError(self, ierr)


    #----- Saving and using hydraulic analysis results files ------- 
Example #29
Source File: epanet2.py    From epynet with Apache License 2.0 5 votes vote down vote up
def ENsetpatternvalue(self, index, period, value):
        """Sets the multiplier factor for a specific period within a time pattern.
        Arguments:
           index: time pattern index
           period: period within time pattern
           value:  multiplier factor for the period"""
        #int ENsetpatternvalue( int index, int period, float value )
        ierr= self._lib.EN_setpatternvalue(self.ph,  ctypes.c_int(index), 
                                      ctypes.c_int(period), 
                                      ctypes.c_float(value) )
        if ierr!=0: raise ENtoolkitError(self, ierr) 
Example #30
Source File: shaderprogram.py    From renpy-shader with MIT License 5 votes vote down vote up
def uniformMatrix4fArray(self, name, values):
        loc = gl.glGetUniformLocation(self.handle, name)
        count = len(values) / 16
        gl.glUniformMatrix4fv(loc, count, False, (ctypes.c_float * len(values))(*values))