View Full Version : OpenGl2D Library
Hi Eros,
I would like know whether it works for you without any crash !
At the moment, I got the stable version 1.8.9.0.
This version runs fine for me and I got not any crashes here!
Everything runs as planed. I don't hope that you tell me something about creepy stories like CRASHES!.
There is a question:
In a Sub or Function, will not run STATIC variable AS SINGLE?
Is it a wrong syntax or isn't it doable?
This would reduce my declared variables, when they are in a Sub or Function.
Okay, try once this OpenGl2D Library and tell me what you think.
It isn't yet completely, I am working hard on it.
ReneMiner
10-04-2013, 22:43
I downloaded and tried example. sometimes window stays white (very often) no picture, sometimes small boy in top left corner visible on white and sometimes on black background. Sometimes does not even start. Especially after run once - Restarting thinAir - then starts at first attemp but mostly window white. Second time won't start... have to click the "Execute Script"-Button a few times until runs again after first run thinAir does not start it on F5-key anymore...
Sorry, I forgot the Maps!
Another Demo.
#INCLUDE "gl.inc"
NewWindow 640,480,1
Long p1, fo
p1 = LoadImage "bmp/huhu.bmp",0
fo = LoadFont "fonts/font2.bmp"
While Key(27)=0
ClsColor 0,25,255
SetText fo,200,40,"HELLO",32,32
Texture p1,40,10,0
Sync
Wend
Quit
ErosOlmi
11-04-2013, 07:35
Ciao Peter,
thanks a lot for this new lib and examples !!
The game is running fine and all seems perfect except at the end when the script ends.
There is a GPF at the end during QUIT or maybe just after QUIT.
I will double check again to see if I do something wrong when unloading external libs but it seems GPF is inside gl.dll library
Ciao
Eros
8179
Thanks Eros,
This is what the Quit Function is doing.
I removed ReleaseDC, which could be a handicap!
Sub Quit()
wglMakeCurrent hdc, 0
wglDeleteContext hRC
glDeleteTextures 256, sData
glDeleteTextures 256, Tiles
glDeleteTextures 128, Fonts
DestroyWindow hwnd
End Sub
Charles Pegge
11-04-2013, 14:02
The GPF could be an Oxygen problem, if Peter is using a compiler version prior to 15 March. I isolated the DLL termination bug while testing a new thinBasic_Oxygen module (compiled with O2). It was caused by premature release of memory holding lists of DLLs.
Charles
Petr Schreiber
11-04-2013, 14:35
Hi Peter,
looking at the exit code - you first release OpenGL context, and then command OpenGL to release resources (textures/lists/...).
I think it should be done in reversed order - first free the resources and then release OpenGL subsytem as such.
Also the call to wglMakeCurrent here is a bit nonstandard, according to OpenGL Wiki the shutdown sequence should look like this in WM_CLOSE handling:
' -- Release resources before canceling context to avoid possible leaks or GPFs
glDeleteTextures 256, sData
glDeleteTextures 256, Tiles
glDeleteTextures 128, Fonts
wglMakeCurrent 0, 0 ' -- To make the GL context non-current
wglDeleteContext hRC ' -- To destroy the GL context
ReleaseDC hWnd, hDC ' -- This is needed if you previously received hDC via GetDC or GetWindowDC
Petr
Yes, is a 11.08.12 version.
The problem is ,that a newer version doesn't work correctly.
If I start an application with this DLL, then I get the after effect message in a message box " gl.dll "
This means: there isn't a DLLl!
Why has OxygenBasic gl2D.dll version no problem. It runs as oiled!
No GPF at all, not any crashes! everything runs fine.
Hi Eros,
Here is an addition for Gl2D library.
It seems that ThinBasic has a bug when I end an application.
Uses "ui"
#INCLUDE "bass.inc"
DWord hdc,hwin
hwin=Canvas_Window("Music",1,1,640,480)
Canvas_Attach(hwin,0,%TRUE)
Canvas_Font("verdana",16,%CANVAS_FONTSTYLE_BOLD)
Canvas_Clear(Rgb(0,0,255))
InitBass
Long music
music = LoadMusic "sound/b.mod"
PlayMusic music
SetText 100,100,"Hit Space Bar",&hffffff,Rgb(0,0,255)
SetText 100,140,"Playing Chip Tune",&hffffff,Rgb(0,0,255)
Canvas_Redraw
While IsWindow(hwin)
If GetAsyncKeyState(32) Then Exit While
Wend
Sleep 500
FreeMusic music
music = LoadMusic "sound/ttl.xm"
PlayMusic music
SetText 100,100,"Hit Space Bar",&hffffff,Rgb(0,0,255)
SetText 100,140,"Playing Through the Light",&hffffff,Rgb(0,0,255)
Canvas_Redraw
While IsWindow(hwin)
If GetAsyncKeyState(32) Then Exit While
Wend
FreeBass
Canvas_Window End
Sub SetText(x,y As Long, txt As String, fcol,bcol As Long)
Canvas_Color(fcol,bcol)
Canvas_SetPos(x,y)
Canvas_Print(txt)
End Sub
Hi petr,
Your method may be for Aliens, but not for OxygenBasic!:D
Look at the image!
I get not any memory leaks at all !
Petr Schreiber
11-04-2013, 23:27
Hi Peter,
I use the same method in TBGL since 2005 and it does not explode nor attracts aliens to land on our planet*
Petr
*I cannot guarantee there is no correlation between UFO sightings and TBGL scripts shutdowns, but I am quite sure about it
Charles Pegge
11-04-2013, 23:39
The DLL bug onlly shows itself under specific conditions, which made it particularly long-lived and not so easy to catch. It is not a memory leak but a memory disallocation.
Unfortunately for us developers, the fact that a program appears to work, is not proof of correctness.
Charles
Hi Charles,
Don't worry, ThinBasic caused this problem.
ThinBasic cannot handle with Aliens Dll's. That is fact!
According to the Function "QUIT", ThinBasic doesn't know what it should do, it thinks that is ordinary ThinBasic programm and does its steps as ever.
It is always easy to blame others. :D
ReneMiner
12-04-2013, 11:28
...It is always easy to blame others...
sure. It's - of course - a thinBasic-problem but none of your works :lol:
ErosOlmi
15-04-2013, 00:34
Peter,
I never make a post saying it crash just for criticize.
I really would like to understand what is causing the GPF. If the problem is thinBasic side, I will be happy say it is thinBasic side and I will be happy to work on it and solve it.
The example you made on using BASS library is something I cannot test because you didn't attach BASS.INC and the BASS.DLL library you used.
If you will attach complete working example I will be happy to work and see what is going on.
Thanks
Eros
ErosOlmi
15-04-2013, 01:02
Thanks Eros,
This is what the Quit Function is doing.
I removed ReleaseDC, which could be a handicap!
Sub Quit()
wglMakeCurrent hdc, 0
wglDeleteContext hRC
glDeleteTextures 256, sData
glDeleteTextures 256, Tiles
glDeleteTextures 128, Fonts
DestroyWindow hwnd
End Sub
Quit like is described above, is not really a function but a Sub. Inside "gl.inc" it is defined as a Function.
If it does not return any value maybe this can explain something.
Thanks Eros,
It is Function, I wrote it here as Sub routine!
Is okay, seems that the newer Oxyen RTL.inc doesn't works correctly.
I took an older version and my gl2D ran fine without crashes. But unfortunately has it an antipathy against Windows Vista and WindowsXP. Both of them get only a white screen.
I would say, it isn't ThinBasic, I was a little too fast and for sure, sorry.
If I have a version, which runs correctly in OxygenBasic then come I back for a test.
ErosOlmi
15-04-2013, 06:58
Ok, perfect.
I will be happy to test any example and possibly help to fix the crash on exit whichever side it is.
All my tests are conducted under the PC indicated in my signature.
Your examples and games are great, I love spending some time with them and I would love to have you engines working fine under thinBasic too.
Ciao
Eros