Hi Stan,
no need to struggle with pointers, as the declaration is made to get the array by reference. So for the two lines, the TB code would look like:
glMultMatrixf(matrix) glGetFloatv(%GL_TEXTURE_MATRIX, matrix)
Petr
I worked on porting my FreeBasic OpenGL program over the weekend and became stuck on the following two lines in the chaptrack function:
glMultMatrixf @aff(0)
glGetFloatv GL_TEXTURE_MATRIX, @aff(0)
The aff() matrix is the affine matrix used in the rotations of the 3D figure. I use the GL_TEXTURE_MATRIX because it is handy and not being used for any other purpose
Anyway, I'm using a pointer to multiply the aff() matrix by the current transformation/rotation matrix and then storing the newly transformed matrix in GL_TEXTURE_MATRIX. Again, using pointers...
I am not certain how to do this using TBGL or raw OpenGL in thinBasic... I tried using varptr but obviously did not know what I was doing
Thanks for any "pointers" you might have,
Stan
Hi Stan,
no need to struggle with pointers, as the declaration is made to get the array by reference. So for the two lines, the TB code would look like:
glMultMatrixf(matrix) glGetFloatv(%GL_TEXTURE_MATRIX, matrix)
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
I prefer the byref approach over pointers (less typing, same effect), that's why headers are translated this way.
If you are unsure about parameters, you can always check the headers in the ThinBASIC/Inc directory or ask here of course!
We had a few iterations of the headers until we found current state, originally there were the pointers everywhere, but I think the current way is more user friendly (once you know BYREF is there ).
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
I agree... ByRef is much simpler than trying to use pointers (for me, anyway). Sending the matrix name (ByRef) worked!
Another question:
What is the TBGL equivalent of the glutIdle() function? Is that your "while TBGL_IsWindow" function?
I use glutIdle() in the program I'm trying to port... just curious.
Thank,
Stan
Hi Stan,
it's up to you how you structure code in TBGL, the endless loop is just one approach possible.
The another could be to use the periodic function and base the organization on that.
Here minimal example, hWnd and FrameRate are passed to idle and input functions just in case you would like to use it, but it is not necessary of course.
Uses "TBGL" Global angle As Double Function TBMain() Local hWnd As DWord Local FrameRate As Double ' -- Create and show window hWnd = TBGL_CreateWindowEx("TBGL script - press ESC to quit", 640, 480, 32, %TBGL_WS_WINDOWED Or %TBGL_WS_CLOSEBOX) TBGL_ShowWindow ' -- Initialize lighting TBGL_UseLighting(%TRUE) TBGL_UseLightSource(%GL_LIGHT0, %TRUE) TBGL_SetLightParameter(%GL_LIGHT0, %TBGL_LIGHT_POSITION, 15, 10, 15, 1) ' -- Resets status of all keys TBGL_ResetKeyState() TBGL_BindPeriodicFunction( hWnd, "funRender", 10 ) TBGL_ProcessPeriodicFunction(hWnd) TBGL_DestroyWindow End Function ' -- Do any calculations here Function funIdle( hWnd As DWord, frameRate As Double ) angle += 90/FrameRate End Function ' -- Handle input here Function funInput( hWnd As DWord, frameRate As Double ) If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then TBGL_UnBindPeriodicFunction(hWnd) Exit Function End If End Function Function funRender() Dim hWnd As DWord = TBGL_CallingWindow Dim FrameRate As Double frameRate = TBGL_GetFrameRate ' -- Process input funIdle( hWnd, FrameRate) ' -- Process calculations funInput( hWnd, FrameRate ) FrameRate = TBGL_GetFrameRate TBGL_ClearFrame TBGL_Camera(15, 15, 15, 0, 0, 0) TBGL_Rotate(angle,0,1,0) TBGL_Color(255, 128, 0) TBGL_Box(1, 1, 1) TBGL_DrawFrame End Function
Petr
Learn 3D graphics with ThinBASIC, learn TBGL!
Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB
Bookmarks