-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_BoilerPlate.py
77 lines (58 loc) · 2.37 KB
/
_BoilerPlate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
"""
Author: Ethan.R
Date of Creation: 31st Febuary
Name of Program: NA
"""
from _lib import Main
import moderngl as mgl
import pygame as pg
import numpy as np
from _shaderPasses.bloom import Bloom
from _shaderPasses.gaussianBlur import GaussianBlur
from _shaderPasses.colourQuantise import ColourQuantise
from _shaderPasses.dithering import Dithering
from _shaderPasses.sobelFilter import SobelFilter
from _shaderPasses.contrast import Contrast
from _shaderPasses.greyScale import GreyScale
from _shaderPasses.cannyEdgeDetection import CannyEdgeDetection
class ShaderProgram(Main):
frag: str = """
# version 460 core
uniform sampler2D uTexture;
in vec2 uvs;
out vec4 fColour;
void main(){
vec4 colour = texture(uTexture, uvs).rgba;
fColour = vec4(colour.rgb, colour.a);
}
"""
def __init__(self, media:str, scale:int=1, caption:str="NA", swizzle:str="RGBA", flip:bool=False, components:int=4, method:str="nearest", fps:int=60):
super().__init__(media=media, scale=scale, caption=caption, swizzle=swizzle, flip=flip, components=components, method=method, fps=fps)
# Shader Shenanigans
self.load_program()
self.create_program(title="new", vert=Main.vert, frag=ShaderProgram.frag)
self.create_vao(title="new", program="new", buffer="main", args=["2f 2f", "iPosition", "iTexCoord"])
self.create_texture(title="new", size=self.textures["main"].size, components=self.textures["main"].components)
self.create_framebuffer(title="new", attachments=self.textures["new"])
def update(self):
# Update content shenanigans
super().update()
def draw(self):
# Draw content shenanigans
self.framebuffers["new"].use()
self.textures["main"].use(location=0)
self.programs["new"]["uTexture"] = 0
self.vaos["new"].render(mgl.TRIANGLE_STRIP)
self.textures["new"].use(location=0)
self.programs["main"]["uTexture"] = 0
super().draw()
if __name__ == "__main__":
ShaderProgram(
caption="I'm Testing Here!",
swizzle="RGBA",
scale=1.0,
flip=True,
components=3,
media=r"",
fps=60,
).run()