I had a look at that video, and maybe I can add a little bit more specific
information to what Greg has said.
In the video, the Model class has it's own batch. It also has it's own
draw() method, which simply draws that batch.
I would get rid of that, and create two batches in the main Window class:
self.batch3d and self.batch2d. When making the Model instances, pass the
self.batch3d into it and add everything to that batch. Use the
self.batch2d class for everything that should be 2D, such as labels, hUD
sprites, etc.
In the Window.on_draw() method, you should have something like:
def on_draw(self):
self.set_3d()
self.batch3d.draw()
self.set_2d()
self.batch2d.draw()
There are a lot of different ways to structure this, but this might be an
easy way to get started.
On Sunday, April 30, 2017 at 3:49:51 AM UTC+9, Samson Liu wrote:
>
> Hello
>
> I'm trying to implement GUI in my 3d scene, but I wasn't able to find a
> lot of examples on how you would implement that.
>
> My current code is, based on this tutorial https://goo.gl/EViXlm. It's a
> short minecraft introduction, which obviously doesn't incorporate any GUI.
>
> Even though I changed almost everything and added a lot more to that code,
> my logic stayed the same: I have one window class, and in the on_draw
> function, I call the projection matrix and modelview matrix. Then I have a
> 'push' function with glRotatef and glTranslate, which is for moving the
> camera and they linked to my model class. I have separate classed for GUI,
> terrain and other stuff too.
>
> I know it should be easy: I just don't have to call 'push' for the GUI
> part. But I can't really grasp how to separately draw the model and the
> GUI? Right now everything is moving, and I almost feel like I need 2 window
> classes but that's obviously not the solution.
>
> Also, I can switch between 2d and 3d view, I just can't separate for GUI
> and model
>
> I watched ThinMatrix's LWJGL and OpenGL series, but I think he's doing a
> lot of the projection matrix things in the shaders.. So it doesn't really
> apply. Then I found examples for only 2d or for Java and it didn't make a
> whole lot of sense to me.
>
> Thank you so much for helping!
>
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/pyglet-users.
For more options, visit https://groups.google.com/d/optout.