From cb54f959975ffc16ea8ce430ea9570bd3a43e575 Mon Sep 17 00:00:00 2001 From: somePythonProgrammer <74598401+somePythonProgrammer@users.noreply.github.com> Date: Sat, 13 Aug 2022 17:02:26 +0530 Subject: [PATCH 1/2] Faster VBO updates --- core/renderer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/renderer.py b/core/renderer.py index 512aaf8..4d75506 100644 --- a/core/renderer.py +++ b/core/renderer.py @@ -12,7 +12,7 @@ glfw.init() -STEP = 256 +STEP = 4096 class TerrainRenderer: def __init__(self, window, mode=GL_TRIANGLES): From e5057f47c30f4fe916a50d12df31cd4d124166ae Mon Sep 17 00:00:00 2001 From: somePythonProgrammer <74598401+somePythonProgrammer@users.noreply.github.com> Date: Sat, 13 Aug 2022 22:01:31 +0530 Subject: [PATCH 2/2] Adding cross-platform support --- __main__.py | 2 +- core/fileutils.py | 1 - core/renderer.py | 2 -- launch.py | 23 +++++++++++++++++++++++ terrain/chunk.py | 2 ++ 5 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 launch.py diff --git a/__main__.py b/__main__.py index 5b11138..9101599 100644 --- a/__main__.py +++ b/__main__.py @@ -55,7 +55,7 @@ glHint(GL_FOG_HINT, GL_DONT_CARE) glFogi(GL_FOG_MODE, GL_LINEAR) glFogf(GL_FOG_START, CHUNK_SIZE*2) - glFogf(GL_FOG_END, (world.render_distance+2) * CHUNK_SIZE) + glFogf(GL_FOG_END, (world.render_distance - 1) * CHUNK_SIZE) # get window size def get_window_size(): diff --git a/core/fileutils.py b/core/fileutils.py index a06e8fc..52d4659 100644 --- a/core/fileutils.py +++ b/core/fileutils.py @@ -1,7 +1,6 @@ import os import json import threading -import sys class ListenerBase: def __init__(self, directory): diff --git a/core/renderer.py b/core/renderer.py index 2c6a0ba..c6c0fb6 100644 --- a/core/renderer.py +++ b/core/renderer.py @@ -85,8 +85,6 @@ def shared_context(self, window): except Exception as e: pass - glfw.poll_events() - glfw.swap_buffers(window2) glfw.terminate() def create_vbo(self, window): diff --git a/launch.py b/launch.py new file mode 100644 index 0000000..b248a13 --- /dev/null +++ b/launch.py @@ -0,0 +1,23 @@ +import sys +import subprocess +import pkg_resources + +# make sure pip is installed +try: + pkg_resources.require("pip") +except pkg_resources.DistributionNotFound: + print("pip is not installed. Please install pip.") + sys.exit(1) + +required = {'glfw', 'pygame', 'opensimplex', 'psutil', 'pyopengl', 'pyopengl-accelerate', 'numpy', 'pillow'} +installed = {pkg.key for pkg in pkg_resources.working_set} +missing = required - installed + +if missing: + subprocess.Popen([sys.executable, '-m', 'pip', 'install', *missing]).wait() + +# run git pull +subprocess.Popen(['git', 'pull']).wait() + +# run the game +subprocess.Popen(['python', '__main__.py']).wait() diff --git a/terrain/chunk.py b/terrain/chunk.py index 14592dd..1680576 100644 --- a/terrain/chunk.py +++ b/terrain/chunk.py @@ -1,4 +1,6 @@ import subprocess +import sys + from terrain.block import * from core.renderer import *