Announcement

Collapse
No announcement yet.

Help needed, C -> PB translation

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

  • Help needed, C -> PB translation

    Hi,

    I'm not a C expert, I need help translating the following OpenGL statement (from Microsoft's gl.h) to PowerBasic :-

    Code:
    	typedef void (APIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i);
    Thanks,

    - Rav.



    [This message has been edited by Rav Singh (edited December 30, 2004).]

  • #2
    Hi Rav,

    typedef void (APIENTRY * PFNGLARRAYELEMENTEXTPROC) (GLint i);

    this is the declaration of a typed variable for function calls.

    void APIENTRY GlArrayElementText(Glint i);
    SUB SDECL name of a func (BYVAL integer i)

    with variable PFNGLARRAYELEMENTEXTPROC you can only call functions declared as above

    In PB you would code something like (copy&paste from help)

    DECLARE SUB MySubCall(Param1%, Param2%)
    DIM PtrMySubCall AS DWORD
    PtrMySubCall= CODEPTR(MySubCall)
    CALL DWORD PtrMySubCall USING MySubCall(x1%, x2%)

    Ahoj
    -Uwe


    ------------------

    Comment


    • #3
      Hi Uwe ,I think I understand what's it's trying to do, thanks for your help.

      - Rav.

      ------------------

      Comment


      • #4
        Hi Rav,

        here some sample code that I use for detecting that my app run as Terminal-Server-Session
        (below is far off completed :-)

        sample show how C++ call pfnVar(..)
        PB: CALL DWORD ptr USING DeclaredFunc(..)

        API WTSOpenServer is only on WTS computers available, so I can't use static binding to those API calls

        // declaration in sample.h
        typedef HANDLE (WINAPI * API_WTSOPENSERVER) (LPTSTR pszServerName);

        // code in sample.cpp
        // we need some variables
        HINSTANCE hWtsApi32;
        API_WTSOPENSERVER pfnWTSOpenServer; // see declaration
        HANDLE hServer;

        // LoadLibrary
        hWtsApi32 = LoadLibrary(TEXT("WTSAPI32.DLL"));
        // Get Address of API Function
        pfnWTSOpenServer = (API_WTSOPENSERVER) GetProcAddress(hWtsApi32, TEXT("WTSOpenServerA"));
        // call it
        hServer = pfnWTSOpenServer(pszComputerName); // see declaration

        I think you got the idea when you see such code and how to translate it to PowerBasic

        Ahoj
        -Uwe

        ------------------




        [This message has been edited by Uwe Heyer (edited December 31, 2004).]

        Comment

        Working...
        X