Hi kryton9

using a C dll makes the calculations speedier

but there is a slow rendering with:

the fps for me is 5For y = 1 To height For x = 1 To width glColor4d 255, 255, 255, noise ( x, y ) * alphaScale TBGL_Vertex x, y Next Next

i have tried the Gbuffer using a template from some examples ,the graphics will be speedy , it is for me about 60. but i have a problem, there is something not correct

i replace your

with positional arrayFor y = 1 To height For x = 1 To width glColor4d 255, 255, 255, noise ( x, y ) * alphaScale TBGL_Vertex x, y Next Nextvertex(x,y)which are filled from 1-500, 1-500

the color and alpha for every vertex in another array :noise(x,y)

but i don't see the alpha working herenoiseNum = PerlinNoise xOff, yOff, 0 noise(x,y).r = 255 noise(x,y).g = 255 noise(x,y).b = 255 noise(x,y).A = noiseNum * alphaScale

Uses "TBGL" #INCLUDE "%APP_INCLUDEPATH%thinbasic_gl.inc" ' to use glColor4d function #INCLUDE "PerlinNoise.tbasici" Double yOff = 0.0 Double xOff = 0.0 Long interval = 0 Long width = 500 'larger the longer it takes to calculate Long height = 500 'larger the longer it takes to calculate Long x = 0 Long y = 0 Function TBMain() Local hWnd As DWord Local FrameRate As Double Long numPoints = width * height String winTitle = "Calculating " + numPoints + " Noise Values, This can take Some time." ' -- Create and show window hWnd = TBGL_CreateWindowEx ( "PerlinNoise 2D GL Demo", width, height, 32, %TBGL_WS_WINDOWED ) TBGL_ShowWindow TBGL_SetWindowTitle ( hWnd, winTitle) TBGL_ShowWindow Dim gbPoints As DWord = TBGL_GBufferCreate(%TBGL_POINTS, %TBGL_2D) ' -- Define data for it Global vertex(width,height) As TBGL_TVECTOR2F Global noise(width,height) As TBGL_TRGBA 'TBGL_TRGB Dim x,y As Integer Double noiseStep = 0.001 'good ranges : 0.1 to 0.00000000000000001 Double alphaScale = 5 ' ranges: 1 to 1000000000000 Double noiseNum For y=1 To width yOff += noiseStep For x=1 To height xOff += noiseStep vertex(x,y).x = x vertex(x,y).y = y noiseNum = PerlinNoise xOff, yOff, 0 noise(x,y).r = 255 noise(x,y).g = 255 noise(x,y).b = 255 noise(x,y).A = noiseNum * alphaScale Next Next Dim NumOfarrayElements As Long = CountOf(vertex(1))* CountOf(vertex(2)) ' -- Create buffer dynamically linked to the arrays above TBGL_GBufferDefineFromArray(gbPoints, %TBGL_STATIC, NumOfarrayElements, vertex(1,1), noise(1,1)) ' -- Resets status of all keys TBGL_ResetKeyState() TBGL_BlendFunc %GL_SRC_ALPHA , %GL_ONE TBGL_UseBlend %TRUE TBGL_RenderMatrix2D ( 1, height, width, 1 ) ' -- Main loop While TBGL_IsWindow(hWnd) FrameRate = TBGL_GetFrameRate Incr interval If interval > 5 Then TBGL_SetWindowTitle ( hWnd, "PerlinNoise 2D GL Demo FPS: " + Str$ ( FrameRate, 4 ) ) interval = 0 EndIf TBGL_ClearFrame ' -- Render it TBGL_RenderMatrix2D ( 1, height, width, 1 ) TBGL_GBufferRender(gbPoints) TBGL_DrawFrame ' -- ESCAPE key to exit application If TBGL_GetWindowKeyState(hWnd, %VK_ESCAPE) Then Exit While Wend ' -- Destroying the buffer is not necessary, ' -- the garbage collector will take care of it ' -- Destroy window TBGL_DestroyWindow End Function

## Bookmarks