PDA

View Full Version : New in next thinBasic (again :) )



ErosOlmi
25-08-2008, 15:45
Again some new things you will find in next thinBasic version.
TBGL power in a window control.

Please let us know if all is working fine.

Ciao
Eros

Updates

updated bundled exe with new TBGL module
fixed a problem occurring on some Intel graphic card drivers


Here the code preview of the attached executable.
Looking at the source code you can get an idea new TBGL control and dialog/controls callbacks functions.
Also note the new entry point function TBMain that will act like what "main" function is in C language.



'#MINVERSION 1.7.0.0

uses "TBGL", "UI"

global hCtrl as dword
global ExitProgram as long
global TBGL_TestFunction as string


' -- ID numbers of controls
Begin Const
%btnClose = 1000
%btnCanvasOn
%btnCanvasOff

%btn_test01
%btn_test02
%btn_test03

%gCanvas

%IDC_TIMER = 100
%TIMER_DELAY = 1 ' Timer delay (in milliseconds, not very accurate below about 100)
End Const

'------------------------------------------------------------
' Main function
'------------------------------------------------------------
function TBMAIN() as long

dim hDlg AS DWORD

DIALOG New 0, "Control test", 100, 100, 625, 390, _
%WS_POPUP Or %WS_VISIBLE Or _
%WS_CLIPCHILDREN Or %WS_CAPTION OR _
%WS_SYSMENU Or %WS_MINIMIZEBOX or %WS_THICKFRAME, 0 To hDlg
' -- Place controls here
hCtrl = CONTROL ADD label, hDlg, %gCanvas, "This is label control, press ON to use this label as TBGL canvas", 5, 5, 510, 380
control set color hDlg, %gCanvas, %YELLOW, %BLACK

CONTROL ADD BUTTON, hDlg, %btnCanvasOn , "On" , 520, 5, 100, 30,,, call CanvasButton
CONTROL ADD BUTTON, hDlg, %btnCanvasOff , "Off" , 520, 35, 100, 30,,, call CanvasButton

CONTROL ADD BUTTON, hDlg, %btn_test01 , "TBGL Test 1" , 520, 100, 100, 30,,, call cbChangeTest
CONTROL ADD BUTTON, hDlg, %btn_test02 , "TBGL Test 2" , 520, 130, 100, 30,,, call cbChangeTest
CONTROL ADD BUTTON, hDlg, %btn_test03 , "TBGL Test 3" , 520, 160, 100, 30,,, call cbChangeTest

CONTROL ADD BUTTON, hDlg, %btnClose , "Click to close", 520, 355, 100, 30,,, call CloseButton

' -- Set anchors
CONTROL Set RESIZE hDlg, %btnClose , 0, 1, 0, 1
CONTROL Set RESIZE hDlg, %btnCanvasOn , 0, 1, 1, 0
CONTROL Set RESIZE hDlg, %btnCanvasOff, 0, 1, 1, 0
CONTROL Set RESIZE hDlg, %gCanvas , 1, 1, 1, 1

CONTROL disable hDlg, %btnCanvasOff

CONTROL disable hDlg, %btn_test01, %btn_test02, %btn_test03

CONTROL Set RESIZE hDlg, %btn_test01 , 0, 1, 1, 0
CONTROL Set RESIZE hDlg, %btn_test02 , 0, 1, 1, 0
CONTROL Set RESIZE hDlg, %btn_test03 , 0, 1, 1, 0

dialog set minsize hDlg, 500, 400

TBGL_TestFunction = "Render_01"

DIALOG SHOW MODal hDlg, call DlgProc

End Function

'------------------------------------------------------------
' Callback function for main window
'------------------------------------------------------------
callback function DlgProc() as long
select case cbmsg

case %WM_CREATE

case %WM_INITDIALOG
dialog Set Timer cbhndl, %IDC_TIMER, %TIMER_DELAY

case %WM_SIZE
TBGL_UpdateCanvasProportions(hCtrl)
call TBGL_TestFunction

case %WM_SIZING
TBGL_UpdateCanvasProportions(hCtrl)
call TBGL_TestFunction

case %WM_TIMER
'---Dynamically call a function whose name is composed at run-time
'---In this case function name to be executed is inside TBGL_TestFunction string variable
call TBGL_TestFunction

case %WM_DESTROY
if TBGL_CanvasBound(hCtrl) then TBGL_ReleaseCanvas(hCtrl)
dialog Kill Timer cbhndl, %IDC_TIMER

end select
end function

'------------------------------------------------------------
' Callback function handling Close button
'------------------------------------------------------------
callback function CloseButton() as long

if CBMSG = %WM_COMMAND then
if cbctlmsg = %BN_CLICKED then DIALOG End cbhndl
end if

end function

'------------------------------------------------------------
' Callback function handling Canvas activation/deactivation
'------------------------------------------------------------
callback function CanvasButton() as long

if CBMSG = %WM_COMMAND then
if cbctlmsg = %BN_CLICKED then
select case cbctl
case %btnCanvasOn
TBGL_TestFunction = "Render_01"
CONTROL disable cbhndl, %btnCanvasOn
TBGL_BindCanvas(hCtrl)

CONTROL enable cbhndl, %btnCanvasOff, %btn_test02, %btn_test03

case %btnCanvasOff
CONTROL disable cbhndl, %btnCanvasOff

TBGL_ReleaseCanvas(hCtrl)

CONTROL disable cbhndl, %btn_test01, %btn_test02, %btn_test03

CONTROL enable cbhndl, %btnCanvasOn

end select
end if
end if

end function

'------------------------------------------------------------
' Callback function handling test type
'------------------------------------------------------------
callback function cbChangeTest() as long

if CBMSG = %WM_COMMAND then
if cbctlmsg = %BN_CLICKED then
select case cbctl
case %btn_test01
CONTROL disable cbhndl, %btn_test01
CONTROL enable cbhndl, %btn_test02, %btn_test03

TBGL_TestFunction = "Render_01"
TBGL_ReleaseCanvas(hCtrl)
TBGL_BindCanvas(hCtrl)
case %btn_test02
CONTROL disable cbhndl, %btn_test02
CONTROL enable cbhndl, %btn_test01, %btn_test03

TBGL_TestFunction = "Render_02"
TBGL_ReleaseCanvas(hCtrl)
TBGL_BindCanvas(hCtrl)
case %btn_test03
CONTROL disable cbhndl, %btn_test03
CONTROL enable cbhndl, %btn_test01, %btn_test02

TBGL_TestFunction = "Render_03"
TBGL_ReleaseCanvas(hCtrl)
TBGL_BindCanvas(hCtrl)

end select
end if
end if

end function

'------------------------------------------------------------
' TBGL render function 1
'------------------------------------------------------------
function Render_01() as long
static x, y, z as double
Static BoxColor as long
TBGL_UseLighting %TRUE
TBGL_UseLightSource %GL_LIGHT0, %TRUE

'TBGL_COLOR 255, 255, 255
if tbgl_GetwindowKeyState(hCtrl, %VK_R) then TBGL_COLOR 255,0,0
if tbgl_GetwindowKeyState(hCtrl, %VK_G) then TBGL_COLOR 0,255,0
if tbgl_GetwindowKeyState(hCtrl, %VK_B) then TBGL_COLOR 0,0,255

TBGL_ClearFrame

tbgl_Camera 0,0,5,0,0,0

tbgl_Rotate GetTickCount/100,1,1,1
tbgl_Box 1,1,1

tbgl_GetPixelInfo tbgl_MouseGetPosX, tbgl_MouseGetPosy, %TBGL_PINFO_XYZ, x, y, z
tbgl_Translate x,y,z
tbgl_Sphere 0.1
TBGL_DrawFrame

end function


'------------------------------------------------------------
' TBGL render function 2
'------------------------------------------------------------
function Render_02() as long
static i, j as long
TBGL_COLOR 255, 255, 255
TBGL_UseLighting %TRUE
TBGL_UseLightSource %GL_LIGHT0, %TRUE


' -- Erases previous frame
tbgl_ClearFrame

' -- Sets camera to look from 3,3,3 to 0,-1,0
tbgl_Camera 3, 3, 3, _
0, 0, 0

' -- All following geometry will be rotated around vector 0,1,0
' -- That is - Y axis
tbgl_Rotate gettickcount/100, 0, 1, 0

' -- Now we will try to render kind of spider
' -- It has ...

' .. One big head
tbgl_Color 255,196,0
tbgl_Sphere 0.25

' .. And eight legs
' .. We will draw them each 60°
for i = 0 to 359 step 45
tbgl_PushMatrix
tbgl_Rotate i, 0, 1, 0 ' 60, 120, 180, ...

' -- Legs will raise from bottom of head
tbgl_Translate 0, -0.25, 0

' -- With 3 part tentacle
tbgl_PushMatrix
for j = 1 to 3
tbgl_Color 255/j, 128/j, 0

' -- Some harmonic rotations will be provided by Sinus
tbgl_Rotate 70+sin(GetTickCount/1000+i+j)*20, 1, 0, 0

' -- Each tentacle part will be shorter and thinner than that before
tbgl_Cylinder ( 0.1/j, 0.1/(j+1), 1/j )
' -- When drawn, we need to move "cursor" at its end to bind new part
tbgl_Translate 0, 1/j, 0
next
tbgl_PopMatrix

tbgl_PopMatrix
next


' -- Finishes drawing
tbgl_DrawFrame

end function


'------------------------------------------------------------
' TBGL render function 3
'------------------------------------------------------------
function Render_03() as long
' Rotation Variable
static angle as single

' Timing Variables
static FrameRate as number

FrameRate = tbgl_GetFrameRate
tbgl_clearframe ' Clear Screen
tbgl_resetmatrix ' Reset the Current Matrix
tbgl_camera 0, 0, 1, 0, 0, 0 ' Default Camera Position

tbgl_translate 0, 0, -4 ' Move Pyramid to Centre of Screen
tbgl_rotate angle, 0.0, 1.0, 0.0 ' Rotation Setup

drawPyramid()

tbgl_drawframe ' Swap the Drawing Buffers

angle += 180.0/FrameRate

end function

'------------------------------------------------------------
' TBGL support to render function 3
'------------------------------------------------------------
sub drawPyramid()

tbgl_beginpoly %GL_TRIANGLE_FAN
tbgl_color 0, 128, 255 : tbgl_vertex 0.0, 1.0, 0.0
tbgl_color 255, 0, 0 : tbgl_vertex -1.0, -1.0, 1.0
tbgl_color 255, 255, 255 : tbgl_vertex 1.0, -1.0, 1.0
tbgl_color 0, 0, 255 : tbgl_vertex 1.0, -1.0, -1.0
tbgl_color 0, 255, 0 : tbgl_vertex -1.0, -1.0, -1.0
tbgl_color 255, 0, 0 : tbgl_vertex -1.0, -1.0, 1.0
tbgl_endpoly

end sub

catventure
25-08-2008, 16:39
Hi,

Animation works first time - but if I click "off" button then "on" again - thinbasic crashes.
Also if I select any of other buttons while anim is playing "TBGL test 1, 2 and 3" it also crashes.
I can resize window OK
Vista
catventure.

ErosOlmi
25-08-2008, 16:42
Thanks a lot catventure.
I will talk with Petr about that. Seems a reset not working.

Petr Schreiber
25-08-2008, 17:53
<jumped out of sea of tears>

Thanks Catventure,

we need such a tests, even negative in results. Will find the reason.


Petr

matthew
25-08-2008, 18:55
It worked fine here. I was able to turn it 'Off & On', select the different effects & resize the window.

It didn't crash once & I'm using Vista too. :P

ErosOlmi
25-08-2008, 19:28
Before posting I made tests under Win98, WinMe, Win2K, WinXP and Vista Business.
All tests were fine.

Anyway this doesn't mean there are no bugs. Every OS has different configurations (hardware and software) so those preview are just precious for us to be sure we are going into the right direction. Petr and I will check what are the possible causes of catventure GPF.

@catventure
One thing can help a little further. When there is a GPF usually it reports the module (the dll) where the GPF occurred. Can you see if you can find this info?
It can be one of those: thinCore.dll, thinBasic_UI.dll, thinBasic_TBGL.dll

Thanks a lot
Eros

Petr Schreiber
25-08-2008, 19:32
I recoded TBGL deinitializaton and sent DLL to Eros,

re-bundled version should appear soon.
In some situations it was possible the deallocation of resources could occur twice.

Thanks a lot for the test Matthew!


Petr

ErosOlmi
25-08-2008, 19:34
Updated bundled exe in first post of this thread.
Waiting for catventure tests ... :)

catventure
25-08-2008, 20:13
Hi,

Same problems occur. Am using Windows Vista Home Basic.
The Close Button works OK though.

After the attached msgbox appears, another appears asks me if I want to close the program.

catventure.

catventure
25-08-2008, 20:28
Here's the info from the problem report:

Problem signature
Problem Event Name: APPCRASH
Application Name: ThinBasic.exe
Application Version: 1.7.0.0
Application Timestamp: 00003039
Fault Module Name: ig4dev32.dll
Fault Module Version: 7.14.10.1461
Fault Module Timestamp: 47e9296a
Exception Code: c0000005
Exception Offset: 00002a00
OS Version: 6.0.6001.2.1.0.768.2
Locale ID: 2057
Additional Information 1: 5b73
Additional Information 2: 7483b78abe8cc4c9e5260c4806be0def
Additional Information 3: 7124
Additional Information 4: f20548daae1bf9485a8dab4a3b8256ed

Extra information about the problem
Bucket ID: 900638912

catventure

ErosOlmi
25-08-2008, 20:30
Thanks. Interesting:
"ig4dev32.dll is a OpenGL belonging to Intel Graphics Accelerator Drivers for Windows Vista(R) from Intel Corporation"

ErosOlmi
25-08-2008, 20:34
Reading from another forum problems with ig4dev32.dll and Intel cards:


... the only thing that seems to have worked is by going to my Control Panel and clicking on the Intel GMA Driver and changing the 3D settings - Depth Buffer Bit Depth from Default to 16-bit Depth Buffer.

Petr Schreiber
25-08-2008, 20:36
Intel, Intel,

you are my nightmare.
So problem is in TBGL or driver.

I just ran TBGL with messagebox popping values glGetError, PB error and GetLastError through all important places in module.
And no problem ???

I will try our home Intel on WinXP, will see if I can replicate fail.

Eros, thanks a lot, but TBGL I sent you uses 16bit Z-Buffer, so this should not be problem - even if it would be the case, it would crash on first run.


Thanks,
Petr

catventure
25-08-2008, 20:43
Reading from another forum problems with ig4dev32.dll and Intel cards:


... the only thing that seems to have worked is by going to my Control Panel and clicking on the Intel GMA Driver and changing the 3D settings - Depth Buffer Bit Depth from Default to 16-bit Depth Buffer.


Hi,

Tried this but same problem persists,

catventure

Petr Schreiber
25-08-2008, 20:45
Hi,

I tested on my precious Intel and no problem at all.
Catventure, last chance - could you please download OpenGL_GetInfo.tbasic from here (http://community.thinbasic.com/index.php?topic=668.0).

It is very simple tool which will tell us whether you have correctly installed OpenGL driver. I presume yes, but just to make me sure.

As I said, I tried on WinXP and onboard Intel, and no problem occured even when I clicked buttons like mad pianist.


Petr

P.S. Does following GPF your PC as well ( windows creation and destruction is there 2x intentionally )?


uses "tbgl"

Dim hWnd As Dword = TBGL_CreateWindowEx("Dummy", 800, 600, 32, %TBGL_WS_WINDOWED or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow

tbgl_DestroyWindow

hWnd = TBGL_CreateWindowEx("Dummy", 800, 600, 32, %TBGL_WS_WINDOWED or %TBGL_WS_CLOSEBOX)
TBGL_ShowWindow

tbgl_DestroyWindow

catventure
25-08-2008, 20:53
Hi Petr,

It is correctly installed:

Vendor: INTEL
Renderer: INTEL 945G
OpenGL: 1.4.0 - BUILD 7.14.10.1461
Extensions( 49 ):
GL_ARB_DEPTH_TEXTURE
GL_ARB_FRAGMENT_PROGRAM
GL_ARB_MULTITEXTURE
GL_ARB_POINT_PARAMETERS
GL_ARB_SHADOW
GL_ARB_TEXTURE_BORDER_CLAMP
GL_ARB_TEXTURE_COMPRESSION
GL_ARB_TEXTURE_CUBE_MAP
GL_ARB_TEXTURE_ENV_ADD
GL_ARB_TEXTURE_ENV_COMBINE
GL_ARB_TEXTURE_ENV_DOT3
GL_ARB_TEXTURE_ENV_CROSSBAR
GL_ARB_TRANSPOSE_MATRIX
GL_ARB_VERTEX_BUFFER_OBJECT
GL_ARB_VERTEX_PROGRAM
GL_ARB_WINDOW_POS
GL_EXT_ABGR
GL_EXT_BGRA
GL_EXT_BLEND_COLOR
GL_EXT_BLEND_FUNC_SEPARATE
GL_EXT_BLEND_MINMAX
GL_EXT_BLEND_SUBTRACT
GL_EXT_CLIP_VOLUME_HINT
GL_EXT_COMPILED_VERTEX_ARRAY
GL_EXT_CULL_VERTEX
GL_EXT_DRAW_RANGE_ELEMENTS
GL_EXT_FOG_COORD
GL_EXT_MULTI_DRAW_ARRAYS
GL_EXT_PACKED_PIXELS
GL_EXT_RESCALE_NORMAL
GL_EXT_SECONDARY_COLOR
GL_EXT_SEPARATE_SPECULAR_COLOR
GL_EXT_SHADOW_FUNCS
GL_EXT_STENCIL_TWO_SIDE
GL_EXT_STENCIL_WRAP
GL_EXT_TEXTURE_COMPRESSION_S3TC
GL_EXT_TEXTURE_ENV_ADD
GL_EXT_TEXTURE_ENV_COMBINE
GL_EXT_TEXTURE_LOD_BIAS
GL_EXT_TEXTURE_FILTER_ANISOTROPIC
GL_EXT_TEXTURE3D
GL_3DFX_TEXTURE_COMPRESSION_FXT1
GL_IBM_TEXTURE_MIRRORED_REPEAT
GL_NV_BLEND_SQUARE
GL_NV_TEXGEN_REFLECTION
GL_SGIS_GENERATE_MIPMAP
GL_SGIS_TEXTURE_EDGE_CLAMP
GL_SGIS_TEXTURE_LOD
GL_WIN_SWAP_HINT

The code you posted works OK too and does not crash thinbasic.

Regards,
catventure.

ErosOlmi
25-08-2008, 21:03
http://www.intel.com/support/graphics/intel945gm/
_________________________________________________

Catventure, are you on a mobile? If yes, it seems the latest driver version for Vista is 7.14.10.1504 while you have 7.14.10.1461
Maybe you can make an update but do not know ... I'm always scared when I need to upgrade graphic drivers. So up to you.
If you are on a mobile computer, maybe the constructor has more specific graphic drivers.

Ciao
Eros

Petr Schreiber
25-08-2008, 21:10
Thanks,

I know I am annoying already, but could you please run the attached EXE and see when it goes down?


Petr

ATTACHEMENT REMOVED

catventure
25-08-2008, 21:22
Hi Petr,

It works right up to when the white circle(? what happened to the square) appears fixed under the mouse pointer... The animated totating square does not appear!?
But if I click one of the TBGL buttons it will crash as before.

@eros: No. not on mobile and check for updates every day.

catventure

matthew
25-08-2008, 21:26
I should say that 2 Weeks ago I updated the Driver for my Intel Card in my Vista Laptop.

I'm running the 965 Express Chipset v7.15.10.1472.

The Debug version that Petr uploaded works fine too.

Petr Schreiber
25-08-2008, 21:41
Hi guys,

thanks. Yes it is possible display is screwed in debug version.
I prepared latest debug version ... without annoying msgboxes and more helpful output.

Catventure, as Matthew has no problem with Vista + same card + newer drivers ... do you think you could try them? :-[
If you do not want to make this step, I understand - driver change can be tricky. But it would help.


Thanks,
Petr

P.S. Now I see Matthews card has slightly different number.

ATTACHEMENT REMOVED, problem solved ;)

catventure
25-08-2008, 21:55
Hi Petr,

I don't know what you did - but it works perfectly now with the debug window.
I get the square, spider-thing and triangle!!!
Very nice.

But what did you change? Maybe a timer problem?

catventure

PS. Tried downloading latest Intel 82945G Express Chipset Graphic controller - but Windows wouldn't let me install it for some reason. I usually get these updates using "Windows Update" and I check this every day... so I am bit worried about installing different way..

Petr Schreiber
25-08-2008, 21:58
LOL :D

That is fantastic!

I did changes only inside TBGL. I removed one statement, which swapped buffers right after getting handle of device but before OpenGL initialization, I read it is necessary but seems it is not :D

Great - Eros, Matthew, Catventure - that was perfect colaboration. Thanks a lot!


Petr

ErosOlmi
25-08-2008, 22:01
Yes, this thread show a great team collaboration.
It is fantastic when working in this way.
Thanks to all.

Michael Hartlef
25-08-2008, 22:10
Hi Petr,

great job. Runs perfect on my windows machine.

Michael

Petr Schreiber
25-08-2008, 22:12
Hi Mike,

thanks for the test :)
Uff uff - sometimes the most serious problems have very easy solution!
Hope new TBGL control will serve well once out ( soon ! )


Petr

ErosOlmi
25-08-2008, 22:15
Problem seems fixed.
Updated attached file in first post of this thread with latest updated TBGL module.

Thanks to all.
Eros

ErosOlmi
26-08-2008, 01:21
I've updated again first post now adding a preview of the source code of the attached example.
Looking at the source code you can get an idea new TBGL control and dialog/controls callbacks functions.
Also note the new entry point function TBMain that will act like what "main" function is in C language.

Eros