I'm not very familiar with 3D, but I suspect your issue is a mismatch between your OpenGL coordinates, and the window coordinates. The mouse clicks always return x/y of the actual window size in pixels, but your OpenGL projection might not match that. If that is the case, you just need to calculate the scaling.
As for OpenGL features, pyglet is using the legacy profile out of the box. If you request a newer profile, it will use that. However, all of the built-in modules (image, sprite, text, etc.) are relying on the older functions. If you request a modern OpenGL context on Linux (and Windows, depending on driver), then the legacy GL functions are still available usually. On Mac, this is not the case. I think that you don't really want to rely on theis behavior if you are planning on sharing your app/game with other people. On Wednesday, May 3, 2017 at 8:01:25 AM UTC+9, Samson Liu wrote: > > Thank you so much!!! I really appreciate it! > > However, on display, there is always this error in x dimension of the > window.. I'm trying to draw text boxes on click, but the rectangles are > really off (to the left) when I click on the left half of the screen. It > gets a little more accurate over to the right though. I'm trying to look > for solutions on my own, but it would be wonderful if you could offer some > insight! > > Also, on a side note, can I still use gluUnProject with OpenGL 4 in > pyglet, since it's deprecated? It didn't give me any error though.. > > On Tuesday, May 2, 2017 at 3:11:39 AM UTC-4, Benjamin Moran wrote: >> >> 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.
