It is currently Thu Feb 27, 2020 3:09 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 64 posts ]  Go to page Previous  1, 2, 3, 4, 5
Author Message
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Mon Feb 27, 2017 4:42 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Jan 31, 2006 9:43 am
Posts: 495
Location: France
Hi grabiller,

I tried your code to initialize a 3.2+ OpenGL context on MacOS but i get an IMA error at line 86 in the following code. Do you have an idea what's happening ? (PB 5.51 x86)

Code:
 EnableExplicit

 ; ** Attribute names For [NSOpenGLPixelFormat initWithAttributes]
 ; ** And [NSOpenGLPixelFormat getValues:forAttribute:forVirtualScreen].
 Enumeration ;{
    #NSOpenGLPFAAllRenderers       =   1 ;,   /* choose from all available renderers          */
    #NSOpenGLPFATripleBuffer       =   3 ;,   /* choose a triple buffered pixel format        */
    #NSOpenGLPFADoubleBuffer       =   5 ;,   /* choose a double buffered pixel format        */
    #NSOpenGLPFAAuxBuffers         =   7 ;,   /* number of aux buffers                        */
    #NSOpenGLPFAColorSize          =   8 ;,   /* number of color buffer bits                  */
    #NSOpenGLPFAAlphaSize          =  11 ;,   /* number of alpha component bits               */
    #NSOpenGLPFADepthSize          =  12 ;,   /* number of depth buffer bits                  */
    #NSOpenGLPFAStencilSize        =  13 ;,   /* number of stencil buffer bits                */
    #NSOpenGLPFAAccumSize          =  14 ;,   /* number of accum buffer bits                  */
    #NSOpenGLPFAMinimumPolicy      =  51 ;,   /* never choose smaller buffers than requested  */
    #NSOpenGLPFAMaximumPolicy      =  52 ;,   /* choose largest buffers of type requested     */
    #NSOpenGLPFASampleBuffers      =  55 ;,   /* number of multi sample buffers               */
    #NSOpenGLPFASamples            =  56 ;,   /* number of samples per multi sample buffer    */
    #NSOpenGLPFAAuxDepthStencil    =  57 ;,   /* each aux buffer has its own depth stencil    */
    #NSOpenGLPFAColorFloat         =  58 ;,   /* color buffers store floating point pixels    */
    #NSOpenGLPFAMultisample        =  59 ;,   /* choose multisampling                         */
    #NSOpenGLPFASupersample        =  60 ;,   /* choose supersampling                         */
    #NSOpenGLPFASampleAlpha        =  61 ;,   /* request alpha filtering                      */
    #NSOpenGLPFARendererID         =  70 ;,   /* request renderer by ID                       */
    #NSOpenGLPFANoRecovery         =  72 ;,   /* disable all failure recovery systems         */
    #NSOpenGLPFAAccelerated        =  73 ;,   /* choose a hardware accelerated renderer       */
    #NSOpenGLPFAClosestPolicy      =  74 ;,   /* choose the closest color buffer To request   */
    #NSOpenGLPFABackingStore       =  76 ;,   /* back buffer contents are valid after Swap    */
    #NSOpenGLPFAScreenMask         =  84 ;,   /* bit mask of supported physical screens       */
    #NSOpenGLPFAAllowOfflineRenderers = 96 ;, /* allow use of offline renderers               */
    #NSOpenGLPFAAcceleratedCompute =  97 ;,   /* choose a hardware accelerated compute device */
    #NSOpenGLPFAVirtualScreenCount = 128 ;,   /* number of virtual screens in this format     */
    #NSOpenGLPFAOpenGLProfile      =  99 ;,   /* specify an OpenGL Profile To use             */
 EndEnumeration ;}

 ;/* NSOpenGLPFAOpenGLProfile values */
 Enumeration ;{
    #NSOpenGLProfileVersionLegacy  = $1000 ;,   /* choose a Legacy/Pre-OpenGL 3.0 Implementation */
    #NSOpenGLProfileVersion3_2Core = $3200 ;,   /* choose an OpenGL 3.2 Core Implementation      */
    #NSOpenGLProfileVersion4_1Core = $4100 ;    /* choose an OpenGL 4.1 Core Implementation      */
 EndEnumeration ;}

 ; ...[ array9_t ]......................................................
 Structure array9_t
    v.l[9]
 EndStructure
 ; ...[ NSOpenGLPixelFormatAttribute ]...................................
 Macro NSOpenGLPixelFormatAttribute
    array9_t
 EndMacro
 ; ...[ NSOpenGLPixelFormat ]............................................
 Macro NSOpenGLPixelFormat
    i
 EndMacro
 ; ...[ NSOpenGLContext ]................................................
 Macro NSOpenGLContext
    i
 EndMacro

 OpenWindow(0, 10, 10, 640, 480, "OpenGL demo")
 OpenGLGadget(0, 10, 10, WindowWidth(0)-20 , WindowHeight(0)-20)

 ; ---[ Allocate Pixel Format Object ]---------------------------------
 Define pfo.NSOpenGLPixelFormat = CocoaMessage( 0, 0, "NSOpenGLPixelFormat alloc" )
 ; ---[ Set Pixel Format Attributes ]----------------------------------
 Define pfa.NSOpenGLPixelFormatAttribute
 With pfa
    \v[0] = #NSOpenGLPFAColorSize          : \v[1] = 24
    \v[2] = #NSOpenGLPFAAlphaSize          : \v[3] =  8
    \v[4] = #NSOpenGLPFAOpenGLProfile      : \v[5] = #NSOpenGLProfileVersion3_2Core ; will give 4.1 version (or more recent) if available
    \v[6] = #NSOpenGLPFADoubleBuffer
    \v[7] = #NSOpenGLPFAAcceleratedCompute ; I also want OpenCL available
    \v[8] = #Null
 EndWith
 ; ---[ Choose Pixel Format ]------------------------------------------
 CocoaMessage( 0, pfo, "initWithAttributes:", @pfa )
 ; ---[ Allocate OpenGL Context ]--------------------------------------
 Define ctx.NSOpenGLContext = CocoaMessage( 0, 0, "NSOpenGLContext alloc" )
 ; ---[ Create OpenGL Context ]----------------------------------------
 CocoaMessage( 0, ctx, "initWithFormat:", pfo, "shareContext:", #Null )
 ; ---[ Associate Context With OpenGLGadget NSView ]-------------------
 CocoaMessage( 0, ctx, "setView:", GadgetID(0) ) ; oglcanvas_gadget is your OpenGLGadget#
 ; ---[ Set Current Context ]------------------------------------------
 CocoaMessage( 0, ctx, "makeCurrentContext" )

 ; do your OpenGL drawing..

 ; ---[ Swap Buffers ]-------------------------------------------------
 ; CocoaMessage( 0, ctx, "flushBuffer" )

 Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow

_________________
Niffo


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Thu Mar 02, 2017 9:41 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Jan 31, 2006 9:43 am
Posts: 495
Location: France
Ok, i have no more IMA if i remove the "#NSOpenGLPFAAcceleratedCompute" from the attributes array on my MacOS virtual machine (seems i have a non hardware accelerated environment).
But with or without #NSOpenGLPFAAcceleratedCompute on a real Mac, i only obtain a black window, no OpenGL graphics are displayed in example with the following code (you should see a white triangle). If you launch the same code on windows, it works.
Code:
EnableExplicit

OpenWindow(0, 10, 10, 640, 480, "OpenGL demo")
OpenGLGadget(0, 10, 10, WindowWidth(0)-20 , WindowHeight(0)-20)
;ImageGadget(0, 10, 10, WindowWidth(0)-20 , WindowHeight(0)-20, 0)

CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
   ; ** Attribute names For [NSOpenGLPixelFormat initWithAttributes]
   ; ** And [NSOpenGLPixelFormat getValues:forAttribute:forVirtualScreen].
   Enumeration ;{
      #NSOpenGLPFAAllRenderers       =   1 ;,   /* choose from all available renderers          */
      #NSOpenGLPFATripleBuffer       =   3 ;,   /* choose a triple buffered pixel format        */
      #NSOpenGLPFADoubleBuffer       =   5 ;,   /* choose a double buffered pixel format        */
      #NSOpenGLPFAAuxBuffers         =   7 ;,   /* number of aux buffers                        */
      #NSOpenGLPFAColorSize          =   8 ;,   /* number of color buffer bits                  */
      #NSOpenGLPFAAlphaSize          =  11 ;,   /* number of alpha component bits               */
      #NSOpenGLPFADepthSize          =  12 ;,   /* number of depth buffer bits                  */
      #NSOpenGLPFAStencilSize        =  13 ;,   /* number of stencil buffer bits                */
      #NSOpenGLPFAAccumSize          =  14 ;,   /* number of accum buffer bits                  */
      #NSOpenGLPFAMinimumPolicy      =  51 ;,   /* never choose smaller buffers than requested  */
      #NSOpenGLPFAMaximumPolicy      =  52 ;,   /* choose largest buffers of type requested     */
      #NSOpenGLPFASampleBuffers      =  55 ;,   /* number of multi sample buffers               */
      #NSOpenGLPFASamples            =  56 ;,   /* number of samples per multi sample buffer    */
      #NSOpenGLPFAAuxDepthStencil    =  57 ;,   /* each aux buffer has its own depth stencil    */
      #NSOpenGLPFAColorFloat         =  58 ;,   /* color buffers store floating point pixels    */
      #NSOpenGLPFAMultisample        =  59 ;,   /* choose multisampling                         */
      #NSOpenGLPFASupersample        =  60 ;,   /* choose supersampling                         */
      #NSOpenGLPFASampleAlpha        =  61 ;,   /* request alpha filtering                      */
      #NSOpenGLPFARendererID         =  70 ;,   /* request renderer by ID                       */
      #NSOpenGLPFANoRecovery         =  72 ;,   /* disable all failure recovery systems         */
      #NSOpenGLPFAAccelerated        =  73 ;,   /* choose a hardware accelerated renderer       */
      #NSOpenGLPFAClosestPolicy      =  74 ;,   /* choose the closest color buffer To request   */
      #NSOpenGLPFABackingStore       =  76 ;,   /* back buffer contents are valid after Swap    */
      #NSOpenGLPFAScreenMask         =  84 ;,   /* bit mask of supported physical screens       */
      #NSOpenGLPFAAllowOfflineRenderers = 96 ;, /* allow use of offline renderers               */
      #NSOpenGLPFAAcceleratedCompute =  97 ;,   /* choose a hardware accelerated compute device */
      #NSOpenGLPFAVirtualScreenCount = 128 ;,   /* number of virtual screens in this format     */
      #NSOpenGLPFAOpenGLProfile      =  99 ;,   /* specify an OpenGL Profile To use             */
   EndEnumeration ;}

   ;/* NSOpenGLPFAOpenGLProfile values */
   Enumeration ;{
      #NSOpenGLProfileVersionLegacy  = $1000 ;,   /* choose a Legacy/Pre-OpenGL 3.0 Implementation */
      #NSOpenGLProfileVersion3_2Core = $3200 ;,   /* choose an OpenGL 3.2 Core Implementation      */
      #NSOpenGLProfileVersion4_1Core = $4100 ;    /* choose an OpenGL 4.1 Core Implementation      */
   EndEnumeration ;}

   ; ...[ array9_t ]......................................................
   Structure array9_t
      v.l[9]
   EndStructure
   ; ...[ NSOpenGLPixelFormatAttribute ]...................................
   Macro NSOpenGLPixelFormatAttribute
      array9_t
   EndMacro
   ; ...[ NSOpenGLPixelFormat ]............................................
   Macro NSOpenGLPixelFormat
      i
   EndMacro
   ; ...[ NSOpenGLContext ]................................................
   Macro NSOpenGLContext
      i
   EndMacro

   ; ---[ Allocate Pixel Format Object ]---------------------------------
   Define pfo.NSOpenGLPixelFormat = CocoaMessage( 0, 0, "NSOpenGLPixelFormat alloc" )
   ; ---[ Set Pixel Format Attributes ]----------------------------------
   Define pfa.NSOpenGLPixelFormatAttribute
   With pfa
      \v[0] = #NSOpenGLPFAColorSize          : \v[1] = 24
      \v[2] = #NSOpenGLPFAAlphaSize          : \v[3] =  8
      \v[4] = #NSOpenGLPFAOpenGLProfile      : \v[5] = #NSOpenGLProfileVersion3_2Core ; will give 4.1 version (or more recent) if available
      \v[6] = #NSOpenGLPFADoubleBuffer
      ;\v[7] = #NSOpenGLPFAAcceleratedCompute ; I also want OpenCL available
      \v[7] = #Null
      \v[8] = #Null
   EndWith
   ; ---[ Choose Pixel Format ]------------------------------------------
   CocoaMessage( 0, pfo, "initWithAttributes:", @pfa )
   ; ---[ Allocate OpenGL Context ]--------------------------------------
   Define ctx.NSOpenGLContext = CocoaMessage( 0, 0, "NSOpenGLContext alloc" )
   ; ---[ Create OpenGL Context ]----------------------------------------
   CocoaMessage( 0, ctx, "initWithFormat:", pfo, "shareContext:", #Null )
   ; ---[ Associate Context With OpenGLGadget NSView ]-------------------
   CocoaMessage( 0, ctx, "setView:", GadgetID(0) ) ; oglcanvas_gadget is your OpenGLGadget#
   ; ---[ Set Current Context ]------------------------------------------
   CocoaMessage( 0, ctx, "makeCurrentContext" )

   ImportC ""
      glVertexAttribPointer(index.i, size.i, type.l, normalized.b, stride.i, *pointer)
      glEnableVertexAttribArray(index.i)
      glDisableVertexAttribArray(index.i)
   EndImport

CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
   Prototype PFNGLVERTEXATTRIBPOINTERPROC ( index.i, size.i, type.l, normalized.b, stride.i, *pointer )
   Global.PFNGLVERTEXATTRIBPOINTERPROC glVertexAttribPointer = wglGetProcAddress_("glVertexAttribPointer")
   Prototype PFNGLENABLEVERTEXATTRIBARRAYPROC ( index.i )
   Global.PFNGLENABLEVERTEXATTRIBARRAYPROC glEnableVertexAttribArray = wglGetProcAddress_("glEnableVertexAttribArray")
   Prototype PFNGLDISABLEVERTEXATTRIBARRAYPROC(index.i)
   Global.PFNGLDISABLEVERTEXATTRIBARRAYPROC glDisableVertexAttribArray = wglGetProcAddress_("glDisableVertexAttribArray")
CompilerEndIf

;==============================================================================================

Dim vertices.f(5)
vertices(0)= -0.5 : vertices(1)= -0.5
vertices(2)= 0.0 : vertices(3)= 0.5
vertices(4)= 0.5 :  vertices(5)= -0.5

Repeat
   glClear_(#GL_COLOR_BUFFER_BIT)

   glVertexAttribPointer(0, 2,  #GL_FLOAT, #GL_FALSE, 0, vertices())
   glEnableVertexAttribArray(0)
   glDrawArrays_(#GL_TRIANGLES, 0, 3)
   glDisableVertexAttribArray(0)

   CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
      CocoaMessage( 0, ctx, "flushBuffer" )
   CompilerElse
      SetGadgetAttribute(0, #PB_OpenGL_FlipBuffers, #True)
   CompilerEndIf
Until WaitWindowEvent(20) = #PB_Event_CloseWindow

_________________
Niffo


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Tue May 02, 2017 9:02 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Jan 31, 2006 9:43 am
Posts: 495
Location: France
In fact it is working but on MacOS Opengl 3.2 (no backward compatibility), using Shaders AND Vertex Array Objects (VAO) is mandatory.

_________________
Niffo


Top
 Profile  
Reply with quote  
 Post subject: Re: raafal - a cross-platform 3d application framework proje
PostPosted: Wed Oct 23, 2019 9:48 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 04, 2013 5:28 pm
Posts: 333
Hi, is Raafal dead ? The domain seems available. Just being morbidly curious.


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 7 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