In this documents we can see that the old property “Handle” is now “ContextHandle” and it is an integer.
But when I use it in code “ContextHandle” is a Pointer, not an integer!
Up to now I had used Control(OpenGLSurface).Handle which was an Integer without problems.
I need to use the Handle in a Declare. Which value have I to use?
OpenGLSurface (deprecated) and DesktopGLSurface both have a ‘ContextHandle’ property of type integer. Means ContextHandle’s type should be an integer, not a pointer.
I did not check in the IDE, but if ContextHandle’s type now is a pointer, I would consider it being a bug, at least an inconsistency between IDE and documentation.
Handles and pointers are not the same (ref. Wikipedia)
In Xojo, the term ‘handle’ is used for both handles and pointers: DesktopControl property ‘Handle’ of type ‘ptr’
Var j As Ptr = OpenGl_Surface.ContextHandle
Var k As Ptr = DesktopControl(OpenGl_Surface).Handle
break
before the code
#If TargetWindows Then
and I get two different pointers. Is it normal?
Anyway, when I try to convert these pointers to an integer (Var kk As Integer = k.Integer(0)) the application crashes.
According to the documentation:
Notes
A Ptr is 4 bytes for 32-bit apps and 8 bytes for 64-bit apps.
You can compare one Ptr to another Ptr or to Nil.
You can convert the value referenced to by the pointer to a specific data type using the available methods.
You can convert the value referenced to by the pointer to a specific datatype using the Pointer Properties: Boolean, Byte, CFStringRef, Class, Color, CString, Currency, Double, Int16, Int32, Int64, Int8, Integer, Object, Ptr, Short, Single, String, UInt16, UInt32, UInt64, UInt8, Variant, WindowPtr, WString
and I obtain two Integers (65536 and 3807270), but I don’t know which one to use.
Of course I can try both and see what happens, but I’d like to understand it.
Can you help me?
Although there is an error of variable type (ContextHandle is a Ptr, not an Integer) it seems that the pointer is to an “underlying OpenGL context”. I have no idea what it means, but it seems that the “underlying context” is not the “handle”.
That’s what I think, but obviously I am not sure at all.
A context in Opengl is a pointer. Opengl is given numbers and the context provides the meaning behind the numbers, which is referenced as a pointer.
An example would be: here are the numbers 4,6, and 9. Opengl context places a meaning to these numbers. Without context, these numbers could mean colour, position, vector, light, etc. All opengl commands pass through the Opengl context.
The pointer to Opengl needs to be known by the window that draws Opengl.
If you are using glfw then you can use the command getcurrentcontext (I think that’s the name, I am not at my development computer)
One of them is the underlying OS control for the OpenGL “View” and one is the OpenGL contents.
At least this is how it works on the Mac. So if you need to customize the control, you use the control.handle property, but if you want to alter the OpenGL content, you use t’other one.
The TextArea on the macOS is also two parts, one if for the scroll view of the text content and t’other is for the text content.