static const wchar_t *appTitleW(){ return bbStringToWString( bbAppTitle ); }
CFStringRef CFStringFromBBString( const BBString *str ){ UniChar *p = bbStringToWString( (BBString*)str ); CFStringRef t = CFStringFromWString(p); bbMemFree( p ); return t; }
BBGLContext *bbGLGraphicsCreateGraphics( int width,int height,int depth,int hertz,int flags, int x, int y ){ BBGLContext *context; int mode; HDC hdc; HWND hwnd; HGLRC hglrc; long pf; PIXELFORMATDESCRIPTOR pfd; int hwnd_style; RECT rect={0,0,width,height}; _initWndClass(); if( depth ){ mode=MODE_DISPLAY; hwnd_style=WS_POPUP; }else{ HWND desktop = GetDesktopWindow(); RECT desktopRect; GetWindowRect(desktop, &desktopRect); rect.left=(x == -1) ? desktopRect.right/2-width/2 : x + GetSystemMetrics(SM_CXBORDER); rect.top=(y == -1) ? desktopRect.bottom/2-height/2: y + GetSystemMetrics(SM_CYCAPTION) + GetSystemMetrics(SM_CYFIXEDFRAME); rect.right=rect.left+width; rect.bottom=rect.top+height; mode=MODE_WINDOW; hwnd_style=WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX; } AdjustWindowRectEx( &rect,hwnd_style,0,0 ); if( _bbusew ){ BBChar *p=bbStringToWString( bbAppTitle ); hwnd=CreateWindowExW( 0,CLASS_NAMEW,p, hwnd_style,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,0,0,GetModuleHandle(0),0 ); bbMemFree(p); }else{ char *p=bbStringToCString( bbAppTitle ); hwnd=CreateWindowEx( 0,CLASS_NAME,p, hwnd_style,rect.left,rect.top,rect.right-rect.left,rect.bottom-rect.top,0,0,GetModuleHandle(0),0 ); bbMemFree(p); } if( !hwnd ) return 0; GetClientRect( hwnd,&rect ); width=rect.right-rect.left; height=rect.bottom-rect.top; _initPfd( &pfd,flags ); hdc=GetDC( hwnd ); int multisample = 0; if (_MULTISAMPLE2X & flags) multisample = 2; else if (_MULTISAMPLE4X & flags) multisample = 4; else if (_MULTISAMPLE8X & flags) multisample = 8; else if (_MULTISAMPLE16X & flags) multisample = 16; if (multisample>0){ pf=MyChoosePixelFormat( hdc,flags ); }else{ pf=ChoosePixelFormat( hdc,&pfd ); } if( !pf ){ DestroyWindow( hwnd ); return 0; } SetPixelFormat( hdc,pf,&pfd ); hglrc=wglCreateContext( hdc ); if( _sharedContext ) wglShareLists( _sharedContext->hglrc,hglrc ); context=(BBGLContext*)malloc( sizeof(BBGLContext) ); memset( context,0,sizeof(context) ); context->mode=mode; context->width=width; context->height=height; context->depth=depth; context->hertz=hertz; context->flags=flags; context->hdc=hdc; context->hwnd=hwnd; context->hglrc=hglrc; context->succ=_contexts; _contexts=context; ShowWindow( hwnd,SW_SHOW ); return context; }