void TrackerArenaForm::paintEvent(QPaintEvent* e)
{
	//qDebug() << "paintEvent1";

	makeCurrent();

//	glMatrixMode(GL_MODELVIEW);
//	glPushMatrix();
//	glMatrixMode(GL_PROJECTION);
//	glPushMatrix();

	initializeGL();

	float ww = width();
	float hh = height();
	setupViewport(ww, hh);
	paintGLInternal();

//	glMatrixMode(GL_MODELVIEW);
//	glPopMatrix();
//	glMatrixMode(GL_PROJECTION);
//	glPopMatrix();

	//
	QPainter painter(this);
	overlapOpenGL(painter);
	//painter.end();

	//qDebug() << "paintEvent2";
}
//----------------------------------------------------------------------------//
void Direct3D10RenderTarget::unprojectPoint(const GeometryBuffer& buff,
                                            const Vector2& p_in,
                                            Vector2& p_out) const
{
    if (!d_matrixValid)
        updateMatrix();

    const Direct3D10GeometryBuffer& gb =
        static_cast<const Direct3D10GeometryBuffer&>(buff);

    D3D10_VIEWPORT vp;
    setupViewport(vp);

    D3DXVECTOR3 in_vec;
    in_vec.z = 0.0f;

    // project points to create a plane orientated with GeometryBuffer's data
    D3DXVECTOR3 p1;
    D3DXVECTOR3 p2;
    D3DXVECTOR3 p3;
    in_vec.x = 0;
    in_vec.y = 0;
    D3DXVec3Project(&p1, &in_vec, &vp, &d_matrix, 0, gb.getMatrix()); 

    in_vec.x = 1;
    in_vec.y = 0;
    D3DXVec3Project(&p2, &in_vec, &vp, &d_matrix, 0, gb.getMatrix()); 

    in_vec.x = 0;
    in_vec.y = 1;
    D3DXVec3Project(&p3, &in_vec, &vp, &d_matrix, 0, gb.getMatrix()); 

    // create plane from projected points
    D3DXPLANE surface_plane;
    D3DXPlaneFromPoints(&surface_plane, &p1, &p2, &p3);

    // unproject ends of ray
    in_vec.x = vp.Width * 0.5f;
    in_vec.y = vp.Height * 0.5f;
    in_vec.z = -d_viewDistance;
    D3DXVECTOR3 t1;
    D3DXVec3Unproject(&t1, &in_vec, &vp, &d_matrix, 0, gb.getMatrix()); 

    in_vec.x = p_in.d_x;
    in_vec.y = p_in.d_y;
    in_vec.z = 0.0f;
    D3DXVECTOR3 t2;
    D3DXVec3Unproject(&t2, &in_vec, &vp, &d_matrix, 0, gb.getMatrix()); 

    // get intersection of ray and plane
    D3DXVECTOR3 intersect;
    D3DXPlaneIntersectLine(&intersect, &surface_plane, &t1, &t2);

    p_out.d_x = intersect.x;
    p_out.d_y = intersect.y;
}
void StateManager::changeState(GAME_STATES nextState, SystemsSet & gameSystems)
{
	activeState = getStateFor(nextState);
	gameSystems.gameData.setChangeToLevelBuilder(false);
	gameSystems.gameData.setChangeToHangar(false);
	gameSystems.gameData.setChangeToMenu(false);
	gameSystems.gameData.setChangeToPause(false);
	gameSystems.gameData.setChangeToPlay(false);
	setupViewport(gameSystems.ogreManager, activeState->getCamera());
}
//----------------------------------------------------------------------------//
void Direct3D8RenderTarget::activate()
{
    if (!d_matrixValid)
        updateMatrix();

    D3DVIEWPORT8 vp;
    setupViewport(vp);
    d_device->SetViewport(&vp);

    d_owner.getDevice()->SetTransform(D3DTS_PROJECTION, &d_matrix);
}
Exemple #5
0
void GLWidget::paintEvent(QPaintEvent *event)
{
    makeCurrent();
//! [4]
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
//! [4]

//! [6]
    qglClearColor(qtPurple.dark());
    glShadeModel(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_MULTISAMPLE);
    static GLfloat lightPosition[4] = { 0.5, 5.0, 7.0, 1.0 };
    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);

    qreal pixelRatio = devicePixelRatio();
    setupViewport(width() * pixelRatio, height() * pixelRatio);
