raafal - a cross-platform 3d application framework project
Re: raafal - a cross-platform 3d application framework proje
Have you considered something like OpenGL instead of a canvas or use native drawing routines on each platform instead of the PureBasic ones ?
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- grabiller
- Enthusiast
- Posts: 309
- Joined: Wed Jun 01, 2011 9:38 am
- Location: France - 89220 Rogny-Les-Septs-Ecluses
- Contact:
Re: raafal - a cross-platform 3d application framework proje
Yes indeed, that's why I've asked to Fred for an OpenGLCanvasGadget. I don't know if nor when it will be available.wilbert wrote:Have you considered something like OpenGL instead of a canvas or use native drawing routines on each platform instead of the PureBasic ones ?
I prefer not to use native drawing routines on each platform, or I better go back to C/C++. To me the point of using PureBasic is to use as few as possible native API while making cross-platform applications.
But I also want to try the Screen (WindowedSreen actually) way with OpenGL subsystem. It requires a different approach to handle events, and constantly polling like in a game application so I'm not sure in terms of resources it will be more efficient. But I'm gonna try anyway.
guy rabiller | radfac founder / ceo | raafal.org
Re: raafal - a cross-platform 3d application framework proje
For some time now, I am working on my cad, cam, cnc software.
I used all the parts in canvas gadget,
but the canvas gadget is having some limits,
I am reprogramming all to sprites now...
but there I am having some problems with the drawtext() and with the colors in OpenGL.
marc,
I used all the parts in canvas gadget,
but the canvas gadget is having some limits,
I am reprogramming all to sprites now...
but there I am having some problems with the drawtext() and with the colors in OpenGL.
marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
- grabiller
- Enthusiast
- Posts: 309
- Joined: Wed Jun 01, 2011 9:38 am
- Location: France - 89220 Rogny-Les-Septs-Ecluses
- Contact:
Re: raafal - a cross-platform 3d application framework proje
That's interesting marc. Could you elaborate on the limits you found with the CanvasGadget ?marc_256 wrote:For some time now, I am working on my cad, cam, cnc software.
I used all the parts in canvas gadget,
but the canvas gadget is having some limits,
I am reprogramming all to sprites now...
but there I am having some problems with the drawtext() and with the colors in OpenGL.
marc,
Also, what kind of issues do you have with DrawText() and OpenGL colors ?
guy rabiller | radfac founder / ceo | raafal.org
Re: raafal - a cross-platform 3d application framework proje
Hi grabiller,
For me, the canvas gadget is one of the best gadgets there exist in PB.
It works very well, but for speed ??
If I make 'mesh drawings' with 1000st of edges and vertices, it works well, but the mouse control is very slow.
So my 3D cursor, is slow in motion.
For the color problems, there is a big difference between DirectX and OpenGL color management.
Also with DrawText() is a difference in DirectX and OpenGL mode.
see also this post, http://www.purebasic.fr/english/viewtop ... 36&t=56020
also mesh handeling is different in DirextX and OpenGL.
Marc,
For me, the canvas gadget is one of the best gadgets there exist in PB.
It works very well, but for speed ??
If I make 'mesh drawings' with 1000st of edges and vertices, it works well, but the mouse control is very slow.
So my 3D cursor, is slow in motion.
For the color problems, there is a big difference between DirectX and OpenGL color management.
Also with DrawText() is a difference in DirectX and OpenGL mode.
see also this post, http://www.purebasic.fr/english/viewtop ... 36&t=56020
also mesh handeling is different in DirextX and OpenGL.
Marc,
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...
PS: sorry for my english I speak flemish ...
Re: raafal - a cross-platform 3d application framework proje
If you would only need one or two fonts in a few different sizes, you could use sprite sheets instead to draw the text.marc_256 wrote:Also with DrawText() is a difference in DirectX and OpenGL mode.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- grabiller
- Enthusiast
- Posts: 309
- Joined: Wed Jun 01, 2011 9:38 am
- Location: France - 89220 Rogny-Les-Septs-Ecluses
- Contact:
Re: raafal - a cross-platform 3d application framework proje
I wanted to try with the OpenWindowedScreen() approach but I've immediately encountered a showstopper.
I didn't find a way to 'resize' the hardware accelerated surface. Using the 'AutoStretch' isn't an option because when the main Window is resized, the HA surface is indeed 'stretched' which means the coordinates are all messed up in regard to the actual dimension of the HA surface in pixels. (yet it does not work at all with DirectX11 - on Win64 - and with OpenGL it is stretched only when you stop resizing the window, so no 'realtime' resizing).
@Marc
I wonder how you handle this in your CAD application !?
I didn't find a way to 'resize' the hardware accelerated surface. Using the 'AutoStretch' isn't an option because when the main Window is resized, the HA surface is indeed 'stretched' which means the coordinates are all messed up in regard to the actual dimension of the HA surface in pixels. (yet it does not work at all with DirectX11 - on Win64 - and with OpenGL it is stretched only when you stop resizing the window, so no 'realtime' resizing).
@Marc
I wonder how you handle this in your CAD application !?
guy rabiller | radfac founder / ceo | raafal.org
Re: raafal - a cross-platform 3d application framework proje
How about something like this ?grabiller wrote:I didn't find a way to 'resize' the hardware accelerated surface.
Code: Select all
Declare CreateSprites()
Declare ResizeWindowedScreen(Window)
; Init some things
If InitSprite() And InitMouse() And InitKeyboard()
Else
MessageRequester("Error", "An error has occured while initializing the application!")
End
EndIf
; Create sprites procedure
Procedure CreateSprites()
CreateSprite(0, 50, 50)
EndProcedure
; Resize windowed screen procedure
Procedure ResizeWindowedScreen(Window)
Static ScreenExists = #False
If ScreenExists : CloseScreen() : EndIf
If OpenWindowedScreen(WindowID(Window), 0, 0, WindowWidth(Window), WindowHeight(Window))
ScreenExists = #True
CreateSprites()
Else
MessageRequester("Error", "An error has occured while resizing the window!")
End
EndIf
EndProcedure
; Main loop
If OpenWindow(0, 0, 0, 320, 200, "A screen in a window...", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
ResizeWindowedScreen(0)
Repeat
Repeat
Event = WaitWindowEvent(10)
Select Event
Case #PB_Event_CloseWindow
End
Case #PB_Event_SizeWindow
ResizeWindowedScreen(0)
EndSelect
Until Event = 0
FlipBuffers()
ClearScreen(RGB(0, 0, 200))
DisplaySprite(0, 10, 10)
DisplaySprite(0, ScreenWidth() - 60, 10)
ForEver
EndIf
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- grabiller
- Enthusiast
- Posts: 309
- Joined: Wed Jun 01, 2011 9:38 am
- Location: France - 89220 Rogny-Les-Septs-Ecluses
- Contact:
Re: raafal - a cross-platform 3d application framework proje
Hey Wilbert,
Yes, this is the solution everyone gives, indeed, I also got it from the french forum and while searching through the messages.
But, in my case, this is unusable. Testing our exemple (with OpenGL subsystem) I get an horrible flicking yet (with OpenGL) the Screen is only updated when I stop resizing the Window. Yet, having to Close/ReOpen the WindowedScreen and re-initialize all the Sprites on resize is a non-sense to me.
Actually, I just found a much simpler workaround: I call OpenWindowedScreen() with the size of the Desktop, then I handle drawing with WindowWidth/Height instead of ScreenWidth/Height. No stretching anymore, no need to close/recreate everything and I have no flicking anymore.
Here is an exemple: windowed_screen_resize_20130831.rar (Win64)
The fact that even with a small window the screen is the size of the desktop is not a big issue in my case because the kind of application I'm creating is usually used maximized. But at least when restoring/resizing I get clean refresh.
Yes, this is the solution everyone gives, indeed, I also got it from the french forum and while searching through the messages.
But, in my case, this is unusable. Testing our exemple (with OpenGL subsystem) I get an horrible flicking yet (with OpenGL) the Screen is only updated when I stop resizing the Window. Yet, having to Close/ReOpen the WindowedScreen and re-initialize all the Sprites on resize is a non-sense to me.
Actually, I just found a much simpler workaround: I call OpenWindowedScreen() with the size of the Desktop, then I handle drawing with WindowWidth/Height instead of ScreenWidth/Height. No stretching anymore, no need to close/recreate everything and I have no flicking anymore.
Here is an exemple: windowed_screen_resize_20130831.rar (Win64)
The fact that even with a small window the screen is the size of the desktop is not a big issue in my case because the kind of application I'm creating is usually used maximized. But at least when restoring/resizing I get clean refresh.
guy rabiller | radfac founder / ceo | raafal.org
- grabiller
- Enthusiast
- Posts: 309
- Joined: Wed Jun 01, 2011 9:38 am
- Location: France - 89220 Rogny-Les-Septs-Ecluses
- Contact:
Re: raafal - a cross-platform 3d application framework proje
Here is the source code based on the PB exemple, it will be more useful than the executable:
Code: Select all
If InitSprite() = 0
MessageRequester("Error", "Can't open screen & sprite environment!", 0)
End
EndIf
Procedure __OnSizeWindow()
ClearScreen(RGB(0, 0, 200)) ; A blue background
DisplaySprite(0, 10, 10) ; Display our black box at the left-top corner
DisplaySprite(0, WindowWidth(0) - 60, 10) ; Display our black box at the right-top corner
FlipBuffers()
EndProcedure
ExamineDesktops()
If OpenWindow(0, 0, 0, 320, 200, "A screen in a window...", #PB_Window_SystemMenu|#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget|#PB_Window_SizeGadget|#PB_Window_ScreenCentered)
SetWindowColor(0,RGB(0,0,200))
BindEvent( #PB_Event_SizeWindow, @__OnSizeWindow(), #PB_All, #PB_All, #PB_All )
If OpenWindowedScreen(WindowID(0),0,0,DesktopWidth(0),DesktopHeight(0))
CreateSprite(0, 50, 50) ; Create an empty sprite, will be whole black
Repeat
; It's very important to process all the events remaining in the queue at each frame
;
Repeat
Event = WaitWindowEvent(10)
If Event = #PB_Event_CloseWindow
End
EndIf
Until Event = 0
ClearScreen(RGB(0, 0, 200)) ; A blue background
DisplaySprite(0, 10, 10) ; Display our black box at the left-top corner
DisplaySprite(0, WindowWidth(0) - 60, 10) ; Display our black box at the right-top corner
FlipBuffers()
ForEver
Else
MessageRequester("Error", "Can't open windowed screen!", 0)
EndIf
EndIf
guy rabiller | radfac founder / ceo | raafal.org
Re: raafal - a cross-platform 3d application framework proje
It doesn't seem to work on OS X.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- grabiller
- Enthusiast
- Posts: 309
- Joined: Wed Jun 01, 2011 9:38 am
- Location: France - 89220 Rogny-Les-Septs-Ecluses
- Contact:
Re: raafal - a cross-platform 3d application framework proje
What happens on OSX ? It does not compile ? It crashes ?wilbert wrote:It doesn't seem to work on OS X.
Perhaps it is related to BindEvent ? (try to use the normal event in the event loop then).
guy rabiller | radfac founder / ceo | raafal.org
Re: raafal - a cross-platform 3d application framework proje
The sprites aren't drawn while DisplaySprite() does get called.grabiller wrote:What happens on OSX ? It does not compile ? It crashes ?
Perhaps it is related to BindEvent ? (try to use the normal event in the event loop then).
So nothing but a blue window.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
Re: raafal - a cross-platform 3d application framework proje
Compiles. Sometimes displays the sprites here, sometimes not (just blue window).grabiller wrote:What happens on OSX ? It does not compile ? It crashes ?wilbert wrote:It doesn't seem to work on OS X.
Perhaps it is related to BindEvent ? (try to use the normal event in the event loop then).
When displaying the sprites, the second one is definitely not displayed at "WindowWidth(0) - 60",
although "Debug WindowWidth(0)" gives the correct result.
- grabiller
- Enthusiast
- Posts: 309
- Joined: Wed Jun 01, 2011 9:38 am
- Location: France - 89220 Rogny-Les-Septs-Ecluses
- Contact:
Re: raafal - a cross-platform 3d application framework proje
That's odd. Works perfectly well here.
@Wilbert
@Danilo
Do the sprites show (at the right place) when the application start, before you do any resizing ?
@Danilo
Did you tried to use the opengl subsystem in the compiler options ?
Did you tried the executable from the link I gave ? Same result ?
Btw, I'm using v5.20 b13 here on Windows x64.
@Wilbert
@Danilo
Do the sprites show (at the right place) when the application start, before you do any resizing ?
@Danilo
Did you tried to use the opengl subsystem in the compiler options ?
Did you tried the executable from the link I gave ? Same result ?
Btw, I'm using v5.20 b13 here on Windows x64.
guy rabiller | radfac founder / ceo | raafal.org