ncca-ngl 0.1.0__tar.gz → 0.1.2__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 (84) hide show
  1. ncca_ngl-0.1.2/MANIFEST.in +33 -0
  2. {ncca_ngl-0.1.0/src/ncca_ngl.egg-info → ncca_ngl-0.1.2}/PKG-INFO +2 -1
  3. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/pyproject.toml +14 -9
  4. ncca_ngl-0.1.2/src/ncca/ngl/PrimData/Primitives.npz +0 -0
  5. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/abstract_vao.py +2 -6
  6. ncca_ngl-0.1.2/src/ncca/ngl/shaders/checker_fragment.glsl +35 -0
  7. ncca_ngl-0.1.2/src/ncca/ngl/shaders/checker_vertex.glsl +19 -0
  8. ncca_ngl-0.1.2/src/ncca/ngl/shaders/colour_fragment.glsl +8 -0
  9. ncca_ngl-0.1.2/src/ncca/ngl/shaders/colour_vertex.glsl +11 -0
  10. ncca_ngl-0.1.2/src/ncca/ngl/shaders/diffuse_fragment.glsl +21 -0
  11. ncca_ngl-0.1.2/src/ncca/ngl/shaders/diffuse_vertex.glsl +24 -0
  12. ncca_ngl-0.1.2/src/ncca/ngl/shaders/text_fragment.glsl +10 -0
  13. ncca_ngl-0.1.2/src/ncca/ngl/shaders/text_geometry.glsl +53 -0
  14. ncca_ngl-0.1.2/src/ncca/ngl/shaders/text_vertex.glsl +18 -0
  15. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2/src/ncca_ngl.egg-info}/PKG-INFO +2 -1
  16. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca_ngl.egg-info/SOURCES.txt +12 -28
  17. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca_ngl.egg-info/requires.txt +1 -0
  18. ncca_ngl-0.1.0/tests/test_base_mesh.py +0 -249
  19. ncca_ngl-0.1.0/tests/test_bbox.py +0 -153
  20. ncca_ngl-0.1.0/tests/test_bezier_curve.py +0 -78
  21. ncca_ngl-0.1.0/tests/test_first_person_camera.py +0 -98
  22. ncca_ngl-0.1.0/tests/test_image.py +0 -66
  23. ncca_ngl-0.1.0/tests/test_logging.py +0 -9
  24. ncca_ngl-0.1.0/tests/test_mat2.py +0 -70
  25. ncca_ngl-0.1.0/tests/test_mat3.py +0 -241
  26. ncca_ngl-0.1.0/tests/test_mat4.py +0 -287
  27. ncca_ngl-0.1.0/tests/test_obj.py +0 -313
  28. ncca_ngl-0.1.0/tests/test_plane.py +0 -74
  29. ncca_ngl-0.1.0/tests/test_primitives.py +0 -121
  30. ncca_ngl-0.1.0/tests/test_pyside_event_handling_mixin.py +0 -644
  31. ncca_ngl-0.1.0/tests/test_quaternion.py +0 -133
  32. ncca_ngl-0.1.0/tests/test_random.py +0 -130
  33. ncca_ngl-0.1.0/tests/test_shaderlib.py +0 -1207
  34. ncca_ngl-0.1.0/tests/test_text.py +0 -15
  35. ncca_ngl-0.1.0/tests/test_texture.py +0 -75
  36. ncca_ngl-0.1.0/tests/test_transform.py +0 -160
  37. ncca_ngl-0.1.0/tests/test_util.py +0 -103
  38. ncca_ngl-0.1.0/tests/test_vao.py +0 -150
  39. ncca_ngl-0.1.0/tests/test_vec2.py +0 -216
  40. ncca_ngl-0.1.0/tests/test_vec2_array.py +0 -112
  41. ncca_ngl-0.1.0/tests/test_vec3.py +0 -324
  42. ncca_ngl-0.1.0/tests/test_vec3_array.py +0 -112
  43. ncca_ngl-0.1.0/tests/test_vec4.py +0 -281
  44. ncca_ngl-0.1.0/tests/test_vec4_array.py +0 -112
  45. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/LICENSE.txt +0 -0
  46. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/README.md +0 -0
  47. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/setup.cfg +0 -0
  48. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/PrimData/pack_arrays.py +0 -0
  49. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/__init__.py +0 -0
  50. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/base_mesh.py +0 -0
  51. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/base_mesh.pyi +0 -0
  52. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/bbox.py +0 -0
  53. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/bezier_curve.py +0 -0
  54. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/first_person_camera.py +0 -0
  55. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/image.py +0 -0
  56. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/log.py +0 -0
  57. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/mat2.py +0 -0
  58. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/mat3.py +0 -0
  59. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/mat4.py +0 -0
  60. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/multi_buffer_vao.py +0 -0
  61. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/obj.py +0 -0
  62. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/plane.py +0 -0
  63. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/primitives.py +0 -0
  64. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/pyside_event_handling_mixin.py +0 -0
  65. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/quaternion.py +0 -0
  66. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/random.py +0 -0
  67. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/shader.py +0 -0
  68. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/shader_lib.py +0 -0
  69. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/shader_program.py +0 -0
  70. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/simple_index_vao.py +0 -0
  71. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/simple_vao.py +0 -0
  72. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/text.py +0 -0
  73. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/texture.py +0 -0
  74. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/transform.py +0 -0
  75. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/util.py +0 -0
  76. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/vao_factory.py +0 -0
  77. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/vec2.py +0 -0
  78. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/vec2_array.py +0 -0
  79. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/vec3.py +0 -0
  80. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/vec3_array.py +0 -0
  81. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/vec4.py +0 -0
  82. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca/ngl/vec4_array.py +0 -0
  83. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca_ngl.egg-info/dependency_links.txt +0 -0
  84. {ncca_ngl-0.1.0 → ncca_ngl-0.1.2}/src/ncca_ngl.egg-info/top_level.txt +0 -0
@@ -0,0 +1,33 @@
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ncca-ngl
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: A Python version of the NGL graphics library.
5
5
  Author-email: Jon Macey <jmacey@bournemouth.ac.uk>
6
6
  License: Copyright 2024 Jon Macey
@@ -20,4 +20,5 @@ Requires-Dist: Pillow
20
20
  Requires-Dist: glfw>=2.9.0
21
21
  Requires-Dist: freetype-py>=2.5.1
22
22
  Requires-Dist: pyside6>=6.9.2
23
+ Requires-Dist: hatch>=1.14.2
23
24
  Dynamic: license-file
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "ncca-ngl"
3
- version = "0.1.0"
3
+ version = "0.1.2"
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,29 +13,34 @@ 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",
16
17
  ]
17
18
 
18
19
  [project.urls]
19
20
  Homepage = "https://github.com/NCCA/PyNGL"
20
21
  Issues = "https://github.com/NCCA/PyNGL/issues"
21
22
 
22
- [tool.setuptools.packages.find]
23
- where = ["src"]
24
- include = ["ncca.*"]
25
23
 
26
24
  [tool.pytest.ini_options]
27
25
  pythonpath = ["src","tests"]
28
26
 
29
- # [build-system]
30
- # requires = ["uv_build>=0.8.14,<0.9.0"]
31
- # build-backend = "uv_build"
32
- # module-name = ["ncca.ngl"]
33
- # module-root = "src/ncca/"
34
27
 
35
28
  [build-system]
36
29
  requires = ["setuptools>=61.0"]
37
30
  build-backend = "setuptools.build_meta"
38
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
41
+
42
+
43
+
39
44
  [dependency-groups]
40
45
  dev = [
41
46
  "coverage>=7.10.6",
@@ -52,14 +52,10 @@ class AbstractVAO(abc.ABC):
52
52
  def remove_vao(self):
53
53
  raise NotImplementedError
54
54
 
55
- def set_vertex_attribute_pointer(
56
- self, id, size, type, stride, offset, normalize=False
57
- ):
55
+ def set_vertex_attribute_pointer(self, id, size, type, stride, offset, normalize=False):
58
56
  if not self.bound:
59
57
  logger.error("VAO not bound in set_vertex_attribute_pointer")
60
- gl.glVertexAttribPointer(
61
- id, size, type, normalize, stride, ctypes.c_void_p(offset)
62
- )
58
+ gl.glVertexAttribPointer(id, size, type, normalize, stride, ctypes.c_void_p(offset))
63
59
  gl.glEnableVertexAttribArray(id)
64
60
 
65
61
  def set_num_indices(self, count):
@@ -0,0 +1,35 @@
1
+ #version 410 core
2
+ in vec3 fragmentNormal;
3
+ in vec2 uv;
4
+
5
+ layout (location =0) out vec4 fragColour;
6
+ uniform vec4 colour1;
7
+ uniform vec4 colour2;
8
+
9
+ uniform vec3 lightPos;
10
+ uniform vec4 lightDiffuse;
11
+ uniform float checkSize=10.0;
12
+ uniform bool checkOn;
13
+
14
+ vec4 checker( vec2 uv )
15
+ {
16
+ if(checkOn == false)
17
+ return colour1;
18
+ else
19
+ {
20
+ float v = floor( checkSize * uv.x ) +floor( checkSize * uv.y );
21
+ if( mod( v, 2.0 ) < 1.0 )
22
+ return colour2;
23
+ else
24
+ return colour1;
25
+
26
+ }
27
+ }
28
+
29
+ void main ()
30
+ {
31
+ fragColour= vec4(0.);
32
+ vec3 N = normalize(fragmentNormal);
33
+ vec3 L = normalize(lightPos);
34
+ fragColour += checker(uv)*lightDiffuse *dot(L, N);
35
+ }
@@ -0,0 +1,19 @@
1
+ #version 410 core
2
+
3
+
4
+ /// @brief the vertex passed in
5
+ layout (location = 0) in vec3 inVert;
6
+ /// @brief the normal passed in
7
+ layout (location = 1) in vec3 inNormal;
8
+ /// @brief the in uv
9
+ layout (location = 2) in vec2 inUV;
10
+ out vec3 fragmentNormal;
11
+ out vec2 uv;
12
+ uniform mat4 MVP;
13
+ uniform mat3 normalMatrix;
14
+ void main()
15
+ {
16
+ fragmentNormal = (normalMatrix*inNormal);
17
+ uv=inUV;
18
+ gl_Position = MVP*vec4(inVert,1.0);
19
+ }
@@ -0,0 +1,8 @@
1
+ #version 410 core
2
+ uniform vec4 Colour;
3
+ layout(location=0) out vec4 outColour;
4
+
5
+ void main ()
6
+ {
7
+ outColour = Colour;
8
+ }
@@ -0,0 +1,11 @@
1
+ #version 410 core
2
+
3
+ uniform mat4 MVP;
4
+
5
+ layout(location=0) in vec3 inVert;
6
+ uniform vec4 Colour;
7
+
8
+ void main(void)
9
+ {
10
+ gl_Position = MVP*vec4(inVert, 1.0);
11
+ }
@@ -0,0 +1,21 @@
1
+ #version 410
2
+ in vec3 fragmentNormal;
3
+ in vec3 fragmentPosition; // Receive fragment position
4
+
5
+ layout (location =0) out vec4 fragColour;
6
+
7
+ uniform vec4 Colour;
8
+ uniform vec3 lightPos; // Light's position in view space
9
+ uniform vec4 lightDiffuse;
10
+
11
+ void main ()
12
+ {
13
+ // Ensure fragment normal is unit length
14
+ vec3 N = normalize(fragmentNormal);
15
+ // Calculate vector from fragment to light
16
+ vec3 L = normalize(lightPos - fragmentPosition);
17
+ // Calculate diffuse factor, ensuring it's not negative
18
+ float diffuse = max(dot(L, N), 0.0);
19
+ // Final colour
20
+ fragColour = Colour * lightDiffuse * diffuse;
21
+ }
@@ -0,0 +1,24 @@
1
+ #version 410
2
+ out vec3 fragmentNormal;
3
+ out vec3 fragmentPosition;
4
+
5
+ layout(location=0) in vec3 inVert;
6
+ layout(location=1) in vec3 inNormal;
7
+
8
+ uniform mat4 MVP;
9
+ uniform mat4 MV;
10
+ uniform mat3 normalMatrix;
11
+
12
+ void main()
13
+ {
14
+ // Transform normal into view space but DO NOT normalize it here.
15
+ // The interpolation and per-fragment normalization is key to smooth shading.
16
+ fragmentNormal = normalMatrix * inNormal;
17
+
18
+ // Transform vertex position into view space
19
+ vec4 viewPosition = MV * vec4(inVert, 1.0);
20
+ fragmentPosition = viewPosition.xyz;
21
+
22
+ // Transform vertex to clip space
23
+ gl_Position = MVP * vec4(inVert, 1.0);
24
+ }
@@ -0,0 +1,10 @@
1
+ #version 410 core
2
+ in vec2 v_uv;
3
+ uniform sampler2D textureID;
4
+ uniform vec4 textColor;
5
+ out vec4 fragColor;
6
+ void main()
7
+ {
8
+ float a = texture(textureID, v_uv).a;
9
+ fragColor = vec4(textColor.rgb, textColor.a * a);
10
+ }
@@ -0,0 +1,53 @@
1
+ #version 410 core
2
+ layout(points) in;
3
+ layout(triangle_strip, max_vertices=4) out;
4
+
5
+ uniform vec2 screenSize;
6
+ uniform float fontSize;
7
+
8
+ in VS_OUT
9
+ {
10
+ vec2 pos;
11
+ vec4 uvRect;
12
+ vec2 size;
13
+ }
14
+ gs_in[];
15
+
16
+ out vec2 v_uv;
17
+
18
+ vec2 toNDC(vec2 screenPos)
19
+ {
20
+ return vec2(
21
+ (screenPos.x / screenSize.x) * 2.0 - 1.0,
22
+ 1.0 - (screenPos.y /screenSize.y) * 2.0
23
+ );
24
+ }
25
+
26
+ void main()
27
+ {
28
+ vec2 base = gs_in[0].pos;
29
+ vec2 gsize = gs_in[0].size * fontSize;
30
+ vec4 uv = gs_in[0].uvRect;
31
+ // generate a quad
32
+ // Top Left
33
+ gl_Position = vec4(toNDC(base), 0.0, 1.0);
34
+ v_uv = uv.xy;
35
+ EmitVertex();
36
+
37
+ // Bottom Left
38
+ gl_Position = vec4(toNDC(base + vec2(0.0, gsize.y)), 0.0, 1.0);
39
+ v_uv = vec2(uv.x, uv.w);
40
+ EmitVertex();
41
+
42
+ // Top Right
43
+ gl_Position = vec4(toNDC(base + vec2(gsize.x, 0.0)), 0.0, 1.0);
44
+ v_uv = vec2(uv.z, uv.y);
45
+ EmitVertex();
46
+
47
+ // Bottom Right
48
+ gl_Position = vec4(toNDC(base + gsize), 0.0, 1.0);
49
+ v_uv = uv.zw;
50
+ EmitVertex();
51
+
52
+ EndPrimitive();
53
+ }
@@ -0,0 +1,18 @@
1
+ #version 410 core
2
+ layout(location=0) in vec2 position;
3
+ layout(location=1) in vec4 uvRect;
4
+ layout(location=2) in vec2 size;
5
+
6
+ out VS_OUT
7
+ {
8
+ vec2 pos;
9
+ vec4 uvRect;
10
+ vec2 size;
11
+ } vs_out;
12
+
13
+ void main()
14
+ {
15
+ vs_out.pos = position;
16
+ vs_out.uvRect = uvRect;
17
+ vs_out.size = size;
18
+ }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ncca-ngl
3
- Version: 0.1.0
3
+ Version: 0.1.2
4
4
  Summary: A Python version of the NGL graphics library.
5
5
  Author-email: Jon Macey <jmacey@bournemouth.ac.uk>
6
6
  License: Copyright 2024 Jon Macey
@@ -20,4 +20,5 @@ Requires-Dist: Pillow
20
20
  Requires-Dist: glfw>=2.9.0
21
21
  Requires-Dist: freetype-py>=2.5.1
22
22
  Requires-Dist: pyside6>=6.9.2
23
+ Requires-Dist: hatch>=1.14.2
23
24
  Dynamic: license-file
@@ -1,4 +1,5 @@
1
1
  LICENSE.txt
2
+ MANIFEST.in
2
3
  README.md
3
4
  pyproject.toml
4
5
  src/ncca/ngl/__init__.py
@@ -36,36 +37,19 @@ src/ncca/ngl/vec3.py
36
37
  src/ncca/ngl/vec3_array.py
37
38
  src/ncca/ngl/vec4.py
38
39
  src/ncca/ngl/vec4_array.py
40
+ src/ncca/ngl/PrimData/Primitives.npz
39
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
40
51
  src/ncca_ngl.egg-info/PKG-INFO
41
52
  src/ncca_ngl.egg-info/SOURCES.txt
42
53
  src/ncca_ngl.egg-info/dependency_links.txt
43
54
  src/ncca_ngl.egg-info/requires.txt
44
- src/ncca_ngl.egg-info/top_level.txt
45
- tests/test_base_mesh.py
46
- tests/test_bbox.py
47
- tests/test_bezier_curve.py
48
- tests/test_first_person_camera.py
49
- tests/test_image.py
50
- tests/test_logging.py
51
- tests/test_mat2.py
52
- tests/test_mat3.py
53
- tests/test_mat4.py
54
- tests/test_obj.py
55
- tests/test_plane.py
56
- tests/test_primitives.py
57
- tests/test_pyside_event_handling_mixin.py
58
- tests/test_quaternion.py
59
- tests/test_random.py
60
- tests/test_shaderlib.py
61
- tests/test_text.py
62
- tests/test_texture.py
63
- tests/test_transform.py
64
- tests/test_util.py
65
- tests/test_vao.py
66
- tests/test_vec2.py
67
- tests/test_vec2_array.py
68
- tests/test_vec3.py
69
- tests/test_vec3_array.py
70
- tests/test_vec4.py
71
- tests/test_vec4_array.py
55
+ src/ncca_ngl.egg-info/top_level.txt
@@ -4,3 +4,4 @@ Pillow
4
4
  glfw>=2.9.0
5
5
  freetype-py>=2.5.1
6
6
  pyside6>=6.9.2
7
+ hatch>=1.14.2
@@ -1,249 +0,0 @@
1
- import OpenGL.GL as gl
2
- import pytest
3
-
4
- from ncca.ngl import BaseMesh, Face, Image, ImageModes, ShaderLib, Texture, Vec2, Vec3
5
-
6
-
7
- def test_is_triangular():
8
- mesh = BaseMesh()
9
- face1 = Face()
10
- face1.vertex = [1, 2, 3]
11
- face2 = Face()
12
- face2.vertex = [4, 5, 6]
13
- mesh.faces = [face1, face2]
14
- assert mesh.is_triangular() is True
15
-
16
-
17
- def test_is_not_triangular():
18
- mesh = BaseMesh()
19
- face1 = Face()
20
- face1.vertex = [1, 2, 3]
21
- face2 = Face()
22
- face2.vertex = [4, 5, 6, 7]
23
- mesh.faces = [face1, face2]
24
- assert mesh.is_triangular() is False
25
-
26
-
27
- def test_calc_dimensions():
28
- mesh = BaseMesh()
29
- mesh.vertex = [
30
- Vec3(-1.0, -2.0, -3.0),
31
- Vec3(1.0, 2.0, 3.0),
32
- Vec3(0.0, 0.0, 0.0),
33
- ]
34
- mesh.calc_dimensions()
35
- assert mesh.min_x == pytest.approx(-1.0)
36
- assert mesh.max_x == pytest.approx(1.0)
37
- assert mesh.min_y == pytest.approx(-2.0)
38
- assert mesh.max_y == pytest.approx(2.0)
39
- assert mesh.min_z == pytest.approx(-3.0)
40
- assert mesh.max_z == pytest.approx(3.0)
41
-
42
-
43
- def test_empty_mesh_dimensions():
44
- mesh = BaseMesh()
45
- mesh.calc_dimensions()
46
- assert mesh.min_x == pytest.approx(0.0)
47
- assert mesh.max_x == pytest.approx(0.0)
48
- assert mesh.min_y == pytest.approx(0.0)
49
- assert mesh.max_y == pytest.approx(0.0)
50
- assert mesh.min_z == pytest.approx(0.0)
51
- assert mesh.max_z == pytest.approx(0.0)
52
-
53
-
54
- def test_init_defaults():
55
- mesh = BaseMesh()
56
- assert mesh.vertex == []
57
- assert mesh.normals == []
58
- assert mesh.uv == []
59
- assert mesh.faces == []
60
- assert mesh.vao is None
61
- assert mesh.bbox is None
62
- assert mesh.min_x == pytest.approx(0.0)
63
- assert mesh.max_x == pytest.approx(0.0)
64
- assert mesh.min_y == pytest.approx(0.0)
65
- assert mesh.max_y == pytest.approx(0.0)
66
- assert mesh.min_z == pytest.approx(0.0)
67
- assert mesh.max_z == pytest.approx(0.0)
68
- assert mesh.min_x == pytest.approx(0.0)
69
- assert mesh.max_x == pytest.approx(0.0)
70
- assert mesh.min_y == pytest.approx(0.0)
71
- assert mesh.max_y == pytest.approx(0.0)
72
- assert mesh.min_z == pytest.approx(0.0)
73
- assert mesh.max_z == pytest.approx(0.0)
74
- assert mesh.texture_id == 0
75
- assert mesh.texture is False
76
-
77
-
78
- def test_create_vao_non_triangular(opengl_context):
79
- mesh = BaseMesh()
80
- face1 = Face()
81
- face1.vertex = [1, 2, 3, 4]
82
- mesh.faces = [face1]
83
- with pytest.raises(RuntimeError):
84
- mesh.create_vao()
85
-
86
-
87
- def test_create_vao(opengl_context):
88
- ShaderLib.load_shader(
89
- "nglColourShader",
90
- "src/ncca/ngl/shaders/colour_vertex.glsl",
91
- "src/ncca/ngl/shaders/colour_fragment.glsl",
92
- )
93
- ShaderLib.use("nglColourShader")
94
- mesh = BaseMesh()
95
- mesh.vertex = [
96
- Vec3(0.0, 0.5, 0.0),
97
- Vec3(-0.5, -0.5, 0.0),
98
- Vec3(0.5, -0.5, 0.0),
99
- ]
100
- mesh.normals = [
101
- Vec3(0.0, 0.0, 1.0),
102
- Vec3(0.0, 0.0, 1.0),
103
- Vec3(0.0, 0.0, 1.0),
104
- ]
105
- mesh.uv = [
106
- Vec2(0.5, 1.0),
107
- Vec2(0.0, 0.0),
108
- Vec2(1.0, 0.0),
109
- ]
110
- face = Face()
111
- face.vertex = [0, 1, 2]
112
- face.normal = [0, 1, 2]
113
- face.uv = [0, 1, 2]
114
- mesh.faces = [face]
115
- mesh.create_vao()
116
- assert mesh.vao is not None
117
- assert mesh.bbox is not None
118
- mesh.draw()
119
-
120
-
121
- def test_create_vao_no_normal_no_uv(opengl_context):
122
- ShaderLib.load_shader(
123
- "nglColourShader",
124
- "src/ncca/ngl/shaders/colour_vertex.glsl",
125
- "src/ncca/ngl/shaders/colour_fragment.glsl",
126
- )
127
- ShaderLib.use("nglColourShader")
128
- mesh = BaseMesh()
129
- mesh.vertex = [
130
- Vec3(0.0, 0.5, 0.0),
131
- Vec3(-0.5, -0.5, 0.0),
132
- Vec3(0.5, -0.5, 0.0),
133
- ]
134
-
135
- face = Face()
136
- face.vertex = [0, 1, 2]
137
- mesh.faces = [face]
138
- mesh.create_vao()
139
- assert mesh.vao is not None
140
- assert mesh.bbox is not None
141
- mesh.draw()
142
-
143
-
144
- def test_create_vao_no_uv(opengl_context):
145
- ShaderLib.load_shader(
146
- "nglColourShader",
147
- "src/ncca/ngl/shaders/colour_vertex.glsl",
148
- "src/ncca/ngl/shaders/colour_fragment.glsl",
149
- )
150
- ShaderLib.use("nglColourShader")
151
- mesh = BaseMesh()
152
- mesh.vertex = [
153
- Vec3(0.0, 0.5, 0.0),
154
- Vec3(-0.5, -0.5, 0.0),
155
- Vec3(0.5, -0.5, 0.0),
156
- ]
157
- mesh.normals = [
158
- Vec3(0.0, 0.0, 1.0),
159
- Vec3(0.0, 0.0, 1.0),
160
- Vec3(0.0, 0.0, 1.0),
161
- ]
162
-
163
- face = Face()
164
- face.vertex = [0, 1, 2]
165
- face.normal = [0, 1, 2]
166
- mesh.faces = [face]
167
- mesh.create_vao()
168
- assert mesh.vao is not None
169
- assert mesh.bbox is not None
170
- mesh.draw()
171
-
172
-
173
- def test_create_vao_no_normal(opengl_context):
174
- ShaderLib.load_shader(
175
- "nglColourShader",
176
- "src/ncca/ngl/shaders/colour_vertex.glsl",
177
- "src/ncca/ngl/shaders/colour_fragment.glsl",
178
- )
179
- ShaderLib.use("nglColourShader")
180
- mesh = BaseMesh()
181
- mesh.vertex = [
182
- Vec3(0.0, 0.5, 0.0),
183
- Vec3(-0.5, -0.5, 0.0),
184
- Vec3(0.5, -0.5, 0.0),
185
- ]
186
- mesh.uv = [
187
- Vec2(0.5, 1.0),
188
- Vec2(0.0, 0.0),
189
- Vec2(1.0, 0.0),
190
- ]
191
- face = Face()
192
- face.vertex = [0, 1, 2]
193
- face.uv = [0, 1, 2]
194
- mesh.faces = [face]
195
- mesh.create_vao()
196
- assert mesh.vao is not None
197
- assert mesh.bbox is not None
198
- mesh.draw()
199
-
200
-
201
- def test_draw_no_vao(opengl_context):
202
- mesh = BaseMesh()
203
- mesh.draw() # Should not raise
204
-
205
-
206
- def test_create_vao_reset_vao(opengl_context):
207
- mesh = BaseMesh()
208
- mesh.vertex = [
209
- Vec3(0.0, 0.5, 0.0),
210
- Vec3(-0.5, -0.5, 0.0),
211
- Vec3(0.5, -0.5, 0.0),
212
- ]
213
- face = Face()
214
- face.vertex = [0, 1, 2]
215
- mesh.faces = [face]
216
- mesh.create_vao()
217
- assert mesh.vao is not None
218
- first_vao = mesh.vao
219
- mesh.create_vao(reset_vao=True)
220
- assert mesh.vao is first_vao
221
- mesh.create_vao(reset_vao=False)
222
- assert mesh.vao is not first_vao
223
-
224
-
225
- def test_draw_with_texture(opengl_context, tmp_path):
226
- ShaderLib.load_shader(
227
- "nglColourShader",
228
- "src/ncca/ngl/shaders/colour_vertex.glsl",
229
- "src/ncca/ngl/shaders/colour_fragment.glsl",
230
- )
231
- ShaderLib.use("nglColourShader")
232
- mesh = BaseMesh()
233
- mesh.vertex = [
234
- Vec3(0.0, 0.5, 0.0),
235
- Vec3(-0.5, -0.5, 0.0),
236
- Vec3(0.5, -0.5, 0.0),
237
- ]
238
- face = Face()
239
- face.vertex = [0, 1, 2]
240
- mesh.faces = [face]
241
- mesh.create_vao()
242
- size = 2
243
- img = Image(width=size, height=size, mode=ImageModes.RGB)
244
- filename = tmp_path / "simpleRGB.png"
245
- img.save(str(filename))
246
- t = Texture(str(filename))
247
- mesh.texture_id = t.set_texture_gl()
248
- mesh.draw()
249
- gl.glDeleteTextures(1, [mesh.texture_id])