It is currently Sun Mar 29, 2020 3:15 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 64 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next
Author Message
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Fri Aug 30, 2013 7:29 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3606
Location: Netherlands
Have you considered something like OpenGL instead of a canvas or use native drawing routines on each platform instead of the PureBasic ones ?

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Fri Aug 30, 2013 8:31 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 01, 2011 9:38 am
Posts: 309
Location: France - 89220 Rogny-Les-Septs-Ecluses
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 ?

Yes indeed, that's why I've asked to Fred for an OpenGLCanvasGadget. I don't know if nor when it will be available.

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


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Fri Aug 30, 2013 8:44 am 
Offline
Enthusiast
Enthusiast

Joined: Thu May 06, 2010 10:16 am
Posts: 584
Location: Belgium
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,

_________________
- every professional was once an amateur - greetings from Pajottenland - Belgium -
PS: sorry for my english I speak flemish ...


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Fri Aug 30, 2013 9:14 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 01, 2011 9:38 am
Posts: 309
Location: France - 89220 Rogny-Les-Septs-Ecluses
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,

That's interesting marc. Could you elaborate on the limits you found with the CanvasGadget ?

Also, what kind of issues do you have with DrawText() and OpenGL colors ?

_________________
guy rabiller | radfac founder / ceo | raafal.org


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Fri Aug 30, 2013 1:36 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu May 06, 2010 10:16 am
Posts: 584
Location: Belgium
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/viewtopic.php?f=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 ...


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Fri Aug 30, 2013 2:13 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3606
Location: Netherlands
marc_256 wrote:
Also with DrawText() is a difference in DirectX and OpenGL mode.

If you would only need one or two fonts in a few different sizes, you could use sprite sheets instead to draw the text.

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Fri Aug 30, 2013 6:31 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 01, 2011 9:38 am
Posts: 309
Location: France - 89220 Rogny-Les-Septs-Ecluses
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 !?

_________________
guy rabiller | radfac founder / ceo | raafal.org


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Sat Aug 31, 2013 7:28 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3606
Location: Netherlands
grabiller wrote:
I didn't find a way to 'resize' the hardware accelerated surface.

How about something like this ?
Code:
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

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Sat Aug 31, 2013 7:52 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 01, 2011 9:38 am
Posts: 309
Location: France - 89220 Rogny-Les-Septs-Ecluses
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.

_________________
guy rabiller | radfac founder / ceo | raafal.org


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Sat Aug 31, 2013 8:12 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 01, 2011 9:38 am
Posts: 309
Location: France - 89220 Rogny-Les-Septs-Ecluses
Here is the source code based on the PB exemple, it will be more useful than the executable:

Code:
  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


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Sat Aug 31, 2013 8:18 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3606
Location: Netherlands
It doesn't seem to work on OS X.

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Sat Aug 31, 2013 8:21 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 01, 2011 9:38 am
Posts: 309
Location: France - 89220 Rogny-Les-Septs-Ecluses
wilbert wrote:
It doesn't seem to work on OS X.

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).

_________________
guy rabiller | radfac founder / ceo | raafal.org


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Sat Aug 31, 2013 8:41 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3606
Location: Netherlands
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).

The sprites aren't drawn while DisplaySprite() does get called.
So nothing but a blue window.

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Sat Aug 31, 2013 8:42 am 
Offline
Addict
Addict
User avatar

Joined: Sat Apr 26, 2003 8:26 am
Posts: 2942
Location: Planet Earth
grabiller wrote:
wilbert wrote:
It doesn't seem to work on OS X.

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).

Compiles. Sometimes displays the sprites here, sometimes not (just blue window).
When displaying the sprites, the second one is definitely not displayed at "WindowWidth(0) - 60",
although "Debug WindowWidth(0)" gives the correct result.


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Sat Aug 31, 2013 8:52 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Jun 01, 2011 9:38 am
Posts: 309
Location: France - 89220 Rogny-Les-Septs-Ecluses
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.

_________________
guy rabiller | radfac founder / ceo | raafal.org


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 64 posts ]  Go to page Previous  1, 2, 3, 4, 5  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye