Beispiel #1
0
bool Curses::processKeyInFocus(const Key &key)
{
	if ((key.plain() && key.ukey == '\t')
	    || key == key.DOWN || key == key.SHIFTDOWN
	    || key == key.ENTER)
	{
		transferNextFocus();
		return true;
	}

	if (key == key.UP || key == key.SHIFTUP)
	{
		transferPrevFocus();
		return true;
	}

	if (key == key.PGUP || key == key.SHIFTPGUP)
	{
		int h=getScreenHeight();

		if (h > 5)
			h -= 5;

		if (h < 5)
			h=5;

		while (h)
		{
			processKey(Key(key ==
				       Key::PGUP ? Key::UP:Key::SHIFTUP));
			--h;
		}
		return true;
	}

	if (key == key.PGDN || key == key.SHIFTPGDN)
	{
		int h=getScreenHeight();

		if (h > 5)
			h -= 5;

		if (h < 5)
			h=5;

		while (h)
		{
			processKey(Key(key ==
				       Key::PGDN ? Key::DOWN:Key::SHIFTDOWN));
			--h;
		}
		return true;
	}

	return false;
}
Beispiel #2
0
void draw(void *userData)
{
	DemoData *d = (DemoData *) userData;
	char buf[256];
	int x, y;
	
	/* Exit on key press */
	if (getKey())
		exitPolo();
	
	/* Clear screen with right mouse button */
	if (isMouseButtonPressed(1))
		clearScreen();
	
	/* Paint with left mouse button */
	if (isMouseButtonPressed(0))
	{
		if ((getMouseX() < 128) && (getMouseY() < 128))
			setDrawTint(getColorFromHSVA(getMouseX() / 128,
			                             getMouseY() / 128,
			                             1,
			                             BRUSH_ALPHA));
		else
			drawImage(getMouseX() - getImageWidth(d->brush) / 2,
			          getMouseY() - getImageHeight(d->brush) / 2,
			          d->brush);
	}
	
	/* Draw left bar */
	setPenColor(POLO_STEEL);
	setFillGradient(POLO_SILVER, POLO_TUNGSTEN);
	drawRect(-1, -1, TOOLBAR_WIDTH, getScreenHeight() + 2);
	
	/* Draw frames per second and time display */
	setPenColor(POLO_BLACK);
	sprintf(buf, "FPS: %.3f", d->frame / (getTime() + 0.001));
	drawText((TOOLBAR_WIDTH - getTextDrawWidth(buf)) / 2,
	         getScreenHeight() - getTextDrawHeight(buf) - 10,
	         buf);
	
	/* Increment frame number */
	d->frame++;
	
	/* Paint color palette */
	for (x = 0; x < 128; x++)
		for (y = 0; y < 128; y++)
		{
			setPenColor(getColorFromHSV(x / 128.0,
			                            y / 128.0,
			                            1.0));
			drawPoint(x, y);
		}
}
Beispiel #3
0
	//creates the default fonts (which shouldn't ever be deleted)
	void loadFonts()
	{
		if(loadedFonts)
			return;

		std::cout << "loading fonts...";

		std::string fontPath = Font::getDefaultPath();

		//make sure our font exists
		if(!boost::filesystem::exists(fontPath))
		{
			std::cerr << "System font \"" << fontPath << "\" wasn't found! Well, you're kind of screwed. Sorry. Report this to Aloshi, please.\n";
			return;
		}

		float fontSizes[] = {0.035, 0.045, 0.1};
		for(unsigned int i = 0; i < 3; i++)
		{
			fonts[i] = new Font(fontPath, (unsigned int)(fontSizes[i] * getScreenHeight()));
		}

		loadedFonts = true;

		std::cout << "done\n";
	}
Beispiel #4
0
void Client::updateClientParameters(void)
{
	std::string string = "";
	// client-version
	string.append("client-version=").append(getVersion());
	
	// screen
	char screen[32];
	memset(screen, 0, 32);
	snprintf(screen, 32, "%dx%d", getScreenWidth(), getScreenHeight());
	string.append("&screen=").append(screen);
	
	// os
	std::string os = std::string(getSystemName()).append("/").append(getSystemVersion());
	UrlUtils::escape(os);
	string.append("&os=").append(os);
	
	// device
	std::string device = std::string(getDeviceModel()).append("/").append(getHardware());
	UrlUtils::escape(device);
	string.append("&device=").append(device);
	
	// imei
	string.append("&imei=").append(getDeviceIdentifier());
	
	m_sClientParameters = string;
}
bool GameDriver::handleMouseMotion(float frameTime, const SDL_MouseMotionEvent& ev)
{
	if(mSteeringWithMouse) {
#if 0
		mSteering += ev.xrel * 0.01f;
		mThrottle -= mBrake;
		mThrottle -= ev.yrel * 0.01f;
		if(mThrottle < 0.0f) {
			mBrake = -mThrottle;
			mThrottle = 0.0f;
		}
#else
		mSteering = (ev.x / (float)getScreenWidth() * 2.0f) - 1.0f;
		float y = ((1.0f - ev.y / (float)getScreenHeight()) * 2.0f) - 1.0f;
		mThrottle = std::max(0.0f, y);
		mBrake = std::max(0.0f, -y);
#endif

		mSteering = Common::clamp(-1.0f, mSteering, 1.0f);
		mThrottle = Common::clamp(0.0f, mThrottle, 1.0f);
		mBrake = Common::clamp(0.0f, mBrake, 1.0f);
	}

	return false;
}
Beispiel #6
0
void render()
{
    // Render floor
    float ar = float(getScreenWidth()) / float(getScreenHeight());
    Vector3f camPos = camera->GetPosition();

    textured->Use(dirLight);

    for (int x = 0; x < ChunkManager::WORLD_SIZE_X; x++)
    {
        for (int z = 0; z < ChunkManager::WORLD_SIZE_Z; z++)
        {
            Matrix4f world = translate(x * 16, 0, z * 16) * scale(1.0f, 1.0f, 1.0f);
            Matrix4f wvp = persProj(ar, 0.1f, 100.0f, 45.0f) * camera->GetTransformation() * world;
            textured->SetWVP(wvp);
            textured->SetWorld(world);
            ChunkManager::getChunk(x, z)->Render(textured);
        }
    }

    checkGLErrors("render chunk");

    textured->StopUsing();

    glUseProgram(0);
}
SkinsRect OS2Factory::getWorkArea() const
{
    // TODO : calculate Desktop Workarea excluding WarpCenter

    // Fill a Rect object
    return  SkinsRect( 0, 0, getScreenWidth(), getScreenHeight());
}
Beispiel #8
0
void X11Factory::getMonitorInfo( int numScreen,
                                 int* p_x, int* p_y,
                                 int* p_width, int* p_height ) const
{
    // initialize to default geometry
    *p_x = 0;
    *p_y = 0;
    *p_width = getScreenWidth();
    *p_height = getScreenHeight();

    // try to detect the requested screen via Xinerama
    if( numScreen >= 0 )
    {
        int num;
        Display *pDisplay = m_pDisplay->getDisplay();
        XineramaScreenInfo* info = XineramaQueryScreens( pDisplay, &num );
        if( info )
        {
            if( numScreen < num )
            {
                *p_x = info[numScreen].x_org;
                *p_y = info[numScreen].y_org;
                *p_width = info[numScreen].width;
                *p_height = info[numScreen].height;
            }
            XFree( info );
        }
    }
}
Beispiel #9
0
void Win32Factory::getMonitorInfo( int numScreen, int* p_x, int* p_y,
                                   int* p_width, int* p_height ) const
{
    HMONITOR hmon = NULL;
    std::list<HMONITOR>::const_iterator it = m_monitorList.begin();
    for( int i = 0; it != m_monitorList.end(); ++it, i++ )
    {
        if( i == numScreen )
        {
            hmon = *it;
            break;
        }
    }
    MONITORINFO mi;
    mi.cbSize = sizeof( MONITORINFO );
    if( hmon && GetMonitorInfo( hmon, &mi ) )
    {
        *p_x = mi.rcMonitor.left;
        *p_y = mi.rcMonitor.top;
        *p_width = mi.rcMonitor.right - mi.rcMonitor.left;
        *p_height = mi.rcMonitor.bottom - mi.rcMonitor.top;
    }
    else
    {
        *p_x = 0;
        *p_y = 0;
        *p_width = getScreenWidth();
        *p_height = getScreenHeight();
    }
}
Beispiel #10
0
void CTDuelInvite::Show(){
	POINT pt;
	pt.x = (getScreenWidth() / 2) - (GetWidth() / 2);
	pt.y = (getScreenHeight() / 2) - (GetHeight() / 2);
	MoveWindow(pt);

	CTDialog::Show();
}
void OS2Factory::getMonitorInfo( int numScreen, int* p_x, int* p_y,
                                   int* p_width, int* p_height ) const
{
    *p_x = 0;
    *p_y = 0;
    *p_width = getScreenWidth();
    *p_height = getScreenHeight();
}
Beispiel #12
0
void X11Factory::getMonitorInfo( const GenericWindow &rWindow,
                                 int* p_x, int* p_y,
                                 int* p_width, int* p_height ) const
{
    // initialize to default geometry
    *p_x = 0;
    *p_y = 0;
    *p_width = getScreenWidth();
    *p_height = getScreenHeight();

    // Use Xinerama to determine the monitor where the video
    // mostly resides (biggest surface)
    Display *pDisplay = m_pDisplay->getDisplay();
    Window wnd = (Window)rWindow.getOSHandle();
    Window root = DefaultRootWindow( pDisplay );
    Window child_wnd;

    int x, y;
    unsigned int w, h, border, depth;
    XGetGeometry( pDisplay, wnd, &root, &x, &y, &w, &h, &border, &depth );
    XTranslateCoordinates( pDisplay, wnd, root, 0, 0, &x, &y, &child_wnd );

    int num;
    XineramaScreenInfo* info = XineramaQueryScreens( pDisplay, &num );
    if( info )
    {
        Region reg1 = XCreateRegion();
        XRectangle rect1 = { (short)x, (short)y, (unsigned short)w, (unsigned short)h };
        XUnionRectWithRegion( &rect1, reg1, reg1 );

        unsigned int surface = 0;
        for( int i = 0; i < num; i++ )
        {
            Region reg2 = XCreateRegion();
            XRectangle rect2 = { info[i].x_org, info[i].y_org,
                                 (unsigned short)info[i].width, (unsigned short)info[i].height };
            XUnionRectWithRegion( &rect2, reg2, reg2 );

            Region reg = XCreateRegion();
            XIntersectRegion( reg1, reg2, reg );
            XRectangle rect;
            XClipBox( reg, &rect );
            unsigned int surf = rect.width * rect.height;
            if( surf > surface )
            {
               surface = surf;
               *p_x = info[i].x_org;
               *p_y = info[i].y_org;
               *p_width = info[i].width;
               *p_height = info[i].height;
            }
            XDestroyRegion( reg );
            XDestroyRegion( reg2 );
        }
        XDestroyRegion( reg1 );
        XFree( info );
    }
}
void OS2Factory::getMonitorInfo( const GenericWindow &rWindow,
                                 int* p_x, int* p_y,
                                 int* p_width, int* p_height ) const
{
    *p_x = 0;
    *p_y = 0;
    *p_width = getScreenWidth();
    *p_height = getScreenHeight();
}
void OS2Factory::getMousePos( int &rXPos, int &rYPos ) const
{
    POINTL ptl;

    WinQueryPointerPos( HWND_DESKTOP, &ptl );

    rXPos = ptl.x;
    rYPos = ( getScreenHeight() - 1 ) - ptl.y;   // Invert Y
}
Beispiel #15
0
void CB_Room::addBound(uint32_t x1, uint32_t y1, uint32_t x2, uint32_t y2, CB_CollisionEnum tileEnum)
{
    if(tileEnum != CB_COLLISION_NONE)
    {
        CB_CollisionBound * bound = new CB_CollisionBound();
        bound->setBound((double)x1 * tileSize - getScreenLeft(), getScreenHeight() + getScreenTop() - (double)y1 * tileSize, (double)x2 * tileSize - getScreenLeft(), getScreenHeight() + getScreenTop() - (double)y2 * tileSize);
        bound->type = tileEnum;
        boundList.push_back(bound);
    }
}
Beispiel #16
0
void displayEditConfigMenu(void)
{
  char strn[2048];


  _clearscreen(7,0);

  _settextposition(1, 1);

  sprintf(strn,
"&n&+gEditing miscellaneous config options\n"
"\n"
"   &+YA&+L.&n &+wCheck all vnums and vnum input to make sure they exist?   %s&n\n"
"   &+YB&+L.&n &+wUpon loading, check all .WLD zone flags vs. .ZON numb?    %s&n\n"
"\n"
"   &+YC&+L.&n &+wShow extra info about entity being edited on menus?       %s&n\n"
"   &+YD&+L.&n &+wEnable 'create room as you walk' creation?                %s&n\n"
"   &+YE&+L.&n &+wSave vnum of current room for reentrance when reloading?  %s&n\n"
"   &+YF&+L.&n &+wConsider exits with destinations of -1 out of zone?       %s&n\n"
"   &+YG&+L.&n &+wShow shop prices adjusted for mob's sell percentage?      %s&n\n"
"   &+YH&+L.&n &+wAutomatically save zone based on 'save when' below?       %s&n\n"
"   &+YI&+L.&n &+wIf autosave is on, save every X commands ...              %u&n\n"
"\n"
"   &+YJ&+L.&n &+wScreen height                                             %u&n\n"
"   &+YK&+L.&n &+wScreen width                                              %u&n\n"
"\n"
"   &+YL&+L.&n &+wExternal desc editor - '%s'&n\n"
"   &+YM&+L.&n &+wMenu prompt - '%s'&n\n"
"   &+YN&+L.&n &+wMain prompt - '%s'&n\n"
"\n"
MENU_COMMON
"\n"
"%s",
             getYesNoStrn(getVnumCheckVal()),
             getYesNoStrn(getCheckZoneFlagsVal()),

             getYesNoStrn(getShowMenuInfoVal()),
             getYesNoStrn(getWalkCreateVal()),
             getYesNoStrn(getStartRoomActiveVal()),
             getYesNoStrn(getNegDestOutofZoneVal()),
             getYesNoStrn(getShowPricesAdjustedVal()),
             getYesNoStrn(getSaveEveryXCommandsVal()),
             getSaveHowOftenVal(),

             getScreenHeight(),
             getScreenWidth(),

             getEditorName(),
             getMenuPromptName(),
             getMainPromptStrn(),

             getMenuPromptName());

  displayColorString(strn);
}
Beispiel #17
0
void DrawEngine::stopOpenGL()
{
	if ( !mbGLEnable )
		return;

	mbGLEnable = false;

	RenderUtility::stopOpenGL();
	setupBuffer( getScreenWidth() , getScreenHeight() );
	mGLContext.cleanup();
}
Beispiel #18
0
void TMMUI_TestApp::init() throw(int) {

    Rectangle *bg = new Rectangle(NULL, 0, 0, getScreenWidth(), getScreenHeight(), 1.0, 1.0, 1.0,1.0,1.0,1.0,1.0);
    getTenUI()->addDisplayObject(bg);

    initChildrenTest();
    //initLotsOfRectanglesTest();
    //initInteractiveRectangleTest();
    //initRectangleTest();
    //initLineTest();
    //initTextTest();
    //initRasterTest();
}
Beispiel #19
0
QPixmap& MainWindow::loadLogo()
{
    QPixmap* logoOriginal = new QPixmap(":/logo.jpg");
    int logoWidth = logoOriginal->width();

    if (logoWidth > getScreenWidth() - 30)
    {
        QPixmap* logoScaled = new QPixmap();

        *logoScaled = logoOriginal->scaled(getScreenWidth() - 30, getScreenHeight(), Qt::KeepAspectRatio);
        return *logoScaled;
    }
    else return *logoOriginal;
}
void DisplayWindowMupen64plus::_swapBuffers()
{
	// if emulator defined a render callback function, call it before buffer swap
	if (renderCallback != nullptr) {
		gfxContext.resetShaderProgram();
		if (config.frameBufferEmulation.N64DepthCompare == 0) {
			gfxContext.setViewport(0, getHeightOffset(), getScreenWidth(), getScreenHeight());
			gSP.changed |= CHANGED_VIEWPORT;
		}
		gDP.changed |= CHANGED_COMBINE;
		(*renderCallback)((gDP.changed&CHANGED_CPU_FB_WRITE) == 0 ? 1 : 0);
	}
	CoreVideo_GL_SwapBuffers();
}
void OGLVideoMupenPlus::_swapBuffers()
{
	// if emulator defined a render callback function, call it before buffer swap
	if (renderCallback != NULL) {
		glUseProgram(0);
		if (config.frameBufferEmulation.N64DepthCompare == 0) {
			glViewport(0, getHeightOffset(), getScreenWidth(), getScreenHeight());
			gSP.changed |= CHANGED_VIEWPORT;
		}
		gDP.changed |= CHANGED_COMBINE;
		(*renderCallback)((gDP.changed&CHANGED_CPU_FB_WRITE) == 0 ? 1 : 0);
	}
	CoreVideo_GL_SwapBuffers();
}
Beispiel #22
0
void RunDuelCountdown(){
	clock_t dt = clock() - gDuelStart;
	gDuelCountdown = (dt / 1000);

	if(gDuelCountdown >= 0 && gDuelCountdown <= 10){
		int y = (getScreenHeight() / 4);
		int x = (getScreenWidth() / 2);

		int timer = CResourceMgr::GetInstance()->GetImageNID(IMAGE_RES_UI, "TIMER_0");
		ResetTransform(0, 0);
		DrawImpl::Instance()->Draw2D(x, y, IMAGE_RES_UI, timer + (10 - gDuelCountdown), 0xFFFFFFFF);
	} else
		gDuelCountdown = -1;
}
Beispiel #23
0
void Game::paint()
{	

	//While the game is loading, the load method will be called once per update
	if (isLoading() == true)
	{
		//Cache the screen width and height
		float screenWidth = getScreenWidth();
		float screenHeight = getScreenHeight();

		//Draw a black background, you could replace this
		//in the future with a full screen background texture
		OpenGLRenderer::getInstance()->setForegroundColor(OpenGLColorBlack());
		OpenGLRenderer::getInstance()->drawRectangle(0.0f, 0.0f, screenWidth, screenHeight);

		//Calculate the bar width and height, don't actually hard-code these
		float barWidth = 200.0f * getScale();
		float barHeight = 40.0f * getScale();
		float barX = (screenWidth - barWidth) / 2.0f;
		float barY = (screenHeight - barHeight) / 2.0f;

		//
		float percentageLoaded = (float)m_LoadStep / (float)(GameLoadStepCount - 1);
		float loadedWidth = barWidth * percentageLoaded;
		OpenGLRenderer::getInstance()->setForegroundColor(OpenGLColorYellow());
		OpenGLRenderer::getInstance()->drawRectangle(barX, barY, loadedWidth, barHeight);

		//
		OpenGLRenderer::getInstance()->setForegroundColor(OpenGLColorWhite());
		OpenGLRenderer::getInstance()->drawRectangle(barX, barY, barWidth, barHeight, false);

		return;
	}

	OpenGLRenderer::getInstance()->drawTexture(m_BackgroundTexture,0.0f,0.0f);

#if _DEBUG
	if (m_World != NULL)
	{
		m_World->DrawDebugData();
	}
#endif

	//Paint the game's game objects
	for (int i = 0; i < m_GameObjects.size(); i++)
	{
		m_GameObjects.at(i)->paint();
	}
}
Beispiel #24
0
Vector2f Camera::worldToScreen(const Vector2f &vec, bool invertYAxis) const
{
    Vector2f screen;
    screen.x = _screenMin.x + _scaleWorldToScreen.x *
            (vec.x - _worldMin.x - _screenMinInWorld.x);
    screen.y = _screenMin.y + _scaleWorldToScreen.y *
            (vec.y - _worldMin.y - _screenMinInWorld.y);

    if (invertYAxis)
    {
        screen.y = getScreenHeight() - screen.y;
    }

    return screen;
}
Beispiel #25
0
void verifyTerminalSize(void)
{
        setScreenHeight(MIN_LINESIZE);
        setScreenWidth(MIN_COLUMNSIZE);
        
        if (FileOutput)
        {
                struct winsize ws;
                int FileOutputFD = fileno(FileOutput);
                
                if (ioctl(FileOutputFD, TIOCGWINSZ, &ws) < 0)
                {
                        fprintf(FileOutput, "La taille de votre terminal "
                                "doit faire au moins [%dx%d] et n'a pas pu etre determinee\n"
                                "Agrandissez maintenant la fenetre et appuyez sur ENTREE\n",
                                MIN_COLUMNSIZE, MIN_LINESIZE);
                        fflush(stdin);
                        getchar();     
                        fflush(stdin);
                        
                        setScreenHeight(MIN_LINESIZE);
                        setScreenWidth(MIN_COLUMNSIZE);
                }
                else
                {
                        fprintf(FileOutput, "La taille de votre terminal "
                                "doit faire au moins [%dx%d] et fait actuellement [%dx%d]\n"
                                "Agrandissez maintenant la fenetre et appuyez sur ENTREE\n",
                                MIN_COLUMNSIZE, MIN_LINESIZE,
                                ws.ws_col, ws.ws_row);
                        fflush(stdin);
                        getchar();     
                        fflush(stdin);
                        
                        
                        ioctl(FileOutputFD, TIOCGWINSZ, &ws);
                        
                        setScreenHeight(ws.ws_row);
                        setScreenWidth(ws.ws_col);
                        
                        fprintf(FileOutput, "La taille de votre terminal "
                                "enregistrée est : [%dx%d].\nLancement dans 1 seconde...\n",
                                getScreenWidth(), getScreenHeight());
                        sleep(1);       
                }
        }
}
bool ApplicationWin32Imp::createWindow()
{
    if( isWindowCreated() ) return false;

    hInstance_ = ( HINSTANCE )GetModuleHandle( NULL );

    if( false == MyRegisterClass( hInstance_ ) )
        return false;

    const int x = getScreenX();
    const int y = getScreenY();
    const int width = getScreenWidth();
    const int height = getScreenHeight();
    hWnd_ = InitInstance( hInstance_, SW_SHOW, x, y, width, height );

    return NULL != hWnd_;
}
void ApplicationWin32Imp::start() {
    if( false == createWindow() )
        throw exception();

    render_->setHWND( getHWND() );

    if( false == render_->createDevice( isWindowedMode(), getScreenWidth(), getScreenHeight() ) ) {
        destroyWindow();
        throw exception();
    }

    mainLoop();

    render_->destroyDevice();

    destroyWindow();
}
Beispiel #28
0
bool DrawEngine::startOpenGL( bool useGLEW )
{
	if ( mbGLEnable )
		return true;

	setupBuffer( getScreenWidth() , getScreenHeight() );
	if ( !mGLContext.init( getWindow().getHDC() , WGLContext::InitSetting() ) )
		return false;

	if ( glewInit() != GLEW_OK )
		return false;

	RenderUtility::startOpenGL();
	mbGLEnable = true;

	return true;
}
Beispiel #29
0
GUI::GUI() {

    IGTLinkStreamer::pointer streamer = IGTLinkStreamer::New();

    setWidth(getScreenWidth());
    setHeight(getScreenHeight());
    enableMaximized();
    setTitle("FAST Neural Network Despeckling");

    auto resizer = ImageResizer::New();
    resizer->setInputConnection(streamer->getOutputPort());
    resizer->setWidth(512);
    resizer->setHeight(512);

    UltrasoundImageEnhancement::pointer enhancer1 = UltrasoundImageEnhancement::New();
    enhancer1->setInputConnection(resizer->getOutputPort());
    ImageRenderer::pointer renderer1 = ImageRenderer::New();
    renderer1->addInputConnection(enhancer1->getOutputPort());
    View* viewOrig = createView();
    viewOrig->setBackgroundColor(Color::Black());
    viewOrig->set2DMode();
    viewOrig->addRenderer(renderer1);


    ImageToImageNetwork::pointer network = ImageToImageNetwork::New();
    network->load("/home/smistad/Downloads/filname_test.pb");
    network->addOutputNode(0, "activation_8/Tanh:0", NodeType::TENSOR);
    network->setSignedInputNormalization(true);
    network->setScaleFactor(1.0f/255.0f);
    network->setInputConnection(streamer->getOutputPort());

    UltrasoundImageEnhancement::pointer enhancer2 = UltrasoundImageEnhancement::New();
    enhancer2->setInputConnection(network->getOutputPort());
    ImageRenderer::pointer renderer2 = ImageRenderer::New();
    renderer2->addInputConnection(enhancer2->getOutputPort());
    View* view = createView();
    view->setBackgroundColor(Color::Black());
    view->set2DMode();
    view->addRenderer(renderer2);


    QHBoxLayout* layout = new QHBoxLayout;
    layout->addWidget(viewOrig);
    layout->addWidget(view);
    mWidget->setLayout(layout);
}
Beispiel #30
0
void DrawEngine::setupBuffer( int w , int h )
{
	if ( mbGLEnable )
	{
		int bitsPerPixel = GetDeviceCaps( getWindow().getHDC() , BITSPIXEL );

		switch (bitsPerPixel) 
		{
		case 8:
			/* bmiColors is 256 WORD palette indices */
			//bmiSize += (256 * sizeof(WORD)) - sizeof(RGBQUAD);
			break;
		case 16:
			/* bmiColors is 3 WORD component masks */
			//bmiSize += (3 * sizeof(DWORD)) - sizeof(RGBQUAD);
			break;
		case 24:
		case 32:
		default:
			/* bmiColors not used */
			break;
		}

		BITMAPINFO bmpInfo;
		bmpInfo.bmiHeader.biSize     = sizeof(BITMAPINFOHEADER);
		bmpInfo.bmiHeader.biWidth    = getScreenWidth();
		bmpInfo.bmiHeader.biHeight   = getScreenHeight();
		bmpInfo.bmiHeader.biPlanes   = 1;
		bmpInfo.bmiHeader.biBitCount = bitsPerPixel;
		bmpInfo.bmiHeader.biCompression = BI_RGB;
		bmpInfo.bmiHeader.biXPelsPerMeter = 0;
		bmpInfo.bmiHeader.biYPelsPerMeter = 0;
		bmpInfo.bmiHeader.biSizeImage = 0;


		if ( !mBufferDC->create( getWindow().getHDC() , &bmpInfo ) )
			return;
	}
	else
	{
		mBufferDC->create( getWindow().getHDC() , w , h );
	}

	mScreenGraphics->setTargetDC( mBufferDC->getDC() );
}