Quantcast
Channel: Xojo Programming Forum - Latest topics
Viewing all articles
Browse latest Browse all 3755

OpenGL Functions Not Recognized in Xojo – Help Needed

$
0
0

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.


:small_blue_diamond: 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:

:white_check_mark: Q1: Is there a known issue with OpenGL function declarations in Xojo that could cause this?
:white_check_mark: Q2: Should these OpenGL functions be declared differently in Xojo (specific syntax, scope, or calling convention adjustments)?


:small_blue_diamond: 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:
:x: glGenTextures(1, texID) does not exist

Questions:

:white_check_mark: Q3: Is this the correct way to handle pointer passing in Xojo for glGenTextures()?
:white_check_mark: Q4: If not, what is the proper syntax for handling pointers in Xojo?


:small_blue_diamond: Issue #3: Calling DeclareOpenGLFunctions() in Render()

Currently, I am calling:

xojo

CopyEdit

IgnisAI_Module.DeclareOpenGLFunctions()

However, Xojo reports:
:x: "Int32" has no member named "DeclareOpenGLFunctions()"

Questions:

:white_check_mark: Q5: Is there a special way to call a module’s function inside OpenGLSurface.Render?
:white_check_mark: Q6: Does DeclareOpenGLFunctions() need to be re-called inside Render() every time it runs?


:small_blue_diamond: 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:

:white_check_mark: Q7: Does Xojo require a different way to declare external functions from .dylib (macOS) and .dll (Windows)?
:white_check_mark: Q8: Should we use ByRef for Ptr parameters to ensure compatibility?
:white_check_mark: Q9: Are there known issues with calling external functions from a dynamically linked library (.dylib/.dll) in Xojo?


:small_blue_diamond: Issue #5: OpenGL State Changes in Render()

Currently, OpenGL state changes (e.g., glEnable(GL_TEXTURE_2D)) are called inside Render().

Questions:

:white_check_mark: Q10: Should OpenGL state changes be moved outside Render(), perhaps into the Window Opening event?
:white_check_mark: Q11: Does Xojo require MakeCurrent() before every OpenGL call?


:pushpin: 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 in Render().
  • 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

Read full topic


Viewing all articles
Browse latest Browse all 3755

Trending Articles