[WIP] Improved version of menu screen.
Replacement of #61
Currently there is a menu screen but it is not functional yet. The UI is made with PyImGUI. I will add an image of the menu tomorrow. Using PyImGUI means we no longer have resizing issues that were present in #61, in addition, we do not need to code the UI elements that we want in the future.
Also, if you do find a way into the world, the F3 screen is rendered with PyImGUI, in addition, this fixes a bug where the F3 text could go behind blocks a certain camera angles.
Here's an image of the menu so far.
Looks great! I'll review this PR shortly... the only issue I have right now is that I'm not able to run it on my PC (I'll send over the details next time I'm on my PC) - could you clarify what exactly needs to be installed, and add that to the readme?
@obiwac
Looks great! I'll review this PR shortly... the only issue I have right now is that I'm not able to run it on my PC (I'll send over the details next time I'm on my PC) - could you clarify what exactly needs to be installed, and add that to the readme?
The community/start.bat has been modified to have all dependencies and I will update the readme. This PR is not finished yet.
I think we should probably delete start.bat and replace it with a requirements.txt.
I agree.
Here is the issue I'm getting w.r.t. not being able to run the program. It seems to be ImGUI-related more than anything, but I'm not excluding the possibility that something is being done in the MCPY code to alter the state of the OpenGL context s.t. it causes issues in ImGUI:
Logs
Traceback (most recent call last):
File "/tmp/python-minecraft-clone/community/main.py", line 460, in <module>
main()
File "/tmp/python-minecraft-clone/community/main.py", line 457, in main
game.run()
File "/tmp/python-minecraft-clone/community/main.py", line 436, in run
pyglet.app.run(interval = 0)
File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/app/__init__.py", line 76, in run
event_loop.run(interval)
File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/app/base.py", line 163, in run
timeout = self.idle()
^^^^^^^^^^^
File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/app/base.py", line 224, in idle
self.clock.call_scheduled_functions(dt)
File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/clock.py", line 180, in call_scheduled_functions
item.func(dt, *item.args, **item.kwargs)
File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/app/base.py", line 118, in _redraw_windows
window.dispatch_event('on_draw')
File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/window/__init__.py", line 671, in dispatch_event
super().dispatch_event(*args)
File "/home/obiwac/.local/lib/python3.11/site-packages/pyglet/event.py", line 387, in dispatch_event
if getattr(self, event_type)(*args):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/python-minecraft-clone/community/main.py", line 420, in on_draw
self.impl.render(imgui.get_draw_data())
File "/home/obiwac/.local/lib/python3.11/site-packages/imgui/integrations/pyglet.py", line 219, in render
super(PygletProgrammablePipelineRenderer, self).render(draw_data)
File "/home/obiwac/.local/lib/python3.11/site-packages/imgui/integrations/opengl.py", line 149, in render
common_gl_state_tuple = get_common_gl_state()
^^^^^^^^^^^^^^^^^^^^^
File "/home/obiwac/.local/lib/python3.11/site-packages/imgui/integrations/opengl.py", line 347, in get_common_gl_state
last_texture = gl.glGetIntegerv(gl.GL_TEXTURE_BINDING_2D)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/obiwac/.local/lib/python3.11/site-packages/OpenGL/latebind.py", line 43, in __call__
return self._finalCall( *args, **named )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/obiwac/.local/lib/python3.11/site-packages/OpenGL/wrapper.py", line 678, in wrapperCall
raise err
File "/home/obiwac/.local/lib/python3.11/site-packages/OpenGL/wrapper.py", line 671, in wrapperCall
result = wrappedOperation( *cArguments )
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/obiwac/.local/lib/python3.11/site-packages/OpenGL/error.py", line 230, in glCheckError
raise self._errorClass(
OpenGL.error.GLError: GLError(
err = 1280,
description = b'invalid enumerant',
baseOperation = glGetIntegerv,
pyArgs = (
GL_TEXTURE_BINDING_2D,
<object object at 0x83e0c7d60>,
),
cArgs = (
GL_TEXTURE_BINDING_2D,
array([3], dtype=int32),
),
cArguments = (
GL_TEXTURE_BINDING_2D,
array([3], dtype=int32),
)
)
I don't have time to debug this in detail today, but you can try setting:
pyglet.options["debug_gl"] = True
That error could be happening because internally imgui uses PyOpenGL instead of Pyglet's gl, so I should probably modify my extra image loading function to use PyOpenGl instead of Pyglet's gl. For me I do not get this error, maybe we have different graphics drivers.
I don't think it's to do with a difference between different gl bindings. The OpenGL state is common between the two, and is stored in the graphics driver. If you enable debug_gl you do see errors in community even without this PR's additions. These probably have to be tracked down and fixed first. (And yeah, a difference in graphics driver probably explains the difference in behaviour; for reference I'm using NVIDIA's X driver.)
Didn't see your message until now, but I have made my extra load function use PyOpenGL. Could you try if that works for you?
Also I thought the same about the state being common, and I'm using NVIDIA's Windows drivers.
I still have the same issue
Could you provide your system information (found in the latest log from the logs directory).
My system information is:
[2023-12-27 12:12:35,759] [MainProcess/MainThread/INFO] (main.py/__init__) System Info: Python: CPython 3.10.2
System: AMD64 Windows 10 10.0.19045
CPU: Intel64 Family 6 Model 165 Stepping 3, GenuineIntel
Display: NVIDIA GeForce GTX 1650/PCIe/SSE2
(4, 6)