hello, so I made new buttons with a resolution in power of 2 (2048x512) and this problem is still there… I don’t think adding a light would solve it since I don’t use any right now and, if I am not wrong, my test button with text wouldn’t have worked if it was the case. I bring here all my code (sorry if it’s not the best) :
guitools.py :
from direct.gui.DirectGui import *
from direct.gui.OnscreenImage import OnscreenImage
from panda3d.core import TransparencyAttrib
BUTTON_WIDTH = 2048
BUTTON_HEIGHT = 512
# buttons dimensions : width : 2048 height : 512
def make_button(self, name, action, width, height, proportions, position):
"""this function returns a DirectButton object that can be used for any GUI in the game"""
maps = self.loader.loadModel(f"models/buttons/{name}")
print("button creation")
button = DirectButton(geom=(maps.find(f"**/{name}"),
maps.find(f"**/{name}_click"),
maps.find(f"**/{name}_rollover"),
),
pos=(position[0],
0,
position[1]),
geom_scale=((width * proportions[0]) / BUTTON_WIDTH,
1,
(height * proportions[1]) / BUTTON_HEIGHT),
command=action,
relief=0,
rolloverSound=self.loader.loadSfx("sounds/menu/rollover_sound.wav"),
clickSound=self.loader.loadSfx("sounds/menu/click_sound.wav")
)
button.setTransparency(TransparencyAttrib.MAlpha)
print("action : ", action)
print("button created")
return button
def make_image(self, name, position, width, height, proportions, imageWidth=None, imageHeight=None, transparent=False,
parent=None):
"""this function create an image rendered on screen"""
if (imageWidth is None) or (imageHeight is None):
image = self.loader.loadTexture(name)
imageWidth = image.getXSize()
imageHeight = image.getYSize()
del image
print(f"{name} = width : {width} proportions : {proportions} imageWidth : {imageWidth}")
print(f"then scale of x is {(width * proportions[0]) / imageWidth}")
image = OnscreenImage(image=name,
pos=position,
scale=((width * proportions[0]) / imageWidth,
1,
(height * proportions[1]) / imageHeight),
)
if parent is not None:
image.reparentTo(parent)
if transparent:
image.setTransparency(TransparencyAttrib.MAlpha)
return image
menu.py :
import guitools
class Menu:
def __init__(self, loader, listButtons, listActions, width, height, render):
"""initialization of the menu object"""
# First, we will have to load all the GUI components
self.LIST_BUTTONS = listButtons
self.WIDTH = width
self.HEIGHT = height
self.loader = loader
self.buttonClicked = False
self.font = guitools.make_image(self, "images/menu/font.jpg", (0, 0, 0), self.WIDTH, self.HEIGHT,
(1.6, 1.9), parent=render)
self.title = guitools.make_image(self, "images/menu/title.png", (-.5, 00, 0.7), self.WIDTH, self.HEIGHT,
(0.25, 0.02), transparent=True, parent=render)
for i, e in enumerate(self.LIST_BUTTONS):
print(i, e)
self.__dict__[e] = guitools.make_button(self, e, listActions[i], self.WIDTH, self.HEIGHT, (0.2, 0.1),
(0.8, 0.6 - 0.5 * i))
def update(self):
"""update of the menu"""
def __del__(self):
""" we will just free space and delete any object that has been loaded before."""
for e in self.LIST_BUTTONS:
self.__dict__[e].destroy()
self.title.destroy()
self.font.destroy()
main.py :
def loadMenu(self):
""" load the menu menu"""
global menu
menu = "menu"
print("loadMenu")
self.player = Menu(self.loader, ("play", "option", "quit"), (self.startGame, self.startOption, self.doExit),
WIDTH, HEIGHT, self.render2d) # load menu
taskMgr.add(self.updateMenu, "update-menu") # update menu
# end of menu
def updateMenu(self, task):
"""the update function for the menu menu"""
print("updateMenu")
self.player.update()
return task.cont
# / ! \ buttons work when I click on them. so we don't care about the next functions
def startGame(self):
print("START GAMEEEE !!!")
taskMgr.remove("update-menu")
print("end menu")
del self.player
self.loadGame() # loadGame
taskMgr.add(self.loop, "loop")
def startOption(self): #this one doesnt work.. but I prefer to correct this texture problem first
taskMgr.remove("update-menu")
print("end menu, go option")
self.lastMenu.append(self.player)
self.player = None
self.loadOption()
taskMgr.add(self.updateOption, "loop")
def doExit(self):
taskMgr.remove("update-menu")
del self.player
sys.exit(0)
The .egg files are made with 3 png (with transparency).
In fact, my friend gave me the images via discord (it was in .PNG)
I tried to display the menu.egg (it’s another button that was made at the same time at the others so it should give the same error with play.egg, quit.egg or option.egg) file in pview and it displayed me also a white rectangle but it gave me also this error :
Known pipe types:
wglGraphicsPipe
(all display modules loaded.)
:display:gsg:glgsg(warning): Driver possibly misreported GL_VERSION! Unable to detect correct OpenGL version.
:gobj(error): Texture::read() - couldn’t read: menu.png
:gobj(error): Unable to find texture “menu.png” on model-path /c/Panda3D-1.10.8-x64/bin;/c/Panda3D-1.10.8-x64/etc/…;/c/Panda3D-1.10.8-x64/etc/…/models
:gobj(error): Texture::read() - couldn’t read: menu_click.png
:gobj(error): Unable to find texture “menu_click.png” on model-path /c/Panda3D-1.10.8-x64/bin;/c/Panda3D-1.10.8-x64/etc/…;/c/Panda3D-1.10.8-x64/etc/…/models
:gobj(error): Texture::read() - couldn’t read: menu_rollover.png
:gobj(error): Unable to find texture “menu_rollover.png” on model-path /c/Panda3D-1.10.8-x64/bin;/c/Panda3D-1.10.8-x64/etc/…;/c/Panda3D-1.10.8-x64/etc/…/models