Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

re: openGL



On Wed, 7 Jun 2006 18:02:01 -0400, Erik Schmidt <email@hidden>
wrote:

> is it possible to draw with openGL in a carbon window?

    // pixel format
    GLint attribs[] = { AGL_DOUBLEBUFFER, AGL_ACCELERATED, AGL_NO_RECOVERY,
AGL_RGBA, AGL_NONE };
    
    AGLPixelFormat tAGLPixelFormat = aglChoosePixelFormat( NULL, 0, attribs
);
    
    // create the context
    tAGLContext = aglCreateContext( tAGLPixelFormat, NULL );
    
    aglDestroyPixelFormat( tAGLPixelFormat );
    
    aglSetCurrentContext( tAGLContext);
    
    // Not actual display pixels, just the window
    int tWidth = 800;
    int tHeight = 600;
    
    Rect windowRect = { 100, 100, 100 + tHeight, 100 + tWidth };
    
    CreateNewWindow( kDocumentWindowClass,
                     kWindowStandardDocumentAttributes |
                     kWindowStandardHandlerAttribute |
                     kWindowResizableAttribute |
                     kWindowLiveResizeAttribute |
                     kWindowCloseBoxAttribute,
                     &windowRect,
                     &tWindowRef);
    SetWindowTitleWithCFString( tWindowRef, CFSTR( "OpenGL Window" ) );
    
    ShowWindow( tWindowRef);
    aglSetDrawable( tAGLContext, GetWindowPort( tWindowRef ) );
    aglUpdateContext( tAGLContext);

    glViewport(0,0, tWidth, tHeight);
    glMatrixMode( GL_PROJECTION );
    gluPerspective( 45.0, (GLdouble) tWidth/ (GLdouble) tHeight, 1.0 ,
200.0);
    glClearColor( 0.0, 0.0, 0.0, 1.0 );

You can now draw to the tAGLContext.

-- 
Enjoy,
George Warner,
Schizophrenic Optimization Scientist
Apple Developer Technical Support (DTS)


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Carbon-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/carbon-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.