当前位置: 首页>>代码示例>>C++>>正文


C++ setViewport函数代码示例

本文整理汇总了C++中setViewport函数的典型用法代码示例。如果您正苦于以下问题:C++ setViewport函数的具体用法?C++ setViewport怎么用?C++ setViewport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setViewport函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: setViewport

void GLWidget::setMode(DISPLAY_MODE mode)
{
    m_displayMode = mode;

    setViewport();
    paintGL();
}
开发者ID:fieldOfView,项目名称:uv-mapper,代码行数:7,代码来源:glwidget.cpp

示例2: display_runners_view

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();
}
开发者ID:verq,项目名称:runners,代码行数:28,代码来源:board.c

示例3: copySurfaceToTexture

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;
}
开发者ID:Andrel322,项目名称:gecko-dev,代码行数:32,代码来源:Blit9.cpp

示例4: glClear

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;
}
开发者ID:karlssonm,项目名称:GUI,代码行数:27,代码来源:LfpDisplayCanvas.cpp

示例5: mainInit

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);
}
开发者ID:lahagemann,项目名称:digdug,代码行数:28,代码来源:main.cpp

示例6: onWindowReshape

void onWindowReshape(int x, int y)
{
    windowWidth = x;
	windowHeight = y;
	setWindow();
	setViewport(0, windowWidth, 0, windowHeight);
}
开发者ID:lahagemann,项目名称:digdug,代码行数:7,代码来源:main.cpp

示例7: QGraphicsView

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)));
}
开发者ID:GoldenCheetah,项目名称:GoldenCheetah,代码行数:29,代码来源:RCanvas.cpp

示例8: copySurfaceToTexture

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;
}
开发者ID:Drakey83,项目名称:steamlink-sdk,代码行数:29,代码来源:Blit9.cpp

示例9: QDeclarativeView

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));
}
开发者ID:MilanLi,项目名称:Reversi-Game,代码行数:30,代码来源:mainwidget.cpp

示例10: l_RenderWindow_setViewport

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;
}
开发者ID:benzap,项目名称:Kampf,代码行数:31,代码来源:l_RenderWindow.cpp

示例11: drawSub1

///////////////////////////////////////////////////////////////////////////////
// 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;
    }
}
开发者ID:andreaswatch,项目名称:dizuo,代码行数:37,代码来源:ModelGL.cpp

示例12: QGLWidget

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);
}
开发者ID:mortenelund,项目名称:qt,代码行数:26,代码来源:mainwindow.cpp

示例13: qDebug

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 );
}
开发者ID:splatterlinge,项目名称:Splatterlinge,代码行数:27,代码来源:View.cpp

示例14: copySurfaceToTexture

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;
}
开发者ID:0omega,项目名称:platform_external_webkit,代码行数:32,代码来源:Blit.cpp

示例15: screenInit

void screenInit()
{
    glColor3f(0.0f,0.0f,0.0f);
	setWindow();
	setViewport(0, windowWidth, 0, windowHeight);

    initTexture("Screens\\InitialScreen.bmp", &initialScreenTexture, &initialScreenType);
}
开发者ID:lahagemann,项目名称:digdug,代码行数:8,代码来源:main.cpp


注:本文中的setViewport函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。