Esempio n. 1
0
void GLPort::StartUp()
{
    if (Created)
        ErrorMsg("Tried to call StartUp() a second time.");

    if (!Initialize())
        ErrorMsg("Unable to create OpenGL interface.");

    InfoMsg("OpenGL device intitialized successfully.");
}
Esempio n. 2
0
/**
 * Dumps the debug information in a file.
 *
 * @returns 0 on success, exit code on failure.
 * @param   file    The filename.
 * @param   dips    The dips to load and use.
 */
static int DumpFile( const char *file, char **dips )
{
    int             rc = 1;
    dig_fhandle     fh;

    /*
     * Open the file
     */
    fh = DIGCliOpen( file, DIG_READ );
    if( fh == DIG_NIL_HANDLE ) {
        return( ErrorMsg( "Failed to open '%s'\n", file ) );
    }

    /*
     * Init DIP, create a process and load the file into the process.
     */
    if( InitDIP( dips ) ) {
        process_info    *proc = DIPCreateProcess();

        if( proc != NULL ) {
            int         prty;
            mod_handle  mh = 0;

            for( prty = DIPPriority( 0 ); prty != 0; prty = DIPPriority( prty ) ) {
                DIGCliSeek( fh, 0, DIG_ORG );
                mh = DIPLoadInfo( fh, 0, prty );
                if( mh != NO_MOD ) {
                    break;
                }
            }
            if( mh != NO_MOD ) {
                DIPMapInfo( mh, NULL );
                InfoMsg( "DIP opened '%s' at prty=%d, mh=%lx\n", file, prty, (long)mh );

                /*
                 * Enumerate the debug info.
                 */
                rc = DumpIt( file, mh, proc );

                /*
                 * Cleanup.
                 */
                DIPUnloadInfo( mh );
            } else {
                ErrorMsg( "DIP failed to open '%s'.\n", file);
            }
            DIPDestroyProcess( proc );
        }
        TermDIP();
    }
    DIGCliClose( fh );
    return( rc );
}
Esempio n. 3
0
/**
 * Initializes DIP.
 *
 * @returns success indicator.
 * @param   dips    Pointer to an array of dip names terminated by a NULL entry.
 */
static bool InitDIP( char **dips )
{
    bool    rc = false;

    if( !(DIPInit() & DS_ERR) ) {
        char        *ptr;
        unsigned    dips_loaded = 0;

        for( ptr = *dips++; ptr; ptr = *dips++ ) {
            int     rc = DIPLoad( ptr );

            if( rc & DS_ERR ) {
                rc &= ~DS_ERR;
                switch( rc ) {
                case DS_FOPEN_FAILED:
                    ErrorMsg( "%s - not found\n", ptr );
                    break;
                case DS_INVALID_DIP_VERSION:
                    ErrorMsg( "%s - wrong DIP version\n", ptr );
                    break;
                case DS_INVALID_DIP:
                    ErrorMsg( "%s - invalid DIP\n", ptr );
                    break;
                case DS_TOO_MANY_DIPS:
                    ErrorMsg( "%s - too many DIPs\n", ptr );
                    break;
                default:
                    ErrorMsg( "%s - rc=%#x (%d)\n", ptr, rc, rc );
                    break;
                }
            } else {
                InfoMsg( "Loaded DIP %s\n", ptr);
                dips_loaded++;
            }
        }

        rc = dips_loaded > 0;
        if( !dips_loaded ) {
            ErrorMsg( "Failed to load any DIPs!\n");
            DIPFini();
        }
    }
    return( rc );
}
Esempio n. 4
0
// looks a lot like Dave's :-)
bool GLPort::Initialize()
{
    PIXELFORMATDESCRIPTOR pfd;
    int npf;

    // need the DC later
    HDC dc = GetDC(MainForm->pnlView->Handle);

    // this is what we want who knows what we get
    memset(&pfd, 0, sizeof pfd);
    pfd.nSize      = sizeof pfd;
    pfd.nVersion   = 1;
    pfd.dwFlags    = /*PFD_SUPPORT_GDI|*/PFD_SUPPORT_OPENGL|
                                         PFD_DOUBLEBUFFER|PFD_DRAW_TO_WINDOW;
    pfd.iPixelType = PFD_TYPE_RGBA;
    pfd.cColorBits = 32;
    pfd.cDepthBits = 16;
    pfd.iLayerType = PFD_MAIN_PLANE;

    // set the pixel format for the window
    npf = ChoosePixelFormat(dc, &pfd);
    SetPixelFormat(dc, npf, &pfd);
    DescribePixelFormat(dc, npf, sizeof pfd, &pfd);
    if (pfd.dwFlags & PFD_NEED_PALETTE)
    {
        ErrorMsg("Segeltuch does not yet support 8-bit video modes.\n\n"
                 "Please increase your video depth to atleast 16-bit.");
        //return false;
        //for now, we allow the program to continue even though the
        //display will be very ugly....
    }
    if (!(pfd.dwFlags & PFD_DOUBLEBUFFER))
    {
        ErrorMsg("No available double buffering support.");
    }
    InfoMsg("Found graphics card with %d-bits of color resolution and a %d-bit depth buffer.",
            pfd.cColorBits, pfd.cDepthBits);

    // create the OpenGL interface
    hRC = wglCreateContext(dc);
    if (hRC == NULL)
    {
        ErrorBox("Unable to create OpenGL renderring context.");
        return false;
    }

    // start her up
    Activate();
    ResetCamera();

    // no more
    MainForm->pnlView->EraseBack = false;
    // Clear the screen initially
    glClearColor(ColBck.r, ColBck.g, ColBck.b, ColBck.a);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    SwapBuffers(dc);

    // setup the new window
    ResetSize(false);

    // Our options
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glFrontFace(GL_CCW);
    glAlphaFunc(GL_GREATER, 0.5);
    glDisable(GL_ALPHA_TEST);

    // Utility Object
    qobj = gluNewQuadric();

    // clean up our stuff
    Deactivate();

    return (Created=true);
}