und nocheinmal opengl

thurin

thurin

Mitglied
Thread Starter
Dabei seit
24.03.2004
Beiträge
78
Reaktionspunkte
0
also ich habs einam geschaft opengl im vollbildmodus zu initialisieren.. allerdings bleiben alle opengl befehle ohne wirkung.. sprich: der bildschirm bleibt schwarz..

hier der quellcode:

#include <unistd.h>
#include <iostream.h>
#include <ApplicationServices/ApplicationServices.h>
#include <OpenGL/OpenGL.h>
#include <OpenGL/gl.h>
#include <OpenGL/glu.h>

int main (int argc, char * const argv[]) {

CGDisplayCapture(kCGDirectMainDisplay);

CGOpenGLDisplayMask displayMask =
CGDisplayIDToOpenGLDisplayMask( kCGDirectMainDisplay ) ;

CGLPixelFormatAttribute attribs[] =
{
kCGLPFAFullScreen,
kCGLPFADisplayMask,
(CGLPixelFormatAttribute)displayMask,
(CGLPixelFormatAttribute)NULL
} ;

CGLPixelFormatObj pixelFormatObj ;
long numPixelFormats ;

CGLError error = CGLChoosePixelFormat( attribs, &pixelFormatObj, &numPixelFormats );
std::cout << "choose pixel format: " << CGLErrorString( error ) << std::endl;

if ( pixelFormatObj == NULL ) std::cout << "format ist null!" << std::endl;

CGLContextObj contextObj ;
error = CGLCreateContext( pixelFormatObj, NULL, &contextObj ) ;
std::cout << "create context: " << CGLErrorString( error ) << std::endl;

if ( contextObj == NULL ) std::cout << "Kontext ist null!" << std::endl;

error = CGLSetCurrentContext( contextObj ) ;
std::cout << "set current context: " << CGLErrorString( error ) << std::endl;
error = CGLSetFullScreen( contextObj ) ;
std::cout << "set fullscreen: " << CGLErrorString( error ) << std::endl;

glClearColor( 0, 0, 1, 0 ) ;

glBegin( GL_POINT );
glPointSize( 10.0 );
glClearColor( 1.0, 0.0, 0.0, 1.0 );
//glClear( GL_COLOR_BUFFER_BIT );
//glColor3f( 0.0, 1.0, 0.0 );
glVertex2i( 100, 100 );
glVertex2i( 100, 150 );
glEnd();

sleep( 3 );

CGLSetCurrentContext( NULL ) ;
CGLClearDrawable( contextObj ) ;
CGLDestroyContext( contextObj );

CGLDestroyPixelFormat( pixelFormatObj ) ;

CGReleaseAllDisplays();

return 0;
}

hat wer eine ahnung woran das liegt?

lg, f
 
Tja also in deinem Prog bekommt OpenGL einfach den Befehl zum Zeichen nicht.
Probier mal ein glFlush() nach glEnd()
 
Original geschrieben von Kusanagi
Tja also in deinem Prog bekommt OpenGL einfach den Befehl zum Zeichen nicht.
Probier mal ein glFlush() nach glEnd()
&nbsp;

das problem hat sich schon längst gelöst.. komischerweise setzt glVertex2i die punkte nicht in devicekoordinaten, sondern auch in den normalisierten viewportkoordinaten (-1 - 1) mit glVertex2f im bereich -1 - 1 hats dann tadellos funktioniert..

glFlush is nicht zwingend notwendig..
 
Zurück
Oben Unten