PDA

View Full Version : Caussian Primes fun - WinTimer question



RobbeK
27-02-2014, 13:58
Hi all,

A quick animation using Gaussian Prime numbers.
(the Z value added is calculated on the number of members around a certain prime).
I rather would do this with a timer i.o. counting down the loops.

(I know there's an example in Petr's files , even under NEW - combining ui and tbgl -> RenderImage ) , but I wonder about the strict minimal way doing this.


best, Rob

Petr Schreiber
27-02-2014, 20:23
Hi Rob,

cool demo, as usually, thanks for sharing!

Here is minimalistic demo to give you idea on how to render in discrete time intervals. It is called "periodic" in TBGL.


'
' The most basic skeleton for TBGL periodic rendering
' Petr Schreiber, started on 02-27-2014
'

Uses "TBGL"

Function TBMain()
Local hWnd As DWord

' -- 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()

' -- We will set GameLoop function to be executed each 10ms
TBGL_PeriodicBindFunction( hWnd, "RenderImage", 10 )

' -- Once the command below is executed, further script execution
' -- is halted and only periodic calling of the bound function is performed
TBGL_PeriodicProcessFunction(hWnd)

TBGL_DestroyWindow
End Function

Function RenderImage()

Double FrameRate
DWord hWnd = TBGL_CallingWindow

FrameRate = TBGL_GetFrameRate

TBGL_ClearFrame

TBGL_Camera(3, 3, 3, 0, 0, 0)

TBGL_Color(255, 128, 0)
TBGL_Box(1, 1, 1)

TBGL_DrawFrame

' -- ESCAPE key to exit application
If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then TBGL_PeriodicUnBindFunction(hWnd)

End Function


Or do you need something even more... minimalistic? :)


Petr

RobbeK
27-02-2014, 21:28
Ah, thanks Petr,
I wasn't aware this was already inside the TBGL module -- yep, minimalistic enough ;-) (just what I needed).
(have to read the documentations more profoundly ;-(

I have to ask you something else ...
By any change do you have the gl and glu includes for PB somewhere ?? (or where to get ?) -- the José Roca site has stopped new registrations (needed for downloading things) .. everyone uses them, but no one seems to have a download link.

(i also have enormous troubles for JVM based languages concerning OpenGL ... probably my old computer, but somewhat frustrating that f.i. TBGL-TBasic works perfectly, Freebasic and GFA also do , but the other oversized languages like Racket (I'm used to Lisp/Scheme synthax ) deliver nothing but problems (Racket isn't JVM based) -- an executable producing plain vanilla window in Racket costs 8Mb ;-)

thanks for your (as usual) expert help !
Rob

Petr Schreiber
27-02-2014, 22:25
Hi Rob,

thanks for your kind words, but it is no challenge to be expert in API designed by... me :D

José's OpenGL headers are the best ones available, besides the original. They also use some PB specifics, so would need some adjustments.
I am not sure if José would be happy if I post them directly, I will ask him soon about it.

In the meantime, what about:


#INCLUDE "thinBasic_gl.inc"
#INCLUDE "thinBasic_glu.inc"
#INCLUDE "thinBasic_glext.inc"


ThinBASIC comes with these headers, maintained by me. They are extensive enough to cover most of the needs.
I did them as translation from original C headers by Khronos. They should cover OpenGL up to 2.1 for sure (so shaders included).
In case you would miss some functionality, I can add it.


Petr

RobbeK
28-02-2014, 00:01
Ah, thanks again .. i'll try these (I used those for MASM as an Ersatz, both they bail out on some definitions ).
No need to disturb José, I'm just toying a little with PB (as I do with GFA and FreeBasic).

.. the frustration ... trying picking up Pascal and Lisp again (after these years), all these things turned into mastodons , needing 100's of Mb's to be functional , there's something wrong withit (imo) .. I mean if the Racket exec size is 8Mb only to produce an empty form and the compilation needs several 10's of seconds, what is it doing and producing then ??? ;-)
(idem for Lazarus, the (free)Pascal RAD/GUI)

best Rob