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


C++ Quad::draw方法代码示例

本文整理汇总了C++中Quad::draw方法的典型用法代码示例。如果您正苦于以下问题:C++ Quad::draw方法的具体用法?C++ Quad::draw怎么用?C++ Quad::draw使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Quad的用法示例。


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

示例1: display

///Displays
void display(){
    ///--- Clears the color buffer so that we don't display garbage
    glViewport(0,0,windowDimension,windowDimension);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        ///--- Upload viewing matrices externally
        GLuint pid = quad.getProgramID();
        glUseProgram(pid);
            mat4 MODEL = mat4::Identity();
            glUniformMatrix4fv(glGetUniformLocation(pid, "MODEL"), 1, GL_FALSE, MODEL.data());

            float theta_rad = M_PI/180.0*theta;
            //vec3 camera_pos( camX, camY, 2*sin(theta_rad));
            camX = camX + rateX;
            camY = camY + rateY;
            camZ = camZ + rateZ;
            vec3 camera_pos(camX,camY,camZ);
            mat4 VIEW = Eigen::lookAt( camera_pos, vec3(lookX,lookY,lookZ), vec3(0,0,1) ); //< "z" up on screen
            glUniformMatrix4fv(glGetUniformLocation(pid, "VIEW"), 1, GL_FALSE, VIEW.data());

            mat4 PROJ = Eigen::perspective(75.0f, windowDimension/(float)windowDimension, 0.1f, 10.0f);
            glUniformMatrix4fv(glGetUniformLocation(pid, "PROJ"), 1, GL_FALSE, PROJ.data());
        glUseProgram(pid);
    ///--- calls the quad.draw() method which displays the terrain quad (?takes in the ModelViewProjection matrices?)
    quad.draw();
}
开发者ID:4444jw4444,项目名称:Ray-Tracer-Scene-Renderer,代码行数:27,代码来源:main.cpp

示例2: drawOverlay

	void drawOverlay()
	{
		if (overlayTex == TEX::ID(0))
			return;

		SimpleShader &shader = shState->shaders().simple;
		shader.bind();
		shader.applyViewportProj();
		shader.setTexSize(overlayTexSize);
		shader.setTranslation(Vec2i());

		glState.blend.pushSet(true);

		TEX::bind(overlayTex);
		screenQuad.draw();

		glState.blend.pop();
	}
开发者ID:xperia64,项目名称:android-mkxp,代码行数:18,代码来源:graphics.cpp

示例3: blitQuad

	void blitQuad(Quad &quad)
	{
		glState.blendMode.pushSet(BlendNone);
		quad.draw();
		glState.blendMode.pop();
	}
开发者ID:Lobomon,项目名称:mkxp,代码行数:6,代码来源:bitmap.cpp

示例4: main


//.........这里部分代码省略.........
			0.0f);
		sceneObject.transform().scale = Vector3(0.5f, 0.5f, 1.0f);
	}

	Material material = Material::Load("install/share/materials/debug_gbuffer.mtl");
	Quad quad;

	

	// Main loop
	while (window.isOpen())
	{
		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed)
			{
				window.close();
				break;
			}
            else if (event.type == sf::Event::Resized)
            {
            	viewport.resize(event.size.width, event.size.height);
            }
		}

		// Update
		scene.update(0.0f);

		// Bind the frame buffer
		//frameBuffer.bind();
		gbuffer.writeTo();
		glEnable(GL_DEPTH_TEST);
		glDepthMask(true);
		glDisable(GL_BLEND);
		glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		// Draw
		for(SceneObjects::iterator sit = scene.begin(); sit != scene.end(); ++sit)
		{
			Components::iterator_range range = sit->components<RenderableComponent>();
			for(Components::iterator cit = range.begin; cit != range.end; ++cit)
			{
				cit->as<RenderableComponent>().draw();
			}
		}
		glUseProgram(0);

		//frameBuffer.unbind();
		//frameBuffer.bindForRead();

		gbuffer.readFrom();
		
		glDisable(GL_DEPTH_TEST);
		glDepthMask(false);
		glEnable(GL_BLEND);
		glBlendFunc(GL_ONE, GL_ONE);
		glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		material.program().use();
		//frameBuffer.bindTargets(material.program());
		material.program().set("diffuse", Texture(gbuffer.target(GBuffer::kDiffuse)));
		quad.draw();
		glUseProgram(0);

		gbuffer.finish();

		//frameBuffer.unbind();

		window.display();

#if 1
		checkGLErrors();
#endif
	}
	
	uchar pixels[800*600*4];

//	const Texture& target = frameBuffer.target("diffuse");
//	target.bind();
	uint target = gbuffer.target(GBuffer::kDiffuse);
	glBindTexture(GL_TEXTURE_2D, target);
	glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, &pixels);
	glBindTexture(GL_TEXTURE_2D, 0);
//	target.unbind();

	sf::Image image;
	image.create(800, 600, pixels);
	image.saveToFile("screenshot.png");

	TextureCache::CleanUp();

#if 1
	checkGLErrors();
#endif

	return 0;
}
开发者ID:Dargish,项目名称:SuperMagic,代码行数:101,代码来源:main.cpp

示例5: drawScene

void ColoredCubeApp::drawScene()
{
	D3DApp::drawScene();

	// Restore default states, input layout and primitive topology 
	// because mFont->DrawText changes them.  Note that we can 
	// restore the default states by passing null.
	md3dDevice->OMSetDepthStencilState(0, 0);
	float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f};
	md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff);
    md3dDevice->IASetInputLayout(mVertexLayout);

	// set some variables for the shader
	int foo[1];
	foo[0] = 0;
	// set the point to the shader technique
	D3D10_TECHNIQUE_DESC techDesc;
	mTech->GetDesc(&techDesc);

	//setting the color flip variable in the shader
	mfxFLIPVar->SetRawValue(&foo[0], 0, sizeof(int));

	//draw the lines
	mWVP = xLine.getWorldMatrix()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
	xLine.setMTech(mTech);
	xLine.draw();
	
	mWVP = yLine.getWorldMatrix() *mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
	yLine.setMTech(mTech);
	yLine.draw();

	mWVP = zLine.getWorldMatrix() *mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
	zLine.setMTech(mTech);
	zLine.draw();

	//draw the quad using the "old" method
	//compare how messy this is compared to the objectified geometry classes
	mWVP = quad1.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad1.draw();
    }

	mWVP = quad2.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad2.draw();
    }

	mWVP = quad3.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad3.draw();
    }

	mWVP = quad4.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad4.draw();
    }

	mWVP = quad5.getWorld()*mView*mProj;
	mfxWVPVar->SetMatrix((float*)&mWVP);
    mTech->GetDesc( &techDesc );
	for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);
       quad5.draw();
    }

	for(int i = 0; i < WALL_SIZE; ++i) {
		mWVP = wall[i].getWorld()*mView*mProj;
		mfxWVPVar->SetMatrix((float*)&mWVP);
		mTech->GetDesc( &techDesc );
		for(UINT p = 0; p < techDesc.Passes; ++p)
		{
			mTech->GetPassByIndex( p )->Apply(0);
		   wall[i].draw();
		}
	}

	// We specify DT_NOCLIP, so we do not care about width/height of the rect.
	RECT R = {5, 5, 0, 0};
	mFont->DrawText(0, mFrameStats.c_str(), -1, &R, DT_NOCLIP, BLACK);
	mSwapChain->Present(0, 0);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:

示例6: draw

	void draw()
	{
		if (base.tex.tex == TEX::ID(0))
			return;

		bool windowskinValid = !nullOrDisposed(windowskin);
		bool contentsValid = !nullOrDisposed(contents);

		Vec2i trans = geo.pos() + sceneOffset;

		SimpleAlphaShader &shader = shState->shaders().simpleAlpha;
		shader.bind();
		shader.applyViewportProj();

		if (windowskinValid)
		{
			shader.setTranslation(trans);
			shader.setTexSize(Vec2i(base.tex.width, base.tex.height));

			TEX::bind(base.tex.tex);
			base.quad.draw();

			if (openness < 255)
				return;

			windowskin->bindTex(shader);

			TEX::setSmooth(true);
			ctrlVert.draw(0, ctrlQuads);
			TEX::setSmooth(false);
		}

		if (openness < 255)
			return;

		bool drawCursor = cursorVert.count() > 0 && windowskinValid;

		if (drawCursor || contentsValid)
		{
			/* Translate cliprect from local into screen space */
			IntRect clip = clipRect;
			clip.setPos(clip.pos() + trans);

			glState.scissorBox.push();
			glState.scissorTest.pushSet(true);

			if (rgssVer >= 3)
				glState.scissorBox.setIntersect(clip);
			else
				glState.scissorBox.setIntersect(IntRect(trans, geo.size()));

			IntRect pad = padRect;
			pad.setPos(pad.pos() + trans);

			if (drawCursor)
			{
				Vec2i contTrans = pad.pos();
				contTrans.x += cursorRect->x;
				contTrans.y += cursorRect->y;

				if (rgssVer >= 3)
					contTrans -= contentsOff;

				shader.setTranslation(contTrans);

				TEX::setSmooth(true);
				cursorVert.draw();
				TEX::setSmooth(false);
			}

			if (contentsValid)
			{
				if (rgssVer <= 2)
					glState.scissorBox.setIntersect(clip);

				Vec2i contTrans = pad.pos();
				contTrans -= contentsOff;
				shader.setTranslation(contTrans);

				TEX::setSmooth(false); // XXX
				contents->bindTex(shader);
				contentsQuad.draw();
			}

			glState.scissorBox.pop();
			glState.scissorTest.pop();
		}

		TEX::setSmooth(false); // XXX FIND out a way to eliminate
	}
开发者ID:Alex223124,项目名称:mkxp,代码行数:90,代码来源:windowvx.cpp

示例7: blitQuad

	void blitQuad(Quad &quad)
	{
		glState.blend.pushSet(false);
		quad.draw();
		glState.blend.pop();
	}
开发者ID:Ancurio,项目名称:mkxp,代码行数:6,代码来源:bitmap.cpp

示例8: drawScene

void ColoredCubeApp::drawScene()
{
    int foo[1] = {0};
    switch (gsm->getGameState()) {
    case GameStateManager::START_GAME:
    {
        foo[0] = 1;
        break;
    }
    case GameStateManager::IN_GAME:
    {
        foo[0] = 0;
        break;
    }
    case GameStateManager::END_GAME:
    {
        foo[0] = 1;
        break;
    }
    default:
        foo[0] = 0;
        break;
    }

    mfxBlack_WhiteVar->SetRawValue(&foo[0], 0, sizeof(int));

    D3DApp::drawScene();

    // Restore default states, input layout and primitive topology
    // because mFont->DrawText changes them.  Note that we can
    // restore the default states by passing null.
    md3dDevice->OMSetDepthStencilState(0, 0);
    float blendFactors[] = {0.0f, 0.0f, 0.0f, 0.0f};
    md3dDevice->OMSetBlendState(0, blendFactors, 0xffffffff);
    md3dDevice->IASetInputLayout(mVertexLayout);
    md3dDevice->IASetPrimitiveTopology(D3D10_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

    //Get Camera viewMatrix
    mView = camera.getViewMatrix();
    mProj = camera.getProjectionMatrix();

    // set constants
    mWVP = mView*mProj;
    mfxWVPVar->SetMatrix((float*)&mWVP);

    D3D10_TECHNIQUE_DESC techDesc;
    mTech->GetDesc( &techDesc );
    for(UINT p = 0; p < techDesc.Passes; ++p)
    {
        mTech->GetPassByIndex( p )->Apply(0);

        //mBox.draw();
        //mAxes.draw();
        //mLine.draw();
        //mTriangle.draw();
        mQuad.draw();
        //particleBox.draw();
    }

    mWVP = gameObject1.getWorldMatrix()  *mView*mProj;
    mfxWVPVar->SetMatrix((float*)&mWVP);
    gameObject1.setMTech(mTech);
    gameObject1.draw();

    for (int i = 0; i < MAX_NUM_ENEMIES; i++)
    {
        mWVP = enemyObjects[i].getWorldMatrix()  *mView*mProj;
        mfxWVPVar->SetMatrix((float*)&mWVP);
        enemyObjects[i].setMTech(mTech);
        enemyObjects[i].draw();
    }


    for (int i = 0; i < MAX_NUM_BULLETS; i++)
    {
        mWVP = playerBullets[i].getWorldMatrix()  *mView*mProj;
        mfxWVPVar->SetMatrix((float*)&mWVP);
        playerBullets[i].setMTech(mTech);
        playerBullets[i].draw();
    }

    for (int i = 0; i < MAX_NUM_EXP_PARTICLES; i++)
    {
        mWVP = particles[i].getWorldMatrix()  *mView*mProj;
        mfxWVPVar->SetMatrix((float*)&mWVP);
        particles[i].setMTech(mTech);
        particles[i].draw();
    }

    for (int i = 0; i < MAX_NUM_STARS; i++)
    {
        mWVP = stars[i].getWorldMatrix()  *mView*mProj;
        mfxWVPVar->SetMatrix((float*)&mWVP);
        stars[i].setMTech(mTech);
        stars[i].draw();
    }

    if(gsm->getGameState() == GameStateManager::END_GAME && score > 0) {
        std::wostringstream gameOverString;
        gameOverString.precision(6);
//.........这里部分代码省略.........
开发者ID:SamGill,项目名称:Games2-Proj1,代码行数:101,代码来源:Colored+Cube+App.cpp


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