ncca-ngl 0.1.2__tar.gz → 0.1.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. ncca_ngl-0.1.6/PKG-INFO +22 -0
  2. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/pyproject.toml +6 -15
  3. ncca_ngl-0.1.6/src/ncca/ngl/.ruff_cache/.gitignore +2 -0
  4. ncca_ngl-0.1.6/src/ncca/ngl/.ruff_cache/0.13.0/10564494386971134025 +0 -0
  5. ncca_ngl-0.1.6/src/ncca/ngl/.ruff_cache/0.13.0/7783445477288392980 +0 -0
  6. ncca_ngl-0.1.6/src/ncca/ngl/.ruff_cache/CACHEDIR.TAG +1 -0
  7. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/buddah.npy +0 -0
  8. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/bunny.npy +0 -0
  9. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/cube.npy +0 -0
  10. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/dodecahedron.npy +0 -0
  11. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/dragon.npy +0 -0
  12. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/football.npy +0 -0
  13. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/icosahedron.npy +0 -0
  14. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/octahedron.npy +0 -0
  15. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/teapot.npy +0 -0
  16. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/tetrahedron.npy +0 -0
  17. ncca_ngl-0.1.6/src/ncca/ngl/PrimData/troll.npy +0 -0
  18. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/__init__.py +8 -0
  19. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/abstract_vao.py +6 -2
  20. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/quaternion.py +6 -2
  21. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shader_program.py +118 -7
  22. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shaders/text_fragment.glsl +2 -2
  23. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/text.py +6 -4
  24. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/vec2.py +3 -1
  25. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/vec2_array.py +24 -6
  26. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/vec3.py +23 -9
  27. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/vec3_array.py +23 -5
  28. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/vec4.py +16 -4
  29. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/vec4_array.py +24 -6
  30. ncca_ngl-0.1.2/MANIFEST.in +0 -33
  31. ncca_ngl-0.1.2/PKG-INFO +0 -24
  32. ncca_ngl-0.1.2/README.md +0 -22
  33. ncca_ngl-0.1.2/setup.cfg +0 -4
  34. ncca_ngl-0.1.2/src/ncca_ngl.egg-info/PKG-INFO +0 -24
  35. ncca_ngl-0.1.2/src/ncca_ngl.egg-info/SOURCES.txt +0 -55
  36. ncca_ngl-0.1.2/src/ncca_ngl.egg-info/dependency_links.txt +0 -1
  37. ncca_ngl-0.1.2/src/ncca_ngl.egg-info/requires.txt +0 -7
  38. ncca_ngl-0.1.2/src/ncca_ngl.egg-info/top_level.txt +0 -1
  39. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/LICENSE.txt +0 -0
  40. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/PrimData/Primitives.npz +0 -0
  41. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/PrimData/pack_arrays.py +0 -0
  42. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/base_mesh.py +0 -0
  43. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/base_mesh.pyi +0 -0
  44. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/bbox.py +0 -0
  45. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/bezier_curve.py +0 -0
  46. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/first_person_camera.py +0 -0
  47. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/image.py +0 -0
  48. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/log.py +0 -0
  49. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/mat2.py +0 -0
  50. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/mat3.py +0 -0
  51. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/mat4.py +0 -0
  52. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/multi_buffer_vao.py +0 -0
  53. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/obj.py +0 -0
  54. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/plane.py +0 -0
  55. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/primitives.py +0 -0
  56. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/pyside_event_handling_mixin.py +0 -0
  57. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/random.py +0 -0
  58. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shader.py +0 -0
  59. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shader_lib.py +0 -0
  60. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shaders/checker_fragment.glsl +0 -0
  61. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shaders/checker_vertex.glsl +0 -0
  62. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shaders/colour_fragment.glsl +0 -0
  63. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shaders/colour_vertex.glsl +0 -0
  64. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shaders/diffuse_fragment.glsl +0 -0
  65. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shaders/diffuse_vertex.glsl +0 -0
  66. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shaders/text_geometry.glsl +0 -0
  67. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/shaders/text_vertex.glsl +0 -0
  68. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/simple_index_vao.py +0 -0
  69. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/simple_vao.py +0 -0
  70. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/texture.py +0 -0
  71. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/transform.py +0 -0
  72. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/util.py +0 -0
  73. {ncca_ngl-0.1.2 → ncca_ngl-0.1.6}/src/ncca/ngl/vao_factory.py +0 -0
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.3
2
+ Name: ncca-ngl
3
+ Version: 0.1.6
4
+ Summary: A Python version of the NGL graphics library.
5
+ Author: Jon Macey
6
+ Author-email: Jon Macey <jmacey@bournemouth.ac.uk>
7
+ License: Copyright 2024 Jon Macey
8
+
9
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
14
+ Requires-Dist: numpy>=2.3.3
15
+ Requires-Dist: pyopengl
16
+ Requires-Dist: pillow
17
+ Requires-Dist: glfw>=2.9.0
18
+ Requires-Dist: freetype-py>=2.5.1
19
+ Requires-Dist: pyside6>=6.9.2
20
+ Requires-Python: >=3.13
21
+ Project-URL: Homepage, https://github.com/NCCA/PyNGL
22
+ Project-URL: Issues, https://github.com/NCCA/PyNGL/issues
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ncca-ngl"
3
- version = "0.1.2"
3
+ version = "0.1.6"
4
4
  description = "A Python version of the NGL graphics library."
5
5
  authors = [{ name = "Jon Macey", email = "jmacey@bournemouth.ac.uk" }]
6
6
  requires-python = ">=3.13"
@@ -13,7 +13,6 @@ dependencies = [
13
13
  "glfw>=2.9.0",
14
14
  "freetype-py>=2.5.1",
15
15
  "pyside6>=6.9.2",
16
- "hatch>=1.14.2",
17
16
  ]
18
17
 
19
18
  [project.urls]
@@ -24,21 +23,13 @@ Issues = "https://github.com/NCCA/PyNGL/issues"
24
23
  [tool.pytest.ini_options]
25
24
  pythonpath = ["src","tests"]
26
25
 
27
-
28
26
  [build-system]
29
- requires = ["setuptools>=61.0"]
30
- build-backend = "setuptools.build_meta"
31
-
32
- [tool.setuptools.packages.find]
33
- where = ["src"]
34
- include = ["ncca.*"]
35
-
36
- [tool.setuptools.package-data]
37
- "ncca.ngl" = ["shaders/*", "PrimData/Primitives.npz"]
38
-
39
- [tool.setuptools]
40
- include-package-data = true
27
+ requires = ["uv_build>=0.8.13,<0.9.0"]
28
+ build-backend = "uv_build"
41
29
 
30
+ [tool.uv.build-backend]
31
+ module-name = "ncca.ngl"
32
+ module-root = "src"
42
33
 
43
34
 
44
35
  [dependency-groups]
@@ -0,0 +1,2 @@
1
+ # Automatically created by ruff.
2
+ *
@@ -0,0 +1 @@
1
+ Signature: 8a477f597d28d172789f06886806bc55
@@ -1,3 +1,11 @@
1
+ # generate auto __version__
2
+ from importlib.metadata import PackageNotFoundError, version
3
+
4
+ try:
5
+ __version__ = version("ncca-ngl")
6
+ except PackageNotFoundError:
7
+ __version__ = "0.0.0"
8
+
1
9
  from .abstract_vao import AbstractVAO, VertexData
2
10
  from .base_mesh import BaseMesh, Face
3
11
  from .bbox import BBox
@@ -52,10 +52,14 @@ class AbstractVAO(abc.ABC):
52
52
  def remove_vao(self):
53
53
  raise NotImplementedError
54
54
 
55
- def set_vertex_attribute_pointer(self, id, size, type, stride, offset, normalize=False):
55
+ def set_vertex_attribute_pointer(
56
+ self, id, size, type, stride, offset, normalize=False
57
+ ):
56
58
  if not self.bound:
57
59
  logger.error("VAO not bound in set_vertex_attribute_pointer")
58
- gl.glVertexAttribPointer(id, size, type, normalize, stride, ctypes.c_void_p(offset))
60
+ gl.glVertexAttribPointer(
61
+ id, size, type, normalize, stride, ctypes.c_void_p(offset)
62
+ )
59
63
  gl.glEnableVertexAttribArray(id)
60
64
 
61
65
  def set_num_indices(self, count):
@@ -75,7 +75,9 @@ class Quaternion:
75
75
  return Quaternion(s, x, y, z)
76
76
 
77
77
  def __add__(self, rhs):
78
- return Quaternion(self.s + rhs.s, self.x + rhs.x, self.y + rhs.y, self.z + rhs.z)
78
+ return Quaternion(
79
+ self.s + rhs.s, self.x + rhs.x, self.y + rhs.y, self.z + rhs.z
80
+ )
79
81
 
80
82
  def __iadd__(self, rhs):
81
83
  self.s += rhs.s
@@ -85,7 +87,9 @@ class Quaternion:
85
87
  return self
86
88
 
87
89
  def __sub__(self, rhs):
88
- return Quaternion(self.s - rhs.s, self.x - rhs.x, self.y - rhs.y, self.z - rhs.z)
90
+ return Quaternion(
91
+ self.s - rhs.s, self.x - rhs.x, self.y - rhs.y, self.z - rhs.z
92
+ )
89
93
 
90
94
  def __isub__(self, rhs):
91
95
  return self.__sub__(rhs)
@@ -345,11 +345,20 @@ class ShaderProgram:
345
345
  )
346
346
 
347
347
  elif len(value) == 2:
348
- gl.glUniform2f(loc, *value)
348
+ if isinstance(value[0], int):
349
+ gl.glUniform2i(loc, *value)
350
+ else:
351
+ gl.glUniform2f(loc, *value)
349
352
  elif len(value) == 3:
350
- gl.glUniform3f(loc, *value)
353
+ if isinstance(value[0], int):
354
+ gl.glUniform3i(loc, *value)
355
+ else:
356
+ gl.glUniform3f(loc, *value)
351
357
  elif len(value) == 4:
352
- gl.glUniform4f(loc, *value)
358
+ if isinstance(value[0], int):
359
+ gl.glUniform4i(loc, *value)
360
+ else:
361
+ gl.glUniform4f(loc, *value)
353
362
 
354
363
  def set_uniform_1fv(self, name: str, values: List[float]) -> None:
355
364
  """
@@ -719,19 +728,121 @@ class ShaderProgram:
719
728
  str: Human-readable type string
720
729
  """
721
730
  type_map = {
731
+ # Scalars
722
732
  gl.GL_FLOAT: "float",
723
- gl.GL_FLOAT_VEC2: "vec2",
724
- gl.GL_FLOAT_VEC3: "vec3",
725
- gl.GL_FLOAT_VEC4: "vec4",
726
733
  gl.GL_DOUBLE: "double",
727
734
  gl.GL_INT: "int",
728
- gl.GL_UNSIGNED_INT: "unsigned int",
735
+ gl.GL_UNSIGNED_INT: "uint",
729
736
  gl.GL_BOOL: "bool",
737
+ # Float vectors
738
+ gl.GL_FLOAT_VEC2: "vec2",
739
+ gl.GL_FLOAT_VEC3: "vec3",
740
+ gl.GL_FLOAT_VEC4: "vec4",
741
+ # Double vectors
742
+ gl.GL_DOUBLE_VEC2: "dvec2",
743
+ gl.GL_DOUBLE_VEC3: "dvec3",
744
+ gl.GL_DOUBLE_VEC4: "dvec4",
745
+ # Integer vectors
746
+ gl.GL_INT_VEC2: "ivec2",
747
+ gl.GL_INT_VEC3: "ivec3",
748
+ gl.GL_INT_VEC4: "ivec4",
749
+ # Unsigned int vectors
750
+ gl.GL_UNSIGNED_INT_VEC2: "uvec2",
751
+ gl.GL_UNSIGNED_INT_VEC3: "uvec3",
752
+ gl.GL_UNSIGNED_INT_VEC4: "uvec4",
753
+ # Bool vectors
754
+ gl.GL_BOOL_VEC2: "bvec2",
755
+ gl.GL_BOOL_VEC3: "bvec3",
756
+ gl.GL_BOOL_VEC4: "bvec4",
757
+ # Float matrices
730
758
  gl.GL_FLOAT_MAT2: "mat2",
731
759
  gl.GL_FLOAT_MAT3: "mat3",
732
760
  gl.GL_FLOAT_MAT4: "mat4",
761
+ gl.GL_FLOAT_MAT2x3: "mat2x3",
762
+ gl.GL_FLOAT_MAT2x4: "mat2x4",
763
+ gl.GL_FLOAT_MAT3x2: "mat3x2",
764
+ gl.GL_FLOAT_MAT3x4: "mat3x4",
765
+ gl.GL_FLOAT_MAT4x2: "mat4x2",
766
+ gl.GL_FLOAT_MAT4x3: "mat4x3",
767
+ # Double matrices
768
+ gl.GL_DOUBLE_MAT2: "dmat2",
769
+ gl.GL_DOUBLE_MAT3: "dmat3",
770
+ gl.GL_DOUBLE_MAT4: "dmat4",
771
+ gl.GL_DOUBLE_MAT2x3: "dmat2x3",
772
+ gl.GL_DOUBLE_MAT2x4: "dmat2x4",
773
+ gl.GL_DOUBLE_MAT3x2: "dmat3x2",
774
+ gl.GL_DOUBLE_MAT3x4: "dmat3x4",
775
+ gl.GL_DOUBLE_MAT4x2: "dmat4x2",
776
+ gl.GL_DOUBLE_MAT4x3: "dmat4x3",
777
+ # Samplers (float)
778
+ gl.GL_SAMPLER_1D: "sampler1D",
733
779
  gl.GL_SAMPLER_2D: "sampler2D",
780
+ gl.GL_SAMPLER_3D: "sampler3D",
734
781
  gl.GL_SAMPLER_CUBE: "samplerCube",
782
+ gl.GL_SAMPLER_1D_SHADOW: "sampler1DShadow",
783
+ gl.GL_SAMPLER_2D_SHADOW: "sampler2DShadow",
784
+ gl.GL_SAMPLER_1D_ARRAY: "sampler1DArray",
785
+ gl.GL_SAMPLER_2D_ARRAY: "sampler2DArray",
786
+ gl.GL_SAMPLER_1D_ARRAY_SHADOW: "sampler1DArrayShadow",
787
+ gl.GL_SAMPLER_2D_ARRAY_SHADOW: "sampler2DArrayShadow",
788
+ gl.GL_SAMPLER_CUBE_SHADOW: "samplerCubeShadow",
789
+ gl.GL_SAMPLER_BUFFER: "samplerBuffer",
790
+ gl.GL_SAMPLER_2D_RECT: "sampler2DRect",
791
+ gl.GL_SAMPLER_2D_RECT_SHADOW: "sampler2DRectShadow",
792
+ # Samplers (int)
793
+ gl.GL_INT_SAMPLER_1D: "isampler1D",
794
+ gl.GL_INT_SAMPLER_2D: "isampler2D",
795
+ gl.GL_INT_SAMPLER_3D: "isampler3D",
796
+ gl.GL_INT_SAMPLER_CUBE: "isamplerCube",
797
+ gl.GL_INT_SAMPLER_1D_ARRAY: "isampler1DArray",
798
+ gl.GL_INT_SAMPLER_2D_ARRAY: "isampler2DArray",
799
+ gl.GL_INT_SAMPLER_BUFFER: "isamplerBuffer",
800
+ gl.GL_INT_SAMPLER_2D_RECT: "isampler2DRect",
801
+ # Samplers (unsigned int)
802
+ gl.GL_UNSIGNED_INT_SAMPLER_1D: "usampler1D",
803
+ gl.GL_UNSIGNED_INT_SAMPLER_2D: "usampler2D",
804
+ gl.GL_UNSIGNED_INT_SAMPLER_3D: "usampler3D",
805
+ gl.GL_UNSIGNED_INT_SAMPLER_CUBE: "usamplerCube",
806
+ gl.GL_UNSIGNED_INT_SAMPLER_1D_ARRAY: "usampler1DArray",
807
+ gl.GL_UNSIGNED_INT_SAMPLER_2D_ARRAY: "usampler2DArray",
808
+ gl.GL_UNSIGNED_INT_SAMPLER_BUFFER: "usamplerBuffer",
809
+ gl.GL_UNSIGNED_INT_SAMPLER_2D_RECT: "usampler2DRect",
810
+ # Images (float)
811
+ gl.GL_IMAGE_1D: "image1D",
812
+ gl.GL_IMAGE_2D: "image2D",
813
+ gl.GL_IMAGE_3D: "image3D",
814
+ gl.GL_IMAGE_2D_RECT: "image2DRect",
815
+ gl.GL_IMAGE_CUBE: "imageCube",
816
+ gl.GL_IMAGE_BUFFER: "imageBuffer",
817
+ gl.GL_IMAGE_1D_ARRAY: "image1DArray",
818
+ gl.GL_IMAGE_2D_ARRAY: "image2DArray",
819
+ gl.GL_IMAGE_CUBE_MAP_ARRAY: "imageCubeArray",
820
+ gl.GL_IMAGE_2D_MULTISAMPLE: "image2DMS",
821
+ gl.GL_IMAGE_2D_MULTISAMPLE_ARRAY: "image2DMSArray",
822
+ # Images (int)
823
+ gl.GL_INT_IMAGE_1D: "iimage1D",
824
+ gl.GL_INT_IMAGE_2D: "iimage2D",
825
+ gl.GL_INT_IMAGE_3D: "iimage3D",
826
+ gl.GL_INT_IMAGE_2D_RECT: "iimage2DRect",
827
+ gl.GL_INT_IMAGE_CUBE: "iimageCube",
828
+ gl.GL_INT_IMAGE_BUFFER: "iimageBuffer",
829
+ gl.GL_INT_IMAGE_1D_ARRAY: "iimage1DArray",
830
+ gl.GL_INT_IMAGE_2D_ARRAY: "iimage2DArray",
831
+ gl.GL_INT_IMAGE_CUBE_MAP_ARRAY: "iimageCubeArray",
832
+ gl.GL_INT_IMAGE_2D_MULTISAMPLE: "iimage2DMS",
833
+ gl.GL_INT_IMAGE_2D_MULTISAMPLE_ARRAY: "iimage2DMSArray",
834
+ # Images (unsigned int)
835
+ gl.GL_UNSIGNED_INT_IMAGE_1D: "uimage1D",
836
+ gl.GL_UNSIGNED_INT_IMAGE_2D: "uimage2D",
837
+ gl.GL_UNSIGNED_INT_IMAGE_3D: "uimage3D",
838
+ gl.GL_UNSIGNED_INT_IMAGE_2D_RECT: "uimage2DRect",
839
+ gl.GL_UNSIGNED_INT_IMAGE_CUBE: "uimageCube",
840
+ gl.GL_UNSIGNED_INT_IMAGE_BUFFER: "uimageBuffer",
841
+ gl.GL_UNSIGNED_INT_IMAGE_1D_ARRAY: "uimage1DArray",
842
+ gl.GL_UNSIGNED_INT_IMAGE_2D_ARRAY: "uimage2DArray",
843
+ gl.GL_UNSIGNED_INT_IMAGE_CUBE_MAP_ARRAY: "uimageCubeArray",
844
+ gl.GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE: "uimage2DMS",
845
+ gl.GL_UNSIGNED_INT_IMAGE_2D_MULTISAMPLE_ARRAY: "uimage2DMSArray",
735
846
  }
736
847
  return type_map.get(gl_type, f"Unknown type {gl_type}")
737
848
 
@@ -1,10 +1,10 @@
1
1
  #version 410 core
2
2
  in vec2 v_uv;
3
3
  uniform sampler2D textureID;
4
- uniform vec4 textColor;
4
+ uniform vec4 textColour;
5
5
  out vec4 fragColor;
6
6
  void main()
7
7
  {
8
8
  float a = texture(textureID, v_uv).a;
9
- fragColor = vec4(textColor.rgb, textColor.a * a);
9
+ fragColor = vec4(textColour.rgb, textColour.a * a);
10
10
  }
@@ -223,12 +223,12 @@ class _Text:
223
223
  """
224
224
  ShaderLib.use(DefaultShader.TEXT)
225
225
  ShaderLib.set_uniform("textureID", 0)
226
- ShaderLib.set_uniform("screenSize", w, h)
226
+ ShaderLib.set_uniform("screenSize", float(w), float(h))
227
227
  ShaderLib.set_uniform("fontSize", 1.0)
228
- ShaderLib.set_uniform("textColor", 1.0, 1.0, 1.0, 1.0)
228
+ ShaderLib.set_uniform("textColour", 1.0, 1.0, 1.0, 1.0)
229
229
 
230
230
  def render_text(
231
- self, font: str, x: int, y: int, text: str, colour: Vec3 = Vec3(1, 1, 1)
231
+ self, font: str, x: int, y: int, text: str, colour: Vec3 = Vec3(1.0, 1.0, 1.0)
232
232
  ) -> None:
233
233
  """
234
234
  Renders a string of text to the screen.
@@ -276,7 +276,9 @@ class _Text:
276
276
  gl.glActiveTexture(gl.GL_TEXTURE0)
277
277
  gl.glBindTexture(gl.GL_TEXTURE_2D, atlas.texture)
278
278
  ShaderLib.use(DefaultShader.TEXT)
279
- ShaderLib.set_uniform("textColor", colour.x, colour.y, colour.z, 1.0)
279
+ ShaderLib.set_uniform(
280
+ "textColour", float(colour.x), float(colour.y), float(colour.z), 1.0
281
+ )
280
282
  # We are drawing one point per character
281
283
  vao.set_num_indices(len(render_data) // 8)
282
284
  vao.draw()
@@ -305,7 +305,9 @@ class Vec2:
305
305
  if isinstance(rhs, (float, int)):
306
306
  return Vec2(self.x * rhs, self.y * rhs)
307
307
  else:
308
- raise ValueError(f"can only do piecewise multiplication with a scalar {rhs=}")
308
+ raise ValueError(
309
+ f"can only do piecewise multiplication with a scalar {rhs=}"
310
+ )
309
311
 
310
312
  def __rmul__(self, rhs):
311
313
  """
@@ -14,17 +14,23 @@ class Vec2Array:
14
14
 
15
15
  def __init__(self, values=None):
16
16
  """
17
- Initializes the Vec2Array.
17
+ Initializes the Vec3Array.
18
18
 
19
19
  Args:
20
- values (iterable, optional): An iterable of Vec2 objects. Defaults to None.
20
+ values (iterable | int, optional): An iterable of Vec3 objects or an integer.
21
+ If an integer, the array is initialized with that many default Vec3s.
22
+ If an iterable, it's initialized with the Vec3s from the iterable.
23
+ Defaults to None (an empty array).
21
24
  """
22
25
  self._data = []
23
26
  if values is not None:
24
- for v in values:
25
- if not isinstance(v, Vec2):
26
- raise TypeError("All elements must be of type Vec2")
27
- self._data.append(v)
27
+ if isinstance(values, int):
28
+ self._data = [Vec2() for _ in range(values)]
29
+ else:
30
+ for v in values:
31
+ if not isinstance(v, Vec2):
32
+ raise TypeError("All elements must be of type Vec2")
33
+ self._data.append(v)
28
34
 
29
35
  def __getitem__(self, index):
30
36
  """
@@ -38,6 +44,18 @@ class Vec2Array:
38
44
  """
39
45
  return self._data[index]
40
46
 
47
+ def __setitem__(self, index, value):
48
+ """
49
+ Set the Vec2 at the specified index.
50
+
51
+ Args:
52
+ index (int): The index of the element to set.
53
+ value (Vec3): The new Vec3 object.
54
+ """
55
+ if not isinstance(value, Vec2):
56
+ raise TypeError("Only Vec2 objects can be assigned")
57
+ self._data[index] = value
58
+
41
59
  def __len__(self):
42
60
  """
43
61
  Return the number of elements in the array.
@@ -156,7 +156,11 @@ class Vec3:
156
156
 
157
157
  if not isinstance(rhs, Vec3):
158
158
  return NotImplemented
159
- return math.isclose(self.x, rhs.x) and math.isclose(self.y, rhs.y) and math.isclose(self.z, rhs.z)
159
+ return (
160
+ math.isclose(self.x, rhs.x)
161
+ and math.isclose(self.y, rhs.y)
162
+ and math.isclose(self.z, rhs.z)
163
+ )
160
164
 
161
165
  def __neq__(self, rhs):
162
166
  """
@@ -169,7 +173,11 @@ class Vec3:
169
173
  """
170
174
  if not isinstance(rhs, Vec3):
171
175
  return NotImplemented
172
- return not (math.isclose(self.x, rhs.x) and math.isclose(self.y, rhs.y) and math.isclose(self.z, rhs.z))
176
+ return not (
177
+ math.isclose(self.x, rhs.x)
178
+ and math.isclose(self.y, rhs.y)
179
+ and math.isclose(self.z, rhs.z)
180
+ )
173
181
 
174
182
  def __neg__(self):
175
183
  """
@@ -282,7 +290,9 @@ class Vec3:
282
290
  """
283
291
  d = self.dot(n)
284
292
  # I - 2.0 * dot(N, I) * N
285
- return Vec3(self.x - 2.0 * d * n.x, self.y - 2.0 * d * n.y, self.z - 2.0 * d * n.z)
293
+ return Vec3(
294
+ self.x - 2.0 * d * n.x, self.y - 2.0 * d * n.y, self.z - 2.0 * d * n.z
295
+ )
286
296
 
287
297
  def clamp(self, low, high):
288
298
  """
@@ -314,11 +324,13 @@ class Vec3:
314
324
  """
315
325
  from .mat3 import Mat3
316
326
 
317
- return Mat3.from_list([
318
- [self.x * rhs.x, self.x * rhs.y, self.x * rhs.z],
319
- [self.y * rhs.x, self.y * rhs.y, self.y * rhs.z],
320
- [self.z * rhs.x, self.z * rhs.y, self.z * rhs.z],
321
- ])
327
+ return Mat3.from_list(
328
+ [
329
+ [self.x * rhs.x, self.x * rhs.y, self.x * rhs.z],
330
+ [self.y * rhs.x, self.y * rhs.y, self.y * rhs.z],
331
+ [self.z * rhs.x, self.z * rhs.y, self.z * rhs.z],
332
+ ]
333
+ )
322
334
 
323
335
  def __mul__(self, rhs):
324
336
  """
@@ -333,7 +345,9 @@ class Vec3:
333
345
  if isinstance(rhs, (float, int)):
334
346
  return Vec3(self.x * rhs, self.y * rhs, self.z * rhs)
335
347
  else:
336
- raise ValueError(f"can only do piecewise multiplication with a scalar {rhs=}")
348
+ raise ValueError(
349
+ f"can only do piecewise multiplication with a scalar {rhs=}"
350
+ )
337
351
 
338
352
  def __rmul__(self, rhs):
339
353
  """
@@ -17,14 +17,20 @@ class Vec3Array:
17
17
  Initializes the Vec3Array.
18
18
 
19
19
  Args:
20
- values (iterable, optional): An iterable of Vec3 objects. Defaults to None.
20
+ values (iterable | int, optional): An iterable of Vec3 objects or an integer.
21
+ If an integer, the array is initialized with that many default Vec3s.
22
+ If an iterable, it's initialized with the Vec3s from the iterable.
23
+ Defaults to None (an empty array).
21
24
  """
22
25
  self._data = []
23
26
  if values is not None:
24
- for v in values:
25
- if not isinstance(v, Vec3):
26
- raise TypeError("All elements must be of type Vec3")
27
- self._data.append(v)
27
+ if isinstance(values, int):
28
+ self._data = [Vec3() for _ in range(values)]
29
+ else:
30
+ for v in values:
31
+ if not isinstance(v, Vec3):
32
+ raise TypeError("All elements must be of type Vec3")
33
+ self._data.append(v)
28
34
 
29
35
  def __getitem__(self, index):
30
36
  """
@@ -38,6 +44,18 @@ class Vec3Array:
38
44
  """
39
45
  return self._data[index]
40
46
 
47
+ def __setitem__(self, index, value):
48
+ """
49
+ Set the Vec3 at the specified index.
50
+
51
+ Args:
52
+ index (int): The index of the element to set.
53
+ value (Vec3): The new Vec3 object.
54
+ """
55
+ if not isinstance(value, Vec3):
56
+ raise TypeError("Only Vec3 objects can be assigned")
57
+ self._data[index] = value
58
+
41
59
  def __len__(self):
42
60
  """
43
61
  Return the number of elements in the array.
@@ -192,10 +192,22 @@ class Vec4:
192
192
  def __matmul__(self, rhs):
193
193
  "Vec4 @ Mat4 matrix multiplication"
194
194
  return Vec4(
195
- self.x * rhs.m[0][0] + self.y * rhs.m[1][0] + self.z * rhs.m[2][0] + self.w * rhs.m[3][0],
196
- self.x * rhs.m[0][1] + self.y * rhs.m[1][1] + self.z * rhs.m[2][1] + self.w * rhs.m[3][1],
197
- self.x * rhs.m[0][2] + self.y * rhs.m[1][2] + self.z * rhs.m[2][2] + self.w * rhs.m[3][2],
198
- self.x * rhs.m[0][3] + self.y * rhs.m[1][3] + self.z * rhs.m[2][3] + self.w * rhs.m[3][3],
195
+ self.x * rhs.m[0][0]
196
+ + self.y * rhs.m[1][0]
197
+ + self.z * rhs.m[2][0]
198
+ + self.w * rhs.m[3][0],
199
+ self.x * rhs.m[0][1]
200
+ + self.y * rhs.m[1][1]
201
+ + self.z * rhs.m[2][1]
202
+ + self.w * rhs.m[3][1],
203
+ self.x * rhs.m[0][2]
204
+ + self.y * rhs.m[1][2]
205
+ + self.z * rhs.m[2][2]
206
+ + self.w * rhs.m[3][2],
207
+ self.x * rhs.m[0][3]
208
+ + self.y * rhs.m[1][3]
209
+ + self.z * rhs.m[2][3]
210
+ + self.w * rhs.m[3][3],
199
211
  )
200
212
 
201
213
  def __repr__(self):
@@ -14,17 +14,23 @@ class Vec4Array:
14
14
 
15
15
  def __init__(self, values=None):
16
16
  """
17
- Initializes the Vec4Array.
17
+ Initializes the Vec3Array.
18
18
 
19
19
  Args:
20
- values (iterable, optional): An iterable of Vec4 objects. Defaults to None.
20
+ values (iterable | int, optional): An iterable of Vec4 objects or an integer.
21
+ If an integer, the array is initialized with that many default Vec3s.
22
+ If an iterable, it's initialized with the Vec3s from the iterable.
23
+ Defaults to None (an empty array).
21
24
  """
22
25
  self._data = []
23
26
  if values is not None:
24
- for v in values:
25
- if not isinstance(v, Vec4):
26
- raise TypeError("All elements must be of type Vec4")
27
- self._data.append(v)
27
+ if isinstance(values, int):
28
+ self._data = [Vec4() for _ in range(values)]
29
+ else:
30
+ for v in values:
31
+ if not isinstance(v, Vec4):
32
+ raise TypeError("All elements must be of type Vec4")
33
+ self._data.append(v)
28
34
 
29
35
  def __getitem__(self, index):
30
36
  """
@@ -38,6 +44,18 @@ class Vec4Array:
38
44
  """
39
45
  return self._data[index]
40
46
 
47
+ def __setitem__(self, index, value):
48
+ """
49
+ Set the Vec3 at the specified index.
50
+
51
+ Args:
52
+ index (int): The index of the element to set.
53
+ value (Vec4): The new Vec3 object.
54
+ """
55
+ if not isinstance(value, Vec4):
56
+ raise TypeError("Only Vec4 objects can be assigned")
57
+ self._data[index] = value
58
+
41
59
  def __len__(self):
42
60
  """
43
61
  Return the number of elements in the array.
@@ -1,33 +0,0 @@
1
- # Include package data
2
- include src/ncca/ngl/shaders/*
3
- include src/ncca/ngl/PrimData/Primitives.npz
4
-
5
- # Include license and readme
6
- include LICENSE.txt
7
- include README.md
8
-
9
- # Exclude tests and test-related files
10
- exclude tests/*
11
- global-exclude tests/*
12
- global-exclude *test*
13
- global-exclude __pycache__/*
14
- global-exclude *.pyc
15
- global-exclude *.pyo
16
-
17
- # Exclude development and build files
18
- exclude .gitignore
19
- exclude .pre-commit-config.yaml
20
- exclude pyproject.toml.bak
21
- exclude *.log
22
- exclude TODO.md
23
- exclude sonar-project.properties
24
- exclude uv.lock
25
-
26
- # Exclude directories
27
- prune tests
28
- prune .pytest_cache
29
- prune .ruff_cache
30
- prune .venv
31
- prune dist
32
- prune tmp
33
- prune .github
ncca_ngl-0.1.2/PKG-INFO DELETED
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: ncca-ngl
3
- Version: 0.1.2
4
- Summary: A Python version of the NGL graphics library.
5
- Author-email: Jon Macey <jmacey@bournemouth.ac.uk>
6
- License: Copyright 2024 Jon Macey
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
-
12
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
- Project-URL: Homepage, https://github.com/NCCA/PyNGL
14
- Project-URL: Issues, https://github.com/NCCA/PyNGL/issues
15
- Requires-Python: >=3.13
16
- License-File: LICENSE.txt
17
- Requires-Dist: numpy>=2.3.3
18
- Requires-Dist: PyOpenGL
19
- Requires-Dist: Pillow
20
- Requires-Dist: glfw>=2.9.0
21
- Requires-Dist: freetype-py>=2.5.1
22
- Requires-Dist: pyside6>=6.9.2
23
- Requires-Dist: hatch>=1.14.2
24
- Dynamic: license-file
ncca_ngl-0.1.2/README.md DELETED
@@ -1,22 +0,0 @@
1
- # PyNGL
2
-
3
- This is the code for the full python version of [NGL](https://github.com/NCCA/NGL) the ncca graphics library.
4
-
5
- More details soon as this is work in progress.
6
-
7
-
8
- ## Test
9
-
10
- use
11
-
12
- ```
13
- uv run pytest
14
- ```
15
-
16
- To run tests,
17
-
18
- ```
19
- uv run pytest --cov=src --cov-report=term-missing
20
- ```
21
-
22
- For coverage reports.
ncca_ngl-0.1.2/setup.cfg DELETED
@@ -1,4 +0,0 @@
1
- [egg_info]
2
- tag_build =
3
- tag_date = 0
4
-
@@ -1,24 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: ncca-ngl
3
- Version: 0.1.2
4
- Summary: A Python version of the NGL graphics library.
5
- Author-email: Jon Macey <jmacey@bournemouth.ac.uk>
6
- License: Copyright 2024 Jon Macey
7
-
8
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
9
-
10
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
11
-
12
- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
- Project-URL: Homepage, https://github.com/NCCA/PyNGL
14
- Project-URL: Issues, https://github.com/NCCA/PyNGL/issues
15
- Requires-Python: >=3.13
16
- License-File: LICENSE.txt
17
- Requires-Dist: numpy>=2.3.3
18
- Requires-Dist: PyOpenGL
19
- Requires-Dist: Pillow
20
- Requires-Dist: glfw>=2.9.0
21
- Requires-Dist: freetype-py>=2.5.1
22
- Requires-Dist: pyside6>=6.9.2
23
- Requires-Dist: hatch>=1.14.2
24
- Dynamic: license-file
@@ -1,55 +0,0 @@
1
- LICENSE.txt
2
- MANIFEST.in
3
- README.md
4
- pyproject.toml
5
- src/ncca/ngl/__init__.py
6
- src/ncca/ngl/abstract_vao.py
7
- src/ncca/ngl/base_mesh.py
8
- src/ncca/ngl/base_mesh.pyi
9
- src/ncca/ngl/bbox.py
10
- src/ncca/ngl/bezier_curve.py
11
- src/ncca/ngl/first_person_camera.py
12
- src/ncca/ngl/image.py
13
- src/ncca/ngl/log.py
14
- src/ncca/ngl/mat2.py
15
- src/ncca/ngl/mat3.py
16
- src/ncca/ngl/mat4.py
17
- src/ncca/ngl/multi_buffer_vao.py
18
- src/ncca/ngl/obj.py
19
- src/ncca/ngl/plane.py
20
- src/ncca/ngl/primitives.py
21
- src/ncca/ngl/pyside_event_handling_mixin.py
22
- src/ncca/ngl/quaternion.py
23
- src/ncca/ngl/random.py
24
- src/ncca/ngl/shader.py
25
- src/ncca/ngl/shader_lib.py
26
- src/ncca/ngl/shader_program.py
27
- src/ncca/ngl/simple_index_vao.py
28
- src/ncca/ngl/simple_vao.py
29
- src/ncca/ngl/text.py
30
- src/ncca/ngl/texture.py
31
- src/ncca/ngl/transform.py
32
- src/ncca/ngl/util.py
33
- src/ncca/ngl/vao_factory.py
34
- src/ncca/ngl/vec2.py
35
- src/ncca/ngl/vec2_array.py
36
- src/ncca/ngl/vec3.py
37
- src/ncca/ngl/vec3_array.py
38
- src/ncca/ngl/vec4.py
39
- src/ncca/ngl/vec4_array.py
40
- src/ncca/ngl/PrimData/Primitives.npz
41
- src/ncca/ngl/PrimData/pack_arrays.py
42
- src/ncca/ngl/shaders/checker_fragment.glsl
43
- src/ncca/ngl/shaders/checker_vertex.glsl
44
- src/ncca/ngl/shaders/colour_fragment.glsl
45
- src/ncca/ngl/shaders/colour_vertex.glsl
46
- src/ncca/ngl/shaders/diffuse_fragment.glsl
47
- src/ncca/ngl/shaders/diffuse_vertex.glsl
48
- src/ncca/ngl/shaders/text_fragment.glsl
49
- src/ncca/ngl/shaders/text_geometry.glsl
50
- src/ncca/ngl/shaders/text_vertex.glsl
51
- src/ncca_ngl.egg-info/PKG-INFO
52
- src/ncca_ngl.egg-info/SOURCES.txt
53
- src/ncca_ngl.egg-info/dependency_links.txt
54
- src/ncca_ngl.egg-info/requires.txt
55
- src/ncca_ngl.egg-info/top_level.txt
@@ -1,7 +0,0 @@
1
- numpy>=2.3.3
2
- PyOpenGL
3
- Pillow
4
- glfw>=2.9.0
5
- freetype-py>=2.5.1
6
- pyside6>=6.9.2
7
- hatch>=1.14.2
@@ -1 +0,0 @@
1
- ncca
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes