{"id":24656695,"url":"https://github.com/jingshing-python/moderngl-shader-with-pygame","last_synced_at":"2025-10-07T17:31:39.146Z","repository":{"id":50659892,"uuid":"519757990","full_name":"JingShing-Python/ModernGL-Shader-with-pygame","owner":"JingShing-Python","description":"you can use this class to give pygame a shader to render screen. it is easy to use.","archived":false,"fork":false,"pushed_at":"2022-08-19T16:45:38.000Z","size":58,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2023-03-07T06:19:02.903Z","etag":null,"topics":["glsl","moderngl","opengl","pygame","pyopengl","shaders"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JingShing-Python.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-07-31T11:33:54.000Z","updated_at":"2023-02-12T06:51:16.000Z","dependencies_parsed_at":"2022-08-12T22:00:43.250Z","dependency_job_id":null,"html_url":"https://github.com/JingShing-Python/ModernGL-Shader-with-pygame","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingShing-Python%2FModernGL-Shader-with-pygame","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingShing-Python%2FModernGL-Shader-with-pygame/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingShing-Python%2FModernGL-Shader-with-pygame/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JingShing-Python%2FModernGL-Shader-with-pygame/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JingShing-Python","download_url":"https://codeload.github.com/JingShing-Python/ModernGL-Shader-with-pygame/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235648389,"owners_count":19023610,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["glsl","moderngl","opengl","pygame","pyopengl","shaders"],"created_at":"2025-01-25T23:39:35.329Z","updated_at":"2025-10-07T17:31:33.814Z","avatar_url":"https://github.com/JingShing-Python.png","language":"Python","readme":"# ModernGL-Shader-with-pygame\nI had put a crt shader as example in shaders folder. you can write your own shader.\nyou can use this class to give pygame a shader to render screen. it is easy to use.\n\nI will add tutorial later I have free time.\n\nit's easy to use.\nI had put example file in it. You can experiment with it and try something new.\n\n1. replace your display variable with a Surface. and blit everything you want to show on that Surface.\n2. display set mode with OPENGL and DOUBLEBUF flag. \n3. import my shader class. And init a new shader for your game. Remember to pass your display Surface to init it.\n4. Replace all display.update with your new shader render function.\n\nEnjoy crt shader in your game.\n\ncrt example : https://www.youtube.com/watch?v=2ekJdkXC4iM\n\nmy works using this class :\n\nMyth of Charlie ：https://jingshing.itch.io/myth-of-charlie\n\nDragonCastle：https://jingshing.itch.io/dragoncastle\n\n使用說明：\n1. 將你原本用於display的變量以Surface的方式重新宣告，並取消對display的變量宣告。之後要繪製的圖形就全部渲染到這張Surface上。以下將簡稱這個Surface為Screen。screen = pygame.Surface(size)\n2. 在display裡設置為OPENGL和DOUBLEBUF的模式，以便讓OpenGL渲染。pygame.display.set_mode(size, DOUBLEBUF|OPENGL)\n3. 導入上面提供的Shader的Class，並自行實例化。之後要用這個實例化的物件渲染。\n4. 將原本畫面更新的部分，全部更改成以shader的物件render。有獨立的func，也設置了__call__的指令。可以直接呼叫物件渲染。\n\n\n\n我的OpenGL啟蒙者。ModernGL在很多方面都方便很多，不過這也是弊端，雖然和pygame的兼容性很高，不過不是一條長遠的道路。\n\n想要過過shader的癮可以嘗試，但最好淺嘗，ModernGL本身的缺陷很多，打包時很痛苦。\n\n如果只是要做pygame項目是完全夠用的。歡迎參考我有使用這個shader的作品：\n\nMyth of Charlie ：https://jingshing.itch.io/myth-of-charlie\n\nDragonCastle：https://jingshing.itch.io/dragoncastle\n\n---\n## UPDATE:\n* ADD \"Fullscreen\" function in crt_shader\n\n* ADD \"change shader\" function in crt_shader\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingshing-python%2Fmoderngl-shader-with-pygame","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjingshing-python%2Fmoderngl-shader-with-pygame","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjingshing-python%2Fmoderngl-shader-with-pygame/lists"}