ncca-ngl 0.1.0__py3-none-any.whl → 0.1.2__py3-none-any.whl

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.
Binary file
ncca/ngl/abstract_vao.py CHANGED
@@ -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,5 +1,5 @@
1
1
  ncca/ngl/__init__.py,sha256=i01MBdh814MrDmPDvG4dPI6azBWZWTq212cfVNnKkR8,2308
2
- ncca/ngl/abstract_vao.py,sha256=VLKp3pmPYK_dQgEImMOAQ0DufAswK_0H4DR4r8flp2U,2104
2
+ ncca/ngl/abstract_vao.py,sha256=fi7-BIfw1jefcXe09Qj2gGmnqqA9kzJK-hAwfG14Hrc,2068
3
3
  ncca/ngl/base_mesh.py,sha256=2JmVT5_bvgLHra1VnwRld-mh-20IqqekgEu1dbGU1a4,5736
4
4
  ncca/ngl/base_mesh.pyi,sha256=kobLuNnCSZlRRobIgVopQaS7Bjg0tJ3m4M64WXt5I-M,173
5
5
  ncca/ngl/bbox.py,sha256=PylB6ju_bkdDUqQkzO1n2E-jsmxiviNkyBLY-sN59n8,6578
@@ -33,9 +33,19 @@ ncca/ngl/vec3.py,sha256=q4HI4y4Xk3lTdlB8YdF4T2mCdwK2jXRattjDHlJi7vg,12265
33
33
  ncca/ngl/vec3_array.py,sha256=okRU8rp-jGYg2AzEUWx-ErsBkH1fG4L16c8nGKu-v04,2808
34
34
  ncca/ngl/vec4.py,sha256=zF0zw5EO4UE7EmqN30LPR3QQfaMcA1VcMID8CZALDiU,6740
35
35
  ncca/ngl/vec4_array.py,sha256=CCyHM4nIHvlwWxa12jCrJp-j6qfIYvU_irbdcB7NO0g,2699
36
+ ncca/ngl/PrimData/Primitives.npz,sha256=8viufkX_FyT6afB4ZJR_ikv3D3tBG6IuHIXBdw0nE0o,15016264
36
37
  ncca/ngl/PrimData/pack_arrays.py,sha256=aWShJX8QPHXKTj66C8yu1DskmD3VEzFXyaADcxw6YKs,362
37
- ncca_ngl-0.1.0.dist-info/licenses/LICENSE.txt,sha256=WY4-vI3NTjw6HGwshZcyvEYhvAKBX3rpY7x9wMF_FhA,1056
38
- ncca_ngl-0.1.0.dist-info/METADATA,sha256=K_RFj72JMSY1SwA0-7kBTMECJ-35KHRe0G029qb4WSM,1620
39
- ncca_ngl-0.1.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
40
- ncca_ngl-0.1.0.dist-info/top_level.txt,sha256=nCKLyKtzlEVkOyE2KwxaykU3UgPocbQqRoMUXcICm3s,5
41
- ncca_ngl-0.1.0.dist-info/RECORD,,
38
+ ncca/ngl/shaders/checker_fragment.glsl,sha256=2hJH8yOJxLH5DdDdS15C3uom4o4YsiBle0fIYLkx9jI,640
39
+ ncca/ngl/shaders/checker_vertex.glsl,sha256=G90GDAY5yEsdYMHhpZhWTmFFx_jfpDUexam-vpuVrXo,411
40
+ ncca/ngl/shaders/colour_fragment.glsl,sha256=Y8CeWyDyQAK7u3-rQhURO6Ee3ibturZR3B75e5vcb2U,118
41
+ ncca/ngl/shaders/colour_vertex.glsl,sha256=moRuaWAmWbItzIgFlweDMz1dklQrJ_jZKNjw8SaXd9I,154
42
+ ncca/ngl/shaders/diffuse_fragment.glsl,sha256=vkKJ9R683yk5OlyUGUwdoqrLyOsvFz3CjZS-wRCuzaY,615
43
+ ncca/ngl/shaders/diffuse_vertex.glsl,sha256=j1t1Zv5iky0gsBG0HOQGOix6qyj09RHo7c_irMMJZHo,621
44
+ ncca/ngl/shaders/text_fragment.glsl,sha256=KbvixK0-ZEdlkW85MhbvYJ0qnQUW6d4SbVcKIA18uyo,217
45
+ ncca/ngl/shaders/text_geometry.glsl,sha256=OTLdn4pdZj2BOMh33rE6JBfQ9SHQ1L1e8qn3Hl3YV6w,1015
46
+ ncca/ngl/shaders/text_vertex.glsl,sha256=uPym1x87SJOd0E3zPN1Fx44warJ6IYfvhzPQEtLOO3w,289
47
+ ncca_ngl-0.1.2.dist-info/licenses/LICENSE.txt,sha256=WY4-vI3NTjw6HGwshZcyvEYhvAKBX3rpY7x9wMF_FhA,1056
48
+ ncca_ngl-0.1.2.dist-info/METADATA,sha256=HUoGh5Z3kVKQ9X_sCAmx3XLF7ng7AJtLlShdc5QD0KI,1649
49
+ ncca_ngl-0.1.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
50
+ ncca_ngl-0.1.2.dist-info/top_level.txt,sha256=nCKLyKtzlEVkOyE2KwxaykU3UgPocbQqRoMUXcICm3s,5
51
+ ncca_ngl-0.1.2.dist-info/RECORD,,