Example #1
0
void GLWidget::setMode(DISPLAY_MODE mode)
{
    m_displayMode = mode;

    setViewport();
    paintGL();
}
Example #2
0
void GLWidget::setZoom(double zoom)
{
    m_zoomFactor = zoom;
    setViewport();

    repaint();
}
Example #3
0
File: board.c Project: verq/runners
void display_runners_view() {
	setViewport(0, 0, width, height);

	glPushMatrix();
	glLoadIdentity();

	Man* looker = runners[chosen_runner];

	double angle;
	if (looker -> turn_angle == 0) angle = 0;
	else if (looker -> turn_angle == 180.0) angle = -PI;
	else angle = -looker -> turn_angle * PI / 180.0;

	if (view_mode == RUNNERS_EYES) {
		gluLookAt(looker -> head_x, looker -> head_y, looker -> head_z, looker -> head_x + cos(angle), looker -> head_y, looker -> head_z + sin(angle), 0.0,  1.0,  0.0);
	} else {
		double behind_shift = 10.0;
		if (looker -> running_phase == FORWARD) {
			gluLookAt(looker -> head_x - behind_shift, looker -> head_y, looker -> head_z, looker -> head_x + cos(angle), looker -> head_y, looker -> head_z + sin(angle), 0.0,  1.0,  0.0);
		} else if (looker -> running_phase == FORWARD_TURN || looker -> running_phase == BACKWARD_TURN) {
			gluLookAt(looker -> head_x - behind_shift * cos(angle), looker -> head_y, looker -> head_z - behind_shift * sin(angle), looker -> head_x - cos(angle), looker -> head_y, looker -> head_z - sin(angle), 0.0,  1.0,  0.0);
		} else if (looker -> running_phase == BACKWARD) {
			gluLookAt(looker -> head_x + behind_shift, looker -> head_y, looker -> head_z, looker -> head_x + cos(angle), looker -> head_y, looker -> head_z + sin(angle), 0.0,  1.0,  0.0);
		}
	}
	draw_board_and_runners();
	glPopMatrix();
}
Example #4
0
gl::Error Blit9::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest)
{
    IDirect3DTexture9 *texture = NULL;
    gl::Error error = copySurfaceToTexture(source, sourceRect, &texture);
    if (error.isError())
    {
        return error;
    }

    IDirect3DDevice9 *device = mRenderer->getDevice();

    saveState();

    device->SetTexture(0, texture);
    device->SetRenderTarget(0, dest);

    setViewport(sourceRect, xoffset, yoffset);

    setCommonBlitState();

    error = setFormatConvertShaders(destFormat);
    if (!error.isError())
    {
        render();
    }

    SafeRelease(texture);

    restoreState();

    return error;
}
Example #5
0
void LfpDisplayCanvas::renderOpenGL()
{
	
	glClear(GL_COLOR_BUFFER_BIT); // clear buffers to preset values

	//drawTicks();

	updateScreenBuffer();

	for (int i = 0; i < nChans; i++)
	{
		bool isSelected = false;

		if (selectedChan == i)
			isSelected = true;

		if (checkBounds(i)) {
			setViewport(i);
			//drawBorder(isSelected);
			drawChannelInfo(i,isSelected);
			drawWaveform(i,isSelected);
		}	
	}
	drawScrollBars();

	//std::cout << "Render." << std::endl;
}
Example #6
0
void mainInit()
{
    glClearColor(1.0,1.0,1.0,0.0);
	glColor3f(0.0f,0.0f,0.0f);
	setWindow();
	setViewport(0, windowWidth, 0, windowHeight);

	// habilita o z-buffer
	glEnable(GL_DEPTH_TEST);
    initTexture("Models\\Sea.bmp\0", &texture, &type);

    // inicializa todos os modelos 3D que serĂ£o multiplicados
    diglettModel = (GLMmodel*)malloc(sizeof(GLMmodel));
    scytherModel = (GLMmodel*)malloc(sizeof(GLMmodel));
    sharpedoModel = (GLMmodel*)malloc(sizeof(GLMmodel));
    snorlaxModel = (GLMmodel*)malloc(sizeof(GLMmodel));
    cube = (GLMmodel*)malloc(sizeof(GLMmodel));
    cube_hole = (GLMmodel*)malloc(sizeof(GLMmodel));
    cube_crack = (GLMmodel*)malloc(sizeof(GLMmodel));

    load_new_model("Models/Diglett.obj", &diglettModel);
    load_new_model("Models/Scyther.obj", &scytherModel);
    load_new_model("Models/Sharpedo.obj", &sharpedoModel);
    load_new_model("Models/Snorlax.obj", &snorlaxModel);
    load_new_model("Models/cube.obj", &cube);
    load_new_model("Models/cube_hole.obj", &cube_hole);
    load_new_model("Models/cube_crack.obj", &cube_crack);
}
Example #7
0
void onWindowReshape(int x, int y)
{
    windowWidth = x;
	windowHeight = y;
	setWindow();
	setViewport(0, windowWidth, 0, windowHeight);
}
Example #8
0
RCanvas::RCanvas(Context *context, QWidget *parent) : QGraphicsView(parent), context(context)
{
    // no frame, its ugly
    setFrameStyle(QFrame::NoFrame);

#ifdef Q_OS_LINUX // mac and windows both have issues. sigh.
    // Enabled on Linux depending on Open GL version
    if (QGLFormat::openGLVersionFlags().testFlag(QGLFormat::OpenGL_Version_2_0)) {
        setViewport(new QGLWidget( QGLFormat(QGL::SampleBuffers)));
        setViewportUpdateMode(QGraphicsView::FullViewportUpdate);
    }
#endif

    // allow to click and drag
    setDragMode(QGraphicsView::ScrollHandDrag);

    // add a scene
    scene = new QGraphicsScene(this);
    this->setScene(scene);

    // turn on antialiasing too
    setRenderHint(QPainter::Antialiasing, true);

    // set colors etc
    configChanged(CONFIG_APPEARANCE);

    // connect
    connect(context, SIGNAL(configChanged(qint32)), this, SLOT(configChanged(qint32)));
}
Example #9
0
bool Blit9::formatConvert(IDirect3DSurface9 *source, const RECT &sourceRect, GLenum destFormat, GLint xoffset, GLint yoffset, IDirect3DSurface9 *dest)
{
    IDirect3DTexture9 *texture = copySurfaceToTexture(source, sourceRect);
    if (!texture)
    {
        return false;
    }

    IDirect3DDevice9 *device = mRenderer->getDevice();

    saveState();

    device->SetTexture(0, texture);
    device->SetRenderTarget(0, dest);

    setViewport(sourceRect, xoffset, yoffset);

    setCommonBlitState();
    if (setFormatConvertShaders(destFormat))
    {
        render();
    }

    SafeRelease(texture);

    restoreState();

    return true;
}
Example #10
0
MainWidget::MainWidget(QWidget *parent)
    : QDeclarativeView(parent)
{
    // Switch to fullscreen in device
#if defined(Q_OS_SYMBIAN) || defined(Q_WS_MAEMO_5)
    setWindowState(Qt::WindowFullScreen);
#endif

    setResizeMode(QDeclarativeView::SizeRootObjectToView);

    // Register Tile to be available in QML
    qmlRegisterType<Tile>("gameCore", 1, 0, "Tile");

    // Setup context
    m_context = rootContext();
    m_context->setContextProperty("mainWidget", this);
    m_context->setContextProperty("gameData", &m_gameData);

    // Set view optimizations not already done for QDeclarativeView
    setAttribute(Qt::WA_OpaquePaintEvent);
    setAttribute(Qt::WA_NoSystemBackground);

    // Make QDeclarativeView use OpenGL backend
    QGLWidget *glWidget = new QGLWidget(this);
    setViewport(glWidget);
    setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

    // Open root QML file
    setSource(QUrl(filename));
}
Example #11
0
static int l_RenderWindow_setViewport(lua_State *L) {
    auto renderWindow = lua_torenderwindow(L, 1);
    if (lua_istable(L, 2)) {
	//x offset
	lua_getfield(L, -1, "x");
	integerType xOffset = luaL_checkint(L, -1);
	lua_pop(L, 1);

	//y offset
	lua_getfield(L, -1, "y");
	integerType yOffset = luaL_checkint(L, -1);
	lua_pop(L, 1);

	//width value
	lua_getfield(L, -1, "w");
	integerType width = luaL_checkint(L, -1);
	lua_pop(L, 1);

	//height value
	lua_getfield(L, -1, "h");
	integerType height = luaL_checkint(L, -1);
	lua_pop(L, 1);

	renderWindow->setViewport(xOffset, yOffset,
				  width, height);
    }
    else {
	luaL_error(L, "setViewport function takes a table as its second argument.");
    }
    return 0;
}
Example #12
0
///////////////////////////////////////////////////////////////////////////////
// draw 2D/3D scene
///////////////////////////////////////////////////////////////////////////////
void ModelGL::draw()
{
    drawSub1();
    drawSub2();

    if(windowSizeChanged)
    {
        setViewport(0, 0, windowWidth, windowHeight);
        windowSizeChanged = false;
    }

    if(drawModeChanged)
    {
        if(drawMode == 0)           // fill mode
        {
            glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
            glEnable(GL_DEPTH_TEST);
            glEnable(GL_CULL_FACE);
        }
        else if(drawMode == 1)      // wireframe mode
        {
            glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
            //glDisable(GL_DEPTH_TEST);
            glDisable(GL_CULL_FACE);
        }
        else if(drawMode == 2)      // point mode
        {
            glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
            //glDisable(GL_DEPTH_TEST);
            glDisable(GL_CULL_FACE);
        }
        drawModeChanged = false;
    }
}
Example #13
0
gl::Error Blit9::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
{
    IDirect3DTexture9 *texture = NULL;
    gl::Error error = copySurfaceToTexture(source, getSurfaceRect(source), &texture);
    if (error.isError())
    {
        return error;
    }

    IDirect3DDevice9 *device = mRenderer->getDevice();

    saveState();

    device->SetTexture(0, texture);
    device->SetRenderTarget(0, dest);

    setVertexShader(SHADER_VS_STANDARD);
    setPixelShader(SHADER_PS_PASSTHROUGH);

    setCommonBlitState();
    device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
    device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

    setViewport(getSurfaceRect(dest), 0, 0);

    render();

    SafeRelease(texture);

    restoreState();

    return gl::Error(GL_NO_ERROR);
}
Example #14
0
void MainWindow::setRenderingSystem()
{
    QWidget *viewport = 0;

#ifndef QT_NO_OPENGL
    if (Colors::openGlRendering) {
        QGLWidget *glw = new QGLWidget(QGLFormat(QGL::SampleBuffers));
        if (Colors::noScreenSync)
            glw->format().setSwapInterval(0);
        glw->setAutoFillBackground(false);
        viewport = glw;
        setCacheMode(QGraphicsView::CacheNone);
        if (Colors::verbose)
            qDebug() << "- using OpenGL";
    } else // software rendering
#endif
    {
        // software rendering
        viewport = new QWidget;
        setCacheMode(QGraphicsView::CacheBackground);
        if (Colors::verbose)
            qDebug() << "- using software rendering";
    }

    setViewport(viewport);
}
Example #15
0
void View::initGL()
{
	qDebug( "* OpenGL:" );
	setViewportUpdateMode( QGraphicsView::FullViewportUpdate );
	setFrameShape( QFrame::NoFrame );

	QGLFormat glFormat( QGL::DoubleBuffer | QGL::DepthBuffer | QGL::Rgba | QGL::DirectRendering );
	glFormat.setVersion( 2, 1 );
//	glFormat.setSwapInterval( 1 );

	QSettings settings;
	glFormat.setSampleBuffers( settings.value( "sampleBuffers", false ).toBool() );

	mGLWidget = new GLWidget( glFormat, this );
	setViewport( mGLWidget );

	const GLubyte * vendorGL = glGetString( GL_VENDOR );
	qDebug( "\t* %s:\t%s", qPrintable(tr("Vendor")), vendorGL );
	const GLubyte * rendererGL = glGetString( GL_RENDERER );
	qDebug( "\t* %s:\t%s", qPrintable(tr("Renderer")), rendererGL );
	const GLubyte * versionGL = glGetString( GL_VERSION );
	qDebug( "\t* %s:\t%s", qPrintable(tr("Version")), versionGL );
	const GLubyte * glslVersionGL = glGetString( GL_SHADING_LANGUAGE_VERSION );
	qDebug( "\t* %s:\t%s", qPrintable(tr("GLSL version")), glslVersionGL );
//	const GLubyte * extensionsGL = glGetString( GL_EXTENSIONS );
//	qDebug( "\t* %s:\t%s", qPrintable(tr("Supported extensions")), extensionsGL );
}
Example #16
0
bool Blit::boxFilter(IDirect3DSurface9 *source, IDirect3DSurface9 *dest)
{
    IDirect3DTexture9 *texture = copySurfaceToTexture(source, getSurfaceRect(source));
    if (!texture)
    {
        return false;
    }

    IDirect3DDevice9 *device = getDevice();

    saveState();

    device->SetTexture(0, texture);
    device->SetRenderTarget(0, dest);

    setVertexShader(SHADER_VS_STANDARD);
    setPixelShader(SHADER_PS_PASSTHROUGH);

    setCommonBlitState();
    device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
    device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

    setViewport(getSurfaceRect(dest), 0, 0);

    render();

    texture->Release();

    restoreState();

    return true;
}
Example #17
0
void screenInit()
{
    glColor3f(0.0f,0.0f,0.0f);
	setWindow();
	setViewport(0, windowWidth, 0, windowHeight);

    initTexture("Screens\\InitialScreen.bmp", &initialScreenTexture, &initialScreenType);
}
Example #18
0
bool Game::startup()
{
    if (_state != UNINITIALIZED)
        return false;

    setViewport(Rectangle(0.0f, 0.0f, (float)_width, (float)_height));
    RenderState::initialize();
    FrameBuffer::initialize();

    _animationController = new AnimationController();
    _animationController->initialize();

    _audioController = new AudioController();
    _audioController->initialize();

    _physicsController = new PhysicsController();
    _physicsController->initialize();

    _aiController = new AIController();
    _aiController->initialize();

    _scriptController = new ScriptController();
    _scriptController->initialize();

    // Load any gamepads, ui or physical.
    loadGamepads();

    // Set the script callback functions.
    if (_properties)
    {
        Properties* scripts = _properties->getNamespace("scripts", true);
        if (scripts)
        {
            const char* callback;
            while ((callback = scripts->getNextProperty()) != NULL)
            {
                std::string url = scripts->getString();
                std::string file;
                std::string id;
                splitURL(url, &file, &id);

                if (file.size() <= 0 || id.size() <= 0)
                {
                    GP_ERROR("Invalid %s script callback function '%s'.", callback, url.c_str());
                }
                else
                {
                    _scriptController->loadScript(file.c_str());
                    _scriptController->registerCallback(callback, id.c_str());
                }
            }
        }
    }

    _state = RUNNING;

    return true;
}
Example #19
0
QcScrollArea::QcScrollArea() :
    paint(false),
    painting(false)
{
    setViewport( new QWidget() );
    scrollWidget = new QcScrollWidget( viewport() );
    scrollWidget->installEventFilter( this );
    updateScrollBars();
}
Example #20
0
EvasCanvas::EvasCanvas( int width, int height )
    :Trackable( "EvasCanvas" )
{
    AllocTag( this, "EvasCanvas" );
    Dout( dc::notice, "EvasCanvas::EvasCanvas - creating new Evas" );
    o = evas_new();
    resize( width, height );
    setViewport( 0, 0, width, height );
}
Example #21
0
void WaterSample::render(float dt)
{
	//update the refract buffer
	auto defaultBuffer = m_refractBuffer->bind();
	auto defaultViewport = getViewport();
	setViewport(gp::Rectangle(bufferSize, bufferSize));

	m_clipPlane.y = -1.f;
	m_clipPlane.w = m_waterHeight + waterOffset;
	clear(CLEAR_COLOR_DEPTH, clearColour, 1.0f, 0);
	m_scene->visit(this, &WaterSample::m_drawScene, false);

	//switch plane direction and camera, and update reflection buffer
	m_reflectBuffer->bind();
	m_clipPlane.y = 1.f;
	m_clipPlane.w = -m_waterHeight + waterOffset;

	auto defaultCam = m_scene->getActiveCamera();
	m_scene->setActiveCamera(m_reflectCamNode->getFirstChild()->getCamera());
	//store the mvp matrix here as it is only valid when reflect camera is active
	m_worldViewProjectionReflection = m_scene->findNode("Water")->getWorldViewProjectionMatrix();
	clear(CLEAR_COLOR_DEPTH, clearColour, 1.0f, 0);
	m_scene->visit(this, &WaterSample::m_drawScene, false);

	//draw the final scene
	defaultBuffer->bind();
	setViewport(defaultViewport);
	m_clipPlane = gp::Vector4::zero();
	m_scene->setActiveCamera(defaultCam);
	clear(CLEAR_COLOR_DEPTH, clearColour, 1.0f, 0);
	m_scene->visit(this, &WaterSample::m_drawScene, true);

	//draw preview if enabled
	if (m_showBuffers)
	{
		m_refractBatch->start();
		m_refractBatch->draw(gp::Vector3(0.f, 4.f, 0.f), gp::Rectangle(bufferSize, bufferSize), gp::Vector2(426.f, 240.f));
		m_refractBatch->finish();

		m_reflectBatch->start();
		m_reflectBatch->draw(gp::Vector3(430.f, 4.f, 0.f), gp::Rectangle(bufferSize, bufferSize), gp::Vector2(426.f, 240.f));
		m_reflectBatch->finish();
	}
}
Example #22
0
File: board.c Project: verq/runners
void display_top_view() {
	setViewport(1 * width / 3, 1 * height / 4, width, height);

	glPushMatrix();
	glLoadIdentity();
	gluLookAt(-50, 250, -70, -50, 0, -70, 0, 0, 1);
	draw_board_and_runners();

	glPopMatrix();
}
Example #23
0
void GLWidget::zoomInOut(bool in)
{
    if(m_zoomFactor == 0) {
        m_zoomFactor = 1;
    }
    m_zoomFactor *= (in)?1.25:0.8;
    setViewport();

    repaint();
}
void ElevatorSimRenderWindow::draw() {
   SimulationState& simState = SimulationState::acquire();

   if(!valid()) {
      /* init, this code only gets executed the first time draw() is called */

      simState.lockBASM(); /* CRITICAL SECTION START */
      simState.initRenderObjs();
      simState.unlockBASM(); /* CRITICAL SECTION STOP */

      glInit();
      setViewport();
   }

   /* draw */
   glClearColor(0.0, 0.0, 0.0, 0.0);
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

   glMatrixMode(GL_PROJECTION);
   glLoadIdentity();

   /* TODO: make these constants somewhere */
   gluPerspective(45.0f, (GLfloat)w()/(GLfloat)h(), 0.1f, 500.0f);

   simState.lockBASM(); /* CRITICAL SECTION START */
   simState.getCameraManager().render();

   glMatrixMode(GL_MODELVIEW);
   glEnable(GL_LIGHTING);
   glEnable(GL_LIGHT0);

   simState.getBuilding().render();

   int curFPS = simState.getTimeManager().getFPS();
   int curTotalFrames = simState.getTimeManager().getTotalFrames();

   SimulationState::StateKind currentSimState = simState.getStateUnsafe();
   simState.unlockBASM(); /* CRITICAL SECTION STOP */


   if(currentSimState == SimulationState::SIMULATION_RUNNING &&
            m_bRenderFPS) {
      drawFPS(curFPS, curTotalFrames);
   }

   /* glTranslatef(0.f, 3.f, 3.f);
    * glCallList(cRenderObjs::OBJ_HUMAN); */

   GLenum err = glGetError();
   if ( err != GL_NO_ERROR ) {
      std::stringstream dbgSS;
      dbgSS << "GLGETERROR= " << (int) err << std::endl;
      LOG_ERROR( Logger::SUB_RENDER, sstreamToBuffer(dbgSS) );
   }
}
Example #25
0
/*----------RenderScene---------------------*/
void Layout(int n, int m, float Width, float Height)
{
	for(int i = 0; i<n; i++)
		for(int j = 0; j<n; j++)
		{
			setViewport(i*Width,(i+1)*Width,j*Height,(j+1)*Height);
			//render layout function
			//Tiling();//Render the tiling sequence
			Truchlet();
		}
}
Example #26
0
ContactList::ContactList(const QRectF &rect, QGraphicsObject *parent)
    : PlexyDesk::ScrollWidget(rect, parent), d(new PrivateContactList) {
  d->mFrame =
      new PlexyDesk::DesktopWidget(QRectF(rect.x(), rect.y(), 0.0, 24), this);
  d->mFrame->setWidgetFlag(PlexyDesk::DesktopWidget::SHADOW, false);
  d->mFrame->setWidgetFlag(PlexyDesk::DesktopWidget::BACKGROUND, false);
  d->mFrame->setFlag(QGraphicsItem::ItemIsMovable, false);
  setFlag(QGraphicsItem::ItemIsMovable, false);

  setViewport(d->mFrame);
}
Example #27
0
void displayObject()
{
    setMaterial();
    setLighting();
    setViewport();
    setCamera();
    //startDrawing
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
    sate();//memanggil fungsi menggambar objek sate
    glFlush();//mengirim semua objek untuk dirender
}
void BakedOpRenderer::startFrame(uint32_t width, uint32_t height, const Rect& repaintRect) {
    LOG_ALWAYS_FATAL_IF(mRenderTarget.frameBufferId != 0, "primary framebufferId must be 0");
    mRenderState.bindFramebuffer(0);
    setViewport(width, height);

    if (!mOpaque) {
        clearColorBuffer(repaintRect);
    }

    mRenderState.debugOverdraw(true, true);
}
Example #29
0
void renderScene(void)
{
	static float angle = 0.0;
	glClear(GL_COLOR_BUFFER_BIT);
	setWindow(-3.0,3.0,-3.0,3.0);
	setViewport(0,screenWidth,0,screenHeight);
	glTranslated(0.0,0.0,-2.0);
	glRotated(angle,0.0,1.0,0.0);
	house.draw();
	angle+= 0.1;
	glFlush();
}
Example #30
0
bool		Application::exec(const std::string &host, int port)
{
  if (!this->init(host, port))
    return false;

  setViewport("MenuScene");

  _root->addFrameListener(this);
  _root->startRendering();

  return true;
}