diff --git a/cFunctions.c b/cFunctions.c new file mode 100644 index 0000000..81822b0 --- /dev/null +++ b/cFunctions.c @@ -0,0 +1,8 @@ +#define PY_SSIZE_T_CLEAN +#include + +int square(int i) { + return i*i; +} + +class diff --git a/main.py b/main.py index 93593fe..99aaeaf 100644 --- a/main.py +++ b/main.py @@ -7,6 +7,8 @@ import pygame from functions import * import multiprocessing as mp +from ctypes import * +cFunctions = CDLL("cFunctions.so") # variables # screen size in pixels @@ -182,34 +184,6 @@ for face in newCube.get_faces(): allFaces.append(face) - # attempt at multiprocessing (failed) - # def apply_cam_matrix(values): #allFaces, start, step): - # new_faces = [] - # all_faces = values[0] - # start = values[1] - # step = values[2] - # # todo fix this - # for face_i in range(start, len(all_faces), step): - # new_face = all_faces[face_i] - # new_points = [] - # for point_i in range(len(all_faces[face_i].points)): - # # apply the camera matrix to the points - # new_points.append(all_faces[face_i].points[point_i].apply_matrix(camMatrix)) - # # fix points behind the camera - # new_face.points = new_points - # new_face.fix_points_behind_camera() - # if len(new_face.points) > 2: - # new_faces.append(new_face) - # return new_faces - # - # # ______draw all faces______ - # # apply camMatrix to allFaces - # with mp.Pool(8) as p: - # newFacesList = p.map(apply_cam_matrix, [(allFaces, x, 8) for x in range(8)]) - # allFaces = [] - # for faces in newFacesList: - # allFaces = allFaces + faces - for face in allFaces: for i, point in enumerate(face.points): # apply the camera matrix to the points