pyray get static unsigned int array[] from raylib #98
Replies: 6 comments 15 replies
-
firstly, please try not to open discussions about these kinds of things, open an issue instead... from raylib import *
from ctypes import *
def la_dbg_pause():
print("DEBUG Pause! Press [Enter] to continue...")
input() # Press [Enter] to continue.
return None
screenWidth = 800
screenHeight = 450
gui_style = c_uint(1564)
InitWindow(screenWidth, screenHeight, b"raygui - controls test suite")
print(DEFAULT)
print(BACKGROUND_COLOR)
gui_style = c_uint(GuiGetStyle(DEFAULT, BACKGROUND_COLOR))
print(gui_style) # DEBUG - returns negative value
# print(gui_get_style(DEFAULT, BACKGROUND_COLOR)) #DEBUG - returns negative value
#la_dbg_pause()
ClearBackground(GetColor(gui_style.value)) # From examples/controls_test_suite.c (converted)
CloseWindow() # Close window and OpenGL context
## From raylib.h
## static unsigned int guiStyle[RAYGUI_MAX_CONTROLS*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED)] = { 0 };
# // Get control style property value
# int GuiGetStyle(int control, int property)
# {
# if (!guiStyleLoaded) GuiLoadStyleDefault();
# return guiStyle[control*(RAYGUI_MAX_PROPS_BASE + RAYGUI_MAX_PROPS_EXTENDED) + property];
# } |
Beta Was this translation helpful? Give feedback.
-
in python, we don't really have arrays, Nevertheless using ctypes you can create an array(in the example I will present an unsigned int array) object by using ctypes from ctypes import *
number_of_elements_in_array = 5
my_array = (c_uint * number_of_elements_in_array )() |
Beta Was this translation helpful? Give feedback.
-
static vairables in c are just globales vairables in python(i think). |
Beta Was this translation helpful? Give feedback.
-
Basically the problem is the signatures dont match. It's an unsigned int, but then in the second signature it's a signed int. So CFFI trys to convert it. You could report this as a bug, but they would probably say "RayGUI is just a simple experiment for my personal projects, you are advised to use ImGUI instead." |
Beta Was this translation helpful? Give feedback.
-
using ctypes you can create a 2d array like this:
if you use that note that you will still need to fill the array data by yourself(manually) |
Beta Was this translation helpful? Give feedback.
-
Hi a small update for /raygui/examples/controls_test_suite/controls_test_suite.py , and I'll throw in the /raylib/examples/shapes/shapes_basic_shapes.py as well. As a last item, is it OK if translate the c to py examples using the type prefix for variables? else I will leave the prefix out for copies I give to you. I'll likely convert as many examples as I can as a "raylib API familiarity exercise", so I may as well send them your ways as a thanks for the assist. Have to start a new tertiary intake from today so may be a while, but I'll trickle along with them in the background. I have to do conversions for FreeBASIC as well because I like to punish myself with over commitment lol With thanks |
Beta Was this translation helpful? Give feedback.
-
Hi I am trying to convert .\raygui\examples\controls_test_suite.c to pyray.
I am stuck on Line 143:
ClearBackground(GetColor(GuiGetStyle(DEFAULT, BACKGROUND_COLOR)));
I am always getting a negative integer return and can't seam to get the correct method using ffi to return it from the library as an unsigned integer.
The following is a test extract that I am using to try to debug and work it out:
Output:
Any small example on retrieving the value of that array would be helpfull :)
Axle
Beta Was this translation helpful? Give feedback.
All reactions