//! [6]

//! [7]
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();
    glTranslatef(0.0, 0.0, -10.0);
    glRotatef(xRot / 16.0, 1.0, 0.0, 0.0);
    glRotatef(yRot / 16.0, 0.0, 1.0, 0.0);
    glRotatef(zRot / 16.0, 0.0, 0.0, 1.0);

    logo->draw();
//! [7]

//! [8]
    glShadeModel(GL_FLAT);
    glDisable(GL_CULL_FACE);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_LIGHTING);

    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();
//! [8]

//! [10]
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    foreach (Bubble *bubble, bubbles) {
        if (bubble->rect().intersects(event->rect()))
            bubble->drawBubble(&painter);
    }
    drawInstructions(&painter);
    painter.end();
}
//----------------------------------------------------------------------------//
void Direct3D10RenderTarget::activate()
{
    if (!d_matrixValid)
        updateMatrix();

    D3D10_VIEWPORT vp;
    setupViewport(vp);
    d_device.RSSetViewports(1, &vp);

    d_owner.setProjectionMatrix(d_matrix);
}
void glwindow::beginglDraw() {
	if (!valid()) {
		setupViewport();
	}

#ifndef MESA
	glDrawBuffer(GL_BACK);//GL_FRONT_AND_BACK
#endif // !MESA

	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
}
//--------------------------------------------------------------
// Loads the settings from the Client XML file.
//--------------------------------------------------------------
void mpeClientTCP::loadIniFile(string _fileString) {
	out("Loading settings from file " + _fileString);

	ofxXmlSettings xmlReader;
    if (!xmlReader.loadFile(_fileString)){
        err("ERROR loading XML file!");
		return;
	}

    // parse INI file
    hostName   = xmlReader.getValue("settings:server:ip", "127.0.0.1", 0);
    serverPort = xmlReader.getValue("settings:server:port", 7887, 0);
    //turn this off if you don't want this client to sync frames but can still
    //receive messages. default is ON as that's the normal behavior
    frameLock = xmlReader.getValue("settings:framelock", true);
    if(frameLock){
        id         = xmlReader.getValue("settings:client_id", -1, 0);
        clientName = xmlReader.getValue("settings:client_name", "noname", 0);
    }
    else{
        cout << "opting out of frame lock" << endl;
    }
	cout << "***MPE:: HOST IS " << hostName << " Server Port is " << serverPort << endl;

	setLocalDimensions(xmlReader.getValue("settings:local_dimensions:width",  640, 0),
					   xmlReader.getValue("settings:local_dimensions:height", 480, 0));

    setOffsets(xmlReader.getValue("settings:local_location:x", 0, 0),
               xmlReader.getValue("settings:local_location:y", 0, 0));

	setMasterDimensions(xmlReader.getValue("settings:master_dimensions:width",  640, 0),
						xmlReader.getValue("settings:master_dimensions:height", 480, 0));

    goFullScreen = xmlReader.getValue("settings:go_fullscreen", "false", 0).compare("true") == 0;
    offsetWindow = xmlReader.getValue("settings:offset_window", "false", 0).compare("true") == 0;

    setupViewport();

	if (xmlReader.getValue("settings:debug", 0, 0) == 1){
        DEBUG = true;
	}

    if(xmlReader.getValue("settings:simulation:on", 0, 0) == 1){
        useSimulationMode(xmlReader.getValue("settings:simulation:fps", 30));
        cout << "using simulation mode" << endl;
    }

    out("Settings: server = " + hostName + ":" + ofToString(serverPort) + ",  id = " + ofToString(id)
        + ", local dimensions = " + ofToString(lWidth) + ", " + ofToString(lHeight)
        + ", location = " + ofToString(xOffset) + ", " + ofToString(yOffset));
}
Exemple #9
0
__kernel void render(__write_only __global image2d_t targetImage, int w, int h, int animation) {
	int y = get_global_id(0);
	int x = get_global_id(1);
	Stack stack;
	stack.size=0;
	ulong seed = y*w+x;

	Viewport viewport = setupViewport(x, y, w, h, animation);
	Vector color = getPixelAntialiased(viewport, &stack, &seed);
	uint4 intColor = {color.z*255, color.y*255, color.x*255, 255};

	int2 posOut = {x, y};
	write_imageui(targetImage, posOut, intColor);
}
bool MultiMgrSample::keyPressed( const OIS::KeyEvent &arg )
{
	if (arg.key == OIS::KC_ESCAPE){
		mShutDown = true;
	}
	else if(arg.key == OIS::KC_V){
		mDual = !mDual;

		if (mDual)
			dualViewport(mPrimarySceneMgr, mSecondarySceneMgr);
		else
			setupViewport(mPrimarySceneMgr);
	}
	else if(arg.key == OIS::KC_C){
		swap(mPrimarySceneMgr, mSecondarySceneMgr);

		if (mDual)
			dualViewport(mPrimarySceneMgr, mSecondarySceneMgr);
		else
			setupViewport(mPrimarySceneMgr);
	}

	return true;
}
void mpeClientTCP::draw(ofEventArgs& e)
{
    //no blocking
    if(useMainThread && lock()) {

		for(int i = 0; i < dataMessage.size(); i++){
			ofxMPEEventArgs e;
			e.message = dataMessage[i];
			e.frame = getFrameCount();
			//cout << "sending message in update " << e.frame << " message " << e.message << endl;

			ofNotifyEvent(ofxMPEEvents.mpeMessage, e);
		}
		dataMessage.clear();

		//TODO: ints, floats, bytes,

		if(shouldReset){
			reset();
		}

		if(triggerFrame){
			//ofLog(OF_LOG_VERBOSE, "Trigger Event :: ! with frame count " + frameCount);

			triggerFrame = false;

//            cout << "triggering frame" << endl;

			ofxMPEEventArgs e;
			e.message = "";
			e.frame = frameCount;
			ofNotifyEvent(ofxMPEEvents.mpeFrame, e);

			if(!simulationMode){
				done();
			}
		}

		unlock();
    }

    //cout << ofGetWidth() << " :: " << lWidth << "  " << ofGetHeight() << " :: " << lHeight << endl;
    if(ofGetWindowPositionX() != xOffset || ofGetWindowPositionY() != yOffset || ofGetWidth() != lWidth || ofGetHeight() != lHeight){
        setupViewport();
    }
}
Exemple #12
0
void MVRenderArea::paint()
/****************************************************************************
*
* Function:     MVRenderArea::paint
*
* Description:  This function paints the view with the current clip
*               region. We set the viewport to the coordinate space for
*               the view and then call the render function clipping to
*               each of the clip rectangles in the clip region.
*
****************************************************************************/
{
    MS_obscure();
    setupViewport();
    clipAndRenderView = this;
    clipRgn.traverse(clipAndRender);
    resetViewport();
    MS_show();
}
Exemple #13
0
HRESULT DXApp::onResize(int width, int height) {
	if (!_dxDev)
		return S_FALSE;

	// Release render target and depth-stencil view
	ID3D11RenderTargetView *nullRTV = NULL;
	_dxImmedDC->OMSetRenderTargets(1, &nullRTV, NULL);
	
	if (_depthStencilView) {
		_depthStencilView->Release();
		_depthStencilView = NULL;
	}

	if (_renderTargetView) {
		_renderTargetView->Release();
		_renderTargetView = NULL;
	}

	// Resize swap chain
	_swapChainDesc.BufferDesc.Width = width;
	_swapChainDesc.BufferDesc.Height = height;
	if (_swapChain) 
		_swapChain->ResizeBuffers(_swapChainDesc.BufferCount, _swapChainDesc.BufferDesc.Width, 
			_swapChainDesc.BufferDesc.Height, _swapChainDesc.BufferDesc.Format, _swapChainDesc.Flags);

	// Re-create a depth-stencil view
	_depthStencilDesc.Width = _swapChainDesc.BufferDesc.Width;
	_depthStencilDesc.Height = _swapChainDesc.BufferDesc.Height;

	createDepthStencilView();

	// Re-create a render target 
	createRenderTargetView();

	// Bind the views to the output
	_dxImmedDC->OMSetRenderTargets(1, &_renderTargetView, _depthStencilView);

	// Setup viewport
	setupViewport();

	return S_OK;
}
Exemple #14
0
void GLWidget::paintEvent(QPaintEvent *event)
{
    makeCurrent();
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    glClearColor( 0.0, 0.0, 0.0, 0.0 );

    glShadeModel(GL_SMOOTH);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_MULTISAMPLE);

    static GLfloat lightPosition[4] = { 0.0, 0.0, 0.0, 0.0 };

    glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
    setupViewport(width(), height());

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    glTranslated(xTrans, yTrans, -10.0);
    glRotated(xRot / 16.0, 1.0, 0.0, 0.0);
    glRotated(yRot / 16.0, 0.0, 1.0, 0.0);
    glRotated(zRot / 16.0, 0.0, 0.0, 1.0);

    glScalef(scale, scale, scale);

    //appelle la liste d objet

    //a chaque refresh on affiche le nouveau volume
    Primitive->draw_xyz_repere();
    Primitive->drawingVolume();

    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);

    drawInstructions(&painter);
    painter.end();
}
// --------------------------------------------------------
void TouchWidgetRenderer::drawSceneToFbo( QGLFramebufferObject * fbo, const QPointF & pos, const QSizeF & size, float rotation ) const
{
	glViewport(0,0,fbo->size().width(), fbo->size().height());
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity();
	glOrtho(-0.5, 0.5, -0.5, 0.5, -1.0, 1.0);
	glScalef(1/size.width(), 1/size.height(),0.0f);
	glRotatef(rotation, 0,0, 1);
	glTranslatef(-pos.x(), -pos.y(), 0.0f);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();

	fbo->bind();
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	emit drawScene(); // TODO: insert layer number
	fbo->release();

	// draw to scene
	emit setupViewport();
}
Exemple #16
0
void init()
{
    glClearColor(1.0, 1.0, 1.0, 0.0); // set the background color to white
    glColor3f(1.0, 0.0, 0.0);

    // initialize V, P, and W
    view_transform();
    persp_transform();
    win_transform();

    // prints out the values of V, P, and W for debugging
    //printf("V matrix:\n");
    //for (int i = 0; i < 16; i++) {
    //    if (i%4 == 0) {
    //        printf("\n");
    //    }
    //    printf("[%f],\t", V[i]);
    //}
    //printf("\n");
    //printf("P matrix:\n");
    //for (int i = 0; i < 16; i++) {
    //    if (i%4 == 0) {
    //        printf("\n");
    //    }
    //    printf("[%f],\t", P[i]);
    //}
    //printf("\n");
    //printf("W matrix:\n");
    //for (int i = 0; i < 16; i++) {
    //    if (i%4 == 0) {
    //        printf("\n");
    //    }
    //    printf("[%f],\t", W[i]);
    //}
    //printf("\n");

    setupViewport(520, 520); // setup our initial window
}
Exemple #17
0
void DhQScrollArea::DvhsetupViewport(QWidget* x1) {
  return setupViewport(x1);
}
void CCCameraBase::recalcViewport()
{
    setupViewport( viewportX, viewportY, viewportWidth, viewportHeight, frameBufferID );
}
Exemple #19
0
// Create Direct3D device and swap chain
HRESULT DXApp::initialiseDxDevice() {
	// Get window size
	RECT rc;
	GetClientRect(_hWnd, &rc);
	UINT width = rc.right - rc.left;
	UINT height = rc.bottom - rc.top;

	// Create D3D11 device and swap chain
	UINT createDeviceFlags = 0;
#ifdef _DEBUG
	//createDeviceFlags |= D3D11_CREATE_DEVICE_DEBUG;
#endif
	ZeroMemory(&_swapChainDesc, sizeof(_swapChainDesc));
	_swapChainDesc.BufferDesc.Width = width;
	_swapChainDesc.BufferDesc.Height = height;
	_swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
	_swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
	_swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R16G16B16A16_FLOAT; // DXGI_FORMAT_R8G8B8A8_UNORM; // 
	_swapChainDesc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
	_swapChainDesc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;

	// No multisampling
	_swapChainDesc.SampleDesc.Count = 1;
	_swapChainDesc.SampleDesc.Quality = 0;

	_swapChainDesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
	_swapChainDesc.BufferCount = 1;
	_swapChainDesc.OutputWindow = _hWnd;
	_swapChainDesc.Windowed = true;
	_swapChainDesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
	_swapChainDesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;

	// Try to create a hardware accelerated device
	const D3D_FEATURE_LEVEL featureLevel[] = { D3D_FEATURE_LEVEL_11_0, D3D_FEATURE_LEVEL_10_0 };
	HRESULT hr = D3D11CreateDeviceAndSwapChain(
		NULL, // Primary graphics adapter
		D3D_DRIVER_TYPE_HARDWARE, // Use graphics hardware
		NULL, // Use hardware rasteriser
		createDeviceFlags, // Debug flags
		featureLevel, // Feature level
		2, // Elements in the feature level
		D3D11_SDK_VERSION, // SDK version
		&_swapChainDesc, // Description of the swap chain
		&_swapChain, // Returns the created swap chain
		&_dxDev, // Returns the created device
		NULL, // Returns feature level
		&_dxImmedDC // Returns the Device Context 
		);

	if (FAILED(hr)) {
		// If failed, try to create a reference device
		D3D11CreateDeviceAndSwapChain(NULL, D3D_DRIVER_TYPE_REFERENCE, NULL, createDeviceFlags, 
			NULL, 0, D3D11_SDK_VERSION, &_swapChainDesc, &_swapChain, &_dxDev, NULL, &_dxImmedDC);
		
		MessageBox(_hWnd, L"No DX10 hardware acceleration found.\nSwitching to REFERENCE driver (very slow).", L"Warning", MB_OK|MB_ICONWARNING);
	}


	// Create a depth - stencil view
	_depthStencilDesc.Width = width;
	_depthStencilDesc.Height = height;
	_depthStencilDesc.MipLevels = 1;
	_depthStencilDesc.ArraySize = 1;
	_depthStencilDesc.Format = DXGI_FORMAT_D16_UNORM;
	_depthStencilDesc.SampleDesc = _swapChainDesc.SampleDesc;
	_depthStencilDesc.Usage = D3D11_USAGE_DEFAULT;
	_depthStencilDesc.BindFlags = D3D11_BIND_DEPTH_STENCIL;
	_depthStencilDesc.CPUAccessFlags = 0;
	_depthStencilDesc.MiscFlags = 0;

	createDepthStencilView();

	// Create a render target view
	createRenderTargetView();

	// Bind the views to the output
	_dxImmedDC->OMSetRenderTargets(1, &_renderTargetView, _depthStencilView);

	// Setup viewport
	setupViewport();

	return S_OK;
}
Exemple #20
0
void TrackerArenaForm::resizeGL(int width, int height)
{
	qDebug() << "TrackerArenaForm::resizeGL (" << width << ", " << height << ")";
	setupViewport(width, height);
}
void CCCameraBase::refreshViewport()
{
    setupViewport( this );
}
void CCCameraBase::setupViewport(const CCCameraBase *inCamera)
{
    setupViewport( inCamera->cameraX, inCamera->cameraY, inCamera->cameraW, inCamera->cameraH );
}
Exemple #23
0
void IMUView::resizeGL(int width, int height)
{
	setupViewport(width, height);
}
// 调整视口大小
void MyGLWidget::resizeGL(int w, int h)
{
    setupViewport(w, h);
}
void MyGLWidget::paintEvent(QPaintEvent *)
{
    // 在当前窗口中进行OpenGL的绘制
    makeCurrent();
    // 将模型视图矩阵压入堆栈
    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();

    // 以下是以前initializeGL()函数中的全部内容
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glShadeModel(GL_SMOOTH);
    glClearDepth(1.0);
    glEnable(GL_DEPTH_TEST);

    textures[0] = bindTexture(QPixmap("../myOpenGL/side1.png"));
    textures[1] = bindTexture(QPixmap("../myOpenGL/side2.png"));
    textures[2] = bindTexture(QPixmap("../myOpenGL/side3.png"));
    glEnable(GL_TEXTURE_2D);

    // 该函数中是以前resizeGL()函数中的全部内容
    setupViewport(width(), height());

    // 以下是以前paintGL()函数中的全部内容
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    glLoadIdentity();

    glTranslatef(0.0, 0.0, translate);
    glRotatef(xRot, 1.0, 0.0, 0.0);
    glRotatef(yRot, 0.0, 1.0, 0.0);
    glRotatef(zRot, 0.0, 0.0, 1.0);

    glBindTexture(GL_TEXTURE_2D, textures[2]);
    glBegin(GL_QUADS);
    glTexCoord2f(1.0, 0.0);
    glVertex3f(1.0, 1.0, 1.0);
    glTexCoord2f(1.0, 1.0);
    glVertex3f(1.0, 1.0, -1.0);
    glTexCoord2f(0.0, 1.0);
    glVertex3f(-1.0, 1.0, -1.0);
    glTexCoord2f(0.0, 0.0);
    glVertex3f(-1.0, 1.0, 1.0);
    glEnd();
    glBindTexture(GL_TEXTURE_2D, textures[1]);
    glBegin(GL_QUADS);
    glTexCoord2f(1.0, 0.0);
    glVertex3f(1.0, -1.0, 1.0);
    glTexCoord2f(1.0, 1.0);
    glVertex3f(1.0, -1.0, -1.0);
    glTexCoord2f(0.0, 1.0);
    glVertex3f(-1.0, -1.0, -1.0);
    glTexCoord2f(0.0, 0.0);
    glVertex3f(-1.0, -1.0, 1.0);
    glEnd();
    glBindTexture(GL_TEXTURE_2D, textures[0]);
    glBegin(GL_QUADS);
    glTexCoord2f(1.0, 1.0);
    glVertex3f(1.0, 1.0, 1.0);
    glTexCoord2f(0.0, 1.0);
    glVertex3f(-1.0, 1.0, 1.0);
    glTexCoord2f(0.0, 0.0);
    glVertex3f(-1.0, -1.0, 1.0);
    glTexCoord2f(1.0, 0.0);
    glVertex3f(1.0, -1.0, 1.0);
    glEnd();

    // 关闭启用的功能并弹出模型视图矩阵
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_TEXTURE_2D);
    glMatrixMode(GL_MODELVIEW);
    glPopMatrix();

    // 下面是2D绘图的内容
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setBrush(Qt::red);
    painter.drawRect(0, 0, 100, 100);
    painter.end();
}
void TutorialApplication::createViewports()
{
    setupViewport(mPrimarySceneMgr);
}
Exemple #27
0
//! [11]
void GLWidget::resizeGL(int width, int height)
{
    setupViewport(width, height);
}
Exemple #28
0
void myReshape(int w, int h) {
    setupViewport(w, h);
    glutPostWindowRedisplay(main_window);  
}
void MultiMgrSample::createViewports()
{
	setupViewport(mPrimarySceneMgr);
}
Exemple #30
0
/* init()
 *
 * Set up background, clearcolor, call setupViewport(width, height).
 */
void init() {
    // glClearColor(8.0, 0.4, 0.0, 1.0);
    glClearColor(0, 0, 0, 1);
    glColor3f(0.5, 0.5, 0.5);
    setupViewport(INITIAL_WIDTH, INITIAL_HEIGHT);

    LookAtX = LookAtY = LookAtZ = 0.0f;

    /***** initialize matrix transforms *****/
 
    // Initial entries for translation matrix
    float ttv_entries[16] = { 1, 0, 0, 0,
			      0, 1, 0, 0,
			      0, 0, 1, 0,
			      0, 0, 0, 1 };
    TranslateToViewer << ttv_entries;
    // Initial entries for first rotation matrix
    float rot1[16] = { 0, 0, 0, 0,
		       0, 0, 0, 0,
		       0, 0, 1, 0,
		       0, 0, 0, 1 };
    Rotate1 << rot1;
    // Initial entries for second rotation matrix
    float rot2[16] = { 0, 0, 0, 0,
		       0, 1, 0, 0,
		       0, 0, 0, 0,
		       0, 0, 0, 1 };
    Rotate2 << rot2;
    // Initial entries for third rotation matrix
    float rot3[16] = { 1, 0, 0, 0,
		       0, 0, 0, 0,
		       0, 0, 0, 0,
		       0, 0, 0, 1 };
    Rotate3 << rot3;
    // Matrix to flip handedness
    float fh[16] = { 1, 0, 0, 0,
		     0, -1, 0, 0,
		     0, 0, 1, 0,
		     0, 0, 0, 1 };
    FlipHandedness << fh;
    // Initial entries for P
    float pentries[] = { ViewPlaneDist, 0, 0, 0,
			 0, ViewPlaneDist, 0, 0, 
			 0, 0, 0, 1,
			 0, 0, 0, 0 };
    P << pentries;
    // Initial entries for W
    float ws[] = { 0, 0, 0, 0,
		   0, 0, 0, 0,
		   0, 0, 1, 0,
		   0, 0, 0, 1 };
    W << ws;
 
    // Calculate the view pipeline for first time
    computeViewerAngle(0);
    computePerspectiveMatrix(0);
    computeWindowMatrix(0);

    V = TranslateToViewer * Rotate1 * Rotate2 * Rotate3 * FlipHandedness;

}