pyglet icon indicating copy to clipboard operation
pyglet copied to clipboard

Some future features about pyglet

Open zhengxyz123 opened this issue 4 years ago • 9 comments

First, thanks pyglet team for providing a such useful game development library. While I was using the pyglet, I found something shortage about pyglet. So, I open this issue named Some future features about pyglet.

1. Font

The pyglet.font module is very useful but it haven't brief documents about Font object.

The following python code create a png file which store a @ character:

import pyglet
import pyglet.font

pyglet.font.add_file('font.ttf')
font = pyglet.font.load('font name')
font.get_glyphs('@')[0].save('glyph.png')

Everything seems very simple, but when we preview this file, the character @ is very strange.

That's why I choose @ as the character, not A

2. GUI

The pyglet.gui module was recently added, so It didn't have documents yet. So, I read the code and create a gui module for my own game. Why? The pyglet.gui is too simple and crude to use!

The Button class just include a Button and a Toggle Button, If we want to add some text or image to the button, we should inherit the origin class and rewrite them.

According to OpenGL coordinate system, the y-axis is contrary to the actual coordinate system. So, we should calculate it, but pyglet not, I suggest you to add this thing.

3. 3D objects

It seems pyglet supports 2D games more, it include 2D shapes, sprite. But, pyglet doesn't have 3D elements like cube, ball, 3D particles, 3D sprite.

A commonplace talk of an old scholar: OpenGL doesn't support mutiple-process

As a game development library, pyglet can't conpare with LWJGL.

zhengxyz123 avatar Jan 22 '21 21:01 zhengxyz123

Thanks for opening the ticket.

1) I'm not sure what the issue is. What's happening, and what did you expect to happen?

2) As you've noticed, the gui module is incomplete. So far, it only contains the basic building blocks. One reason that it's undocumented, is that it could change. As for the goal of this module, the idea is to provide basic functionality for a game or simple application. After that, it depends on what users want.

According to OpenGL coordinate system, the y-axis is contrary to the actual coordinate system. So, we should calculate it, but pyglet not, I suggest you to add this thing.

I'm sorry, but I don't fully understand. Are you saying that Y should start at the top-left for Widgets?

3) There is simple support for loading 3D models, but so far only the Wavefront (obj) format is supported. When pyglet v2.0 is released, glTF will be added as well. 3D shapes could be added to the shapes module if someone wants to write them. If you look at the shapes module, you can see that everything is created from the pyglet.graphics module.

If you want to talk about any of these ideas, please feel free to join the Discord server, and visit the contributing channel.

benmoran56 avatar Jan 24 '21 13:01 benmoran56

Thanks for your replied. I open this issue when I code the HUD/GUI part of my game.

Also, you answered the gui but didn't include font. pyglet.font is a big problem for me, I want to use it to draw 3D text but I don't know exactly what to do. pyglet.font documents are not in detail!

zhengxyz123 avatar Jan 24 '21 15:01 zhengxyz123

I'm sorry, but I don't fully understand. Are you saying that Y should start at the top-left for Widgets?

The y-axis(y=0) should start at the top of the window, not bottom.

The following codes return the size of a given name window:

def get_size(name):
    for w in pyglet.canvas.get_display().get_windows():
        if w.caption == name:
            return w.width, w.height
    else:
        return 0, 0

zhengxyz123 avatar Jan 24 '21 22:01 zhengxyz123

Pyglet use viewport coordinate by default for projection. Also mouse coordinates are in viewport coordinates.

einarf avatar Jan 24 '21 23:01 einarf

Hello, I have a problem: I want to write a small game which allow player to choice a game storage and start the game in just one window.

It is a 3D game and use a 2D GUI to choice a game storage, It seems not easy.

zhengxyz123 avatar Feb 06 '21 04:02 zhengxyz123

If you want to mix 2D and 3D, you will need to change the OpenGL projection between rendering calls. There are a lot of ways to do this, but one way would be to use custom Groups. Groups have set_state and unset_state methods. This is where you can provide the OpenGL projection changes before drawing.

benmoran56 avatar Apr 01 '21 07:04 benmoran56

I really want to know: the documents about pyglet.font are very simple, not useful.

zhengxyz123 avatar Apr 01 '21 11:04 zhengxyz123

Can you tell me how I can use pyglet.font?

zhengxyz123 avatar Jun 07 '21 13:06 zhengxyz123

你想用pyglet.font的哪个方面?

shenjackyuanjie avatar Feb 22 '23 14:02 shenjackyuanjie