Announcement

Collapse
No announcement yet.

Creating a FBO for OpenGl

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Creating a FBO for OpenGl

    Hi,
    I am trying to use a Frame Buffer Object in OpenGl and am having difficulties. I found the required include file in Jose's WINAPI_III-107 files, " GLEXT.INC".
    But trying to compile I get " Undefined SUB/FUNCTION reference" for the gl subs.
    Any help very much appreciated.

    thanks,
    Ron


    #COMPILE EXE
    #DIM ALL

    #INCLUDE "GL.INC"
    #INCLUDE "GLU.INC"
    #INCLUDE "GLEXT.INC"
    #INCLUDE "win32api.INC"

    GLOBAL fbo AS DWORD 'The frame buffer object
    GLOBAL fbodepth AS DWORD 'The depth buffer for the frame buffer object
    GLOBAL fbotexture AS INTEGER 'The texture object to write our frame buffer object to
    GLOBAL windowwidth AS LONG 'The width of our window
    GLOBAL windowheight AS LONG 'The height of our window
    GLOBAL rotationdegree AS SINGLE 'The angle of rotation in degrees
    GLOBAL NumBuffers AS LONG
    ' =======================================================================================
    SUB initFrameBufferDepthBuffer
    NumBuffers = 1
    glGenRenderbuffersEXT(NumBuffers, fbodepth) 'Generate one render buffer and store the ID in fbo_depth (dword,dword)
    glBindRenderbufferEXT(%GL_RENDERBUFFER_EXT, fbodepth) 'Bind the fbo_depth RENDER buffer (dword,dword)
    ' ...
    glRenderbufferStorageEXT(%GL_RENDERBUFFER_EXT, %GL_DEPTH_COMPONENT, windowwidth, windowheight)' Set the render buffer storage to be a depth component, with a width and height of the window
    glFramebufferRenderbufferEXT(%GL_FRAMEBUFFER_EXT, %GL_DEPTH_ATTACHMENT_EXT, %GL_RENDERBUFFER_EXT, fbodepth)'Set the render buffer of this buffer to the depth buffer
    glBindRenderbufferEXT(%GL_RENDERBUFFER_EXT, 0) 'Unbind the render buffer
    END SUB
    ' =======================================================================================
    FUNCTION PBMAIN () AS LONG

    MSGBOX "Running"


    END FUNCTION
    ' =======================================================================================

  • #2
    You can't use my headers and the PB headers at the same time:

    You must also be aware that these headers are not extensions to the ones provided with the compiler, but a full replacement. Therefore, you must not mix them with the PowerBASIC include files in any way, neither directly (via #INCLUDE), nor indirectly (via the include path in the IDE).

    Unzip the attached file to a folder of your choice and replace the PB Include path in the PB Ide or the editor that you are using to that folder instead of C:\PBWin10\WinApi.
    Forum: http://www.jose.it-berater.org/smfforum/index.php

    Comment


    • #3
      You can't use [Jose Roca's Windows'] headers and the PB [Windows'] headers at the same time:
      "At the same time" means, "When compiling a single module."

      Using an SLL or DLL for part of an application which uses different source code components is a handy idea. I also have used DLLs to get around equate name conflicts when I had to "marry" two applications into a single user interface.

      MCM
      Michael Mattias
      Tal Systems Inc.
      Racine WI USA
      mmattias@talsystems.com
      http://www.talsystems.com

      Comment


      • #4
        Hi,

        So in the compiler preferences is "C:\WINAPI_III_107" for the include path. And delete the line #INCLUDE "win32api.INC".
        If this is what you meant, I did it and still no luck.
        Is the compiler looking for a DLL that it is not finding? I'm using Windows 10 Pro, 32 bit.
        I have been fighting with this for 2 days already.

        And thank you, I see I have the big guns helping me.

        Ron

        Comment


        • #5
          You're including GLEXT.INC, that only has procedure prototypes, instead of CGLEXT.INC, that contains method wrappers to retrieve the addres of the procedure at runtime and call it if it is supported.

          Direct bindings using LIB <somelib> in the declares is not possible because it won't compile if a procedure is not supported by the installed DLL.

          So the code must be changed to:

          Code:
          #COMPILE EXE
          #DIM ALL
          
          #INCLUDE "GL.INC"
          #INCLUDE "GLU.INC"
          #INCLUDE "CGLEXT.INC"
          
          GLOBAL fbo AS DWORD 'The frame buffer object
          GLOBAL fbodepth AS DWORD 'The depth buffer for the frame buffer object
          GLOBAL fbotexture AS INTEGER 'The texture object to write our frame buffer object to
          GLOBAL windowwidth AS LONG 'The width of our window
          GLOBAL windowheight AS LONG 'The height of our window
          GLOBAL rotationdegree AS SINGLE 'The angle of rotation in degrees
          GLOBAL NumBuffers AS LONG
          ' =======================================================================================
          SUB initFrameBufferDepthBuffer
             NumBuffers = 1
          
             DIM pGlExt AS IGLEXT
             pGlExt = CLASS "CGLEXT"
          
             pGlExt.glGenRenderbuffersEXT(NumBuffers, fbodepth) 'Generate one render buffer and store the ID in fbo_depth (dword,dword)
             pGlExt.glBindRenderbufferEXT(%GL_RENDERBUFFER_EXT, fbodepth) 'Bind the fbo_depth RENDER buffer (dword,dword)
             ' ...
             pGlExt.glRenderbufferStorageEXT(%GL_RENDERBUFFER_EXT, %GL_DEPTH_COMPONENT, windowwidth, windowheight)' Set the render buffer storage to be a depth component, with a width and height of the window
             pGlExt.glFramebufferRenderbufferEXT(%GL_FRAMEBUFFER_EXT, %GL_DEPTH_ATTACHMENT_EXT, %GL_RENDERBUFFER_EXT, fbodepth)'Set the render buffer of this buffer to the depth buffer
             pGlExt.glBindRenderbufferEXT(%GL_RENDERBUFFER_EXT, 0) 'Unbind the render buffer
          
          END SUB
          ' =======================================================================================
          FUNCTION PBMAIN () AS LONG
          
          MSGBOX "Running"
          
          
          END FUNCTION
          ' =======================================================================================
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            Hi,
            The users of PB have been truly blessed with such a supportive community. I have learned a great deal here from you both and many others.
            Thank you very much for your help.
            Ron

            Comment

            Working...
            X