Dear Xojo Community,
I am currently developing a project in Xojo using OpenGL, but I am encountering persistent errors related to OpenGL function calls. Despite properly declaring functions in DeclareOpenGLFunctions()
, Xojo reports that they “do not exist” when called in the Render()
event.
Issue #1: OpenGL Functions Not Recognized
Even though DeclareOpenGLFunctions()
contains standard OpenGL function declarations, Xojo reports:
glEnable(IgnisAI_Module.GL_TEXTURE_2D) does not exist
glGenTextures(1, texID) does not exist
glBindTexture(IgnisAI_Module.GL_TEXTURE_2D, IgnisAI_Module.TextureID) does not exist
glTexImage2D(...) does not exist
Questions:
Q1: Is there a known issue with OpenGL function declarations in Xojo that could cause this?
Q2: Should these OpenGL functions be declared differently in Xojo (specific syntax, scope, or calling convention adjustments)?
Issue #2: glGenTextures()
Pointer Handling in Xojo
Xojo Support previously suggested that glGenTextures()
expects a pointer reference, so I modified the code as follows:
xojo
CopyEdit
If IgnisAI_Module.TextureID = 0 Then
Var texID(0) As Integer
glGenTextures(1, texID) '✅ Correctly passing a reference
IgnisAI_Module.TextureID = texID(0)
End If
Yet, Xojo still reports:
glGenTextures(1, texID) does not exist
Questions:
Q3: Is this the correct way to handle pointer passing in Xojo for
glGenTextures()
?
Q4: If not, what is the proper syntax for handling pointers in Xojo?
Issue #3: Calling DeclareOpenGLFunctions()
in Render()
Currently, I am calling:
xojo
CopyEdit
IgnisAI_Module.DeclareOpenGLFunctions()
However, Xojo reports:
"Int32" has no member named "DeclareOpenGLFunctions()"
Questions:
Q5: Is there a special way to call a module’s function inside
OpenGLSurface.Render
?
Q6: Does
DeclareOpenGLFunctions()
need to be re-called inside Render()
every time it runs?
Issue #4: SDK Function Issues (guide_get_temperature_data
, guide_measure_convertgray2rgb24
)
The following SDK functions are declared in DeclareSDKFunctions()
:
xojo
CopyEdit
Declare Function guide_get_temperature_data Lib "libMTbdSDK.dylib" (buffer As Ptr, size As Integer) As Integer
Declare Function guide_measure_convertgray2rgb24 Lib "libMTbdSDK.dylib" (pGray As Ptr, pRgb As Ptr, size As Integer, paletteIndex As Integer) As Integer
Yet, Xojo reports that these functions “do not exist” when called in GetTemperatureData()
and UpdateVideo()
.
Questions:
Q7: Does Xojo require a different way to declare external functions from
.dylib
(macOS) and .dll
(Windows)?
Q8: Should we use
ByRef
for Ptr
parameters to ensure compatibility?
Q9: Are there known issues with calling external functions from a dynamically linked library (.dylib/.dll) in Xojo?
Issue #5: OpenGL State Changes in Render()
Currently, OpenGL state changes (e.g., glEnable(GL_TEXTURE_2D)
) are called inside Render()
.
Questions:
Q10: Should OpenGL state changes be moved outside
Render()
, perhaps into the Window Opening event?
Q11: Does Xojo require
MakeCurrent()
before every OpenGL call?
Next Steps & Requested Support
I would greatly appreciate guidance from the Xojo community regarding:
- Proper function declaration for OpenGL and SDK calls.
- Whether
DeclareOpenGLFunctions()
must be re-called inRender()
. - The correct approach for handling OpenGL texture generation (
glGenTextures
pointer issue). - Best practices for declaring
.dylib
and.dll
functions in Xojo.
If anyone has encountered similar issues, please share your insights or potential fixes.
Your help would be invaluable in resolving these persistent errors.
Thank you in advance for your support!
Best regards,
Sinha
6 posts - 3 participants