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


C++ GraphicsDevice类代码示例

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


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

示例1: getManager

void VegetationView::draw(const GameTime& gameTime)
{
	GraphicsManager& manager = getManager();
	const VegetationController& controller = getController();

	GraphicsDevice device = manager.getDevice();

	unsigned long prevCullMode = device.getRenderState(D3DRS_CULLMODE);

	device.setRenderState(D3DRS_CULLMODE, D3DCULL_NONE);

	Matrix world = controller.getWorld() * manager.getWorld();
	const Matrix& view = manager.getView();
	const Matrix& projection = manager.getProjection();

	for (Vegetation::iterator it = vegetation.begin(); it != vegetation.end(); ++it)
	{
		FBXModel& model = it->model;

		model.setClipPlane(manager.getClipPlane());
		model.setCamera(manager.getCamera());
		model.setLight(manager.getLight());
	
		model.draw(device, gameTime, world, view, projection, it->transforms, it->transforms.size(), manager.isRenderShadowMap());
	}

	device.setRenderState(D3DRS_CULLMODE, prevCullMode);
}
开发者ID:sp-alex-osou,项目名称:LuckyLeprechauns,代码行数:28,代码来源:VegetationView.cpp

示例2: POMDOG_ASSERT

std::unique_ptr<Shader> HLSLCompiler::CreateShaderFromSource(
    GraphicsDevice & graphicsDevice,
    const void* shaderSource,
    std::size_t byteLength,
    const std::string& entryPoint,
    ShaderPipelineStage pipelineStage,
    const Optional<std::string>& currentDirectory)
{
    POMDOG_ASSERT(shaderSource != nullptr);
    POMDOG_ASSERT(byteLength > 0);
    POMDOG_ASSERT(graphicsDevice.GetSupportedLanguage() == ShaderLanguage::HLSL);

    auto nativeGraphicsDevice = graphicsDevice.GetNativeGraphicsDevice();

    ShaderBytecode shaderBytecode;
    shaderBytecode.Code = shaderSource;
    shaderBytecode.ByteLength = byteLength;

    ShaderCompileOptions compileOptions;
    compileOptions.EntryPoint = entryPoint;
    compileOptions.Profile.PipelineStage = pipelineStage;
    compileOptions.Profile.ShaderModel.Major = 4;
    compileOptions.Profile.ShaderModel.Minor = 0;
    compileOptions.Precompiled = false;

    if (currentDirectory) {
        compileOptions.CurrentDirectory = *currentDirectory;
    }

    return nativeGraphicsDevice->CreateShader(shaderBytecode, compileOptions);
}
开发者ID:colajam93,项目名称:pomdog,代码行数:31,代码来源:HLSLCompiler.cpp

示例3: Create

    GameAsset* ShaderEffect::Create(StreamReader& reader, GameAsset* existingInstance)
    {
        GraphicsDevice* graphicsDevice = static_cast<GraphicsDevice*>(reader.ReadModule(GraphicsDevice::ClassID));
        
        reader.ReadInt(); // NOT USED

        const int codeLength = reader.ReadInt();
        byte* code = BBStackAlloc(byte, codeLength);
        reader.Read(code, codeLength);

        ID3DXEffect* handle = nullptr;
        ID3DXBuffer* errorBuffer = nullptr;
        HRESULT result = D3DXCreateEffect(graphicsDevice->GetD3DDevice(),
                                          code, codeLength,
                                          NULL, NULL, D3DXSHADER_OPTIMIZATION_LEVEL3, 0, &handle, &errorBuffer);
        if (result != D3D_OK)
        {
            Log::Error("ShaderEffect", Int::ToString(result).CStr());

            if (errorBuffer)
                Log::Error("ShaderEffect", reinterpret_cast<const char*>(errorBuffer->GetBufferPointer()));
        }

        if (existingInstance == nullptr)
            existingInstance = new ShaderEffect(graphicsDevice);

        static_cast<ShaderEffect*>(existingInstance)->Setup(handle);

        BBStackFree(code);

        return existingInstance;
    }
开发者ID:Darkttd,项目名称:Bibim,代码行数:32,代码来源:ShaderEffect.DX9.cpp

示例4: getGraphicsDevice

void LuckyLeprechauns::toggleWireframe()
{
	GraphicsDevice device = getGraphicsDevice();

	unsigned long fillMode = device.getRenderState(D3DRS_FILLMODE) == D3DFILL_SOLID ? D3DFILL_WIREFRAME : D3DFILL_SOLID;

	device.setRenderState(D3DRS_FILLMODE, fillMode);
}
开发者ID:sp-alex-osou,项目名称:LuckyLeprechauns,代码行数:8,代码来源:LuckyLeprechauns.cpp

示例5:

SpriteBatch::SpriteBatch(GraphicsDevice &window)
{
	changes = true;
	size = vector2f((float) window.GetSize().x, (float) window.GetSize().y);
	(this->graphicsDevice) = &window;
	glGenBuffers(2, &buffer[0]);

}
开发者ID:marcopapaia,项目名称:VesaMoottori,代码行数:8,代码来源:SpriteBatch.cpp

示例6: screenDims

void GameLoop::updateRender(RenderContext &rc) {
  const DisplayCaps settings = m_window.getSettings();
  const core::math::Vec2f screenDims((f32) settings.m_width, (f32) settings.m_height);
  SceneManager &sm = m_instance.m_sm;
  CameraSystem &cameraSys = m_instance.m_cameraSys;
  GraphicsDevice gd;


  //---------------------
  rc.m_fboGBuffer.activate();
  // TODO(kulseran): defer rendering pass
  rc.m_fboGBuffer.deactivate();

  //---------------------
  /*
        camera.update((f32) ticker.dt(), settings.m_width, settings.m_height, m_inputManager);
        fsengine::render::MeshBuffer mesh = drawPrim.beginMesh(fsengine::render::eDrawLayer::DRAW_LAYER_WORLD_DIFUSE, *debugMaterial);
        fsengine::render::MeshBuilder builder(mesh);
        core::math::Matrix44 impactLoc = core::math::G_IdentityMatrix44;
        impactLoc.pos() = core::math::G_ZeroVector4;
        impactLoc.at() *= 0.5;
        impactLoc.up() *= 0.5;
        impactLoc.left() *= 0.5;
        builder.insertCube(impactLoc, core::math::Color(100, 196, 64, 128));
        drawPrim.endMesh(mesh);
        cameraSys.addCamera(camera);
        cameraSys.update(screenDims);
        drawPrim.prerender(sm, fsengine::render::eDrawLayer::DRAW_LAYER_WORLD_DIFUSE);
        sm.render(fsengine::render::eDrawLayer::DRAW_LAYER_WORLD_DIFUSE, cameraSys, gd);
        debugDraw.render(camera);
        debugDraw.clear();
        drawPrim.clear();
  */

  // Render Hud
  fsengine::hud::HudCamera cameraHud(screenDims);
  cameraSys.addCamera(cameraHud);
  cameraSys.update(screenDims);
  gd.clearDepth();

  HudContainer &hud = m_instance.m_hud;
  hud.update(1.0f / 60.0f, screenDims, m_inputManager);

  hud.prerender(sm, fsengine::render::eDrawLayer::DRAW_LAYER_HUD_BASE);
  hud.prerender(sm, fsengine::render::eDrawLayer::DRAW_LAYER_HUD_ICONS);
  hud.prerender(sm, fsengine::render::eDrawLayer::DRAW_LAYER_HUD_TEXT);
  hud.prerender(sm, fsengine::render::eDrawLayer::DRAW_LAYER_HUD_CURSOR);

  sm.render(fsengine::render::eDrawLayer::DRAW_LAYER_HUD_BASE, cameraSys, gd);
  sm.render(fsengine::render::eDrawLayer::DRAW_LAYER_HUD_ICONS, cameraSys, gd);
  sm.render(fsengine::render::eDrawLayer::DRAW_LAYER_HUD_TEXT, cameraSys, gd);
  sm.render(fsengine::render::eDrawLayer::DRAW_LAYER_HUD_CURSOR, cameraSys, gd);

  // Finish
  sm.clear();
  gd.restoreState(fsengine::device::GraphicsState());
  CHECK(gd.verify());
}
开发者ID:,项目名称:,代码行数:58,代码来源:

示例7: draw

void TerrainTessellator::draw(const GraphicsDevice& device, unsigned levelOfDetail, unsigned primitiveCount, const IndexBufferCollection& indexBuffers) const
{
	device.setStreamSource(vertexBuffer, sizeof(TerrainVertex));
	device.setIndices(indexBuffers[levelOfDetail]);

	device.setFVF(TerrainVertex::fvf);

	device.drawIndexedPrimitive(D3DPT_TRIANGLELIST, primitiveCount, numVertices);
}
开发者ID:steinbergerbernd,项目名称:Lucky-Leprechauns,代码行数:9,代码来源:TerrainTessellator.cpp

示例8: reset

void D3D11RenderTarget::load(GraphicsDevice &g, const UINT width, const UINT height)
{
    m_graphics = &g.castD3D11();
    m_width = width;
    m_height = height;
    
    g.castD3D11().registerAsset(this);

    reset();
}
开发者ID:techmatt,项目名称:d3d11-interceptor,代码行数:10,代码来源:D3D11RenderTarget.cpp

示例9: draw

void Model::draw(const GraphicsDevice& device)
{
	for (unsigned i = 0; i < materials.size(); ++i)
	{
		device.setMaterial(materials[i]);
		device.setTexture(textures[i]);

		mesh.drawSubset(i);
	}
}
开发者ID:steinbergerbernd,项目名称:Lucky-Leprechauns,代码行数:10,代码来源:Model.cpp

示例10: onResetDevice

void WaterView::onResetDevice(const GraphicsDevice& device)
{
	Viewport viewport = device.getViewport();

	reflectionmap = Texture::create(device, viewport.Width, viewport.Height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT);
	refractionmap = Texture::create(device, viewport.Width, viewport.Height, 1, D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8, D3DPOOL_DEFAULT);
	
	reflectionSurface = reflectionmap.getSurfaceLevel();
	refractionSurface = refractionmap.getSurfaceLevel();

	zBuffer = device.createDepthStencilSurface(viewport.Width, viewport.Height, D3DFMT_D24X8);

	effect.onResetDevice();
}
开发者ID:steinbergerbernd,项目名称:Lucky-Leprechauns,代码行数:14,代码来源:WaterView.cpp

示例11:

void RenderPath2D::ResizeBuffers()
{
	RenderPath::ResizeBuffers();

	GraphicsDevice* device = wiRenderer::GetDevice();

	wiRenderer::GetDevice()->WaitForGPU();

	FORMAT defaultTextureFormat = device->GetBackBufferFormat();

	if(GetDepthStencil() != nullptr && wiRenderer::GetResolutionScale() != 1.0f)
	{
		TextureDesc desc;
		desc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE;
		desc.Format = defaultTextureFormat;
		desc.Width = wiRenderer::GetInternalResolution().x;
		desc.Height = wiRenderer::GetInternalResolution().y;
		device->CreateTexture2D(&desc, nullptr, &rtStenciled);
		device->SetName(&rtStenciled, "rtStenciled");
	}
	{
		TextureDesc desc;
		desc.BindFlags = BIND_RENDER_TARGET | BIND_SHADER_RESOURCE;
		desc.Format = defaultTextureFormat;
		desc.Width = device->GetScreenWidth();
		desc.Height = device->GetScreenHeight();
		device->CreateTexture2D(&desc, nullptr, &rtFinal);
		device->SetName(&rtFinal, "rtFinal");
	}

}
开发者ID:turanszkij,项目名称:WickedEngine,代码行数:31,代码来源:RenderPath2D.cpp

示例12: createPatchIndexBuffer

IndexBuffer TerrainTessellator::createPatchIndexBuffer(const GraphicsDevice& device, unsigned levelOfDetail)
{
	// distance between two neighbor vertices
	int delta = MathHelper::pow2(levelOfDetail);

	// size of grid in current lod (e.g. lod 0: 64, lod 1: 32)
	int lodSize = size / delta;

	// main indices + skirt indices
	int numIndices = lodSize * lodSize * 6;

	IndexCollection indices(numIndices);

	int count = 0;

	unsigned interval = min(stripeSize * delta, size);

	// init main indices
	for (unsigned i = 0; i < size / interval; ++i)
		for (unsigned row = 0; row < size; row += delta)
			for (unsigned col = i * interval; col < (i+1) * interval; col += delta)
				initQuadIndices(row, col, delta, delta, &indices, &count);

	IndexBuffer indexBuffer = device.createIndexBuffer(sizeof(TerrainIndex) * numIndices, indexFormat, D3DUSAGE_WRITEONLY);

	indexBuffer.setData(indices);

	return indexBuffer;
}
开发者ID:steinbergerbernd,项目名称:Lucky-Leprechauns,代码行数:29,代码来源:TerrainTessellator.cpp

示例13: RenderBox

void Indicator::RenderBox(GraphicsDevice &GD, MatrixController &MC, float Radius, const Rectangle3f &Rect, RGBColor Color)
{
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Min.y, Rect.Min.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Max.y, Rect.Min.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Max.y, Rect.Min.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Min.y, Rect.Min.z), Color);

    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Min.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Min.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Min.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Max.x, Rect.Max.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Max.y, Rect.Min.z), Vec3f(Rect.Min.x, Rect.Max.y, Rect.Max.z), Color);

    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Min.y, Rect.Max.z), Vec3f(Rect.Max.x, Rect.Min.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Min.y, Rect.Max.z), Vec3f(Rect.Max.x, Rect.Max.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Max.x, Rect.Max.y, Rect.Max.z), Vec3f(Rect.Min.x, Rect.Max.y, Rect.Max.z), Color);
    RenderCylinder(GD, MC, Radius, Vec3f(Rect.Min.x, Rect.Max.y, Rect.Max.z), Vec3f(Rect.Min.x, Rect.Min.y, Rect.Max.z), Color);

    Matrix4 Scale = Matrix4::Scaling(Rect.Dimensions());
    Matrix4 Translate = Matrix4::Translation(Rect.Min);

    MC.World = Scale * Translate;

    LPDIRECT3DDEVICE9 Device = GD.CastD3D9().GetDevice();
    
    D3DCOLOR D3DColor = RGBColor(90, 90, 90);
    Device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_BLENDFACTOR);
    Device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVBLENDFACTOR);
    Device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
    Device->SetRenderState(D3DRS_BLENDFACTOR, D3DColor);

    _Box.SetColor(Color);
    _Box.Render();

    Device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
}
开发者ID:kbinani,项目名称:dxrip,代码行数:35,代码来源:Indicator.cpp

示例14: vertexCount

VertexBuffer::VertexBuffer(
    GraphicsDevice & graphicsDevice,
    const void* vertices,
    std::size_t vertexCountIn,
    std::size_t strideInBytesIn,
    BufferUsage bufferUsageIn)
    : vertexCount(static_cast<decltype(vertexCount)>(vertexCountIn))
    , strideInBytes(static_cast<decltype(strideInBytes)>(strideInBytesIn))
    , bufferUsage(bufferUsageIn)
{
    POMDOG_ASSERT(vertices != nullptr);
    POMDOG_ASSERT(vertexCount > 0);
    POMDOG_ASSERT(strideInBytes > 0);

    auto sizeInBytes = vertexCount * strideInBytes;
    auto nativeDevice = graphicsDevice.GetNativeGraphicsDevice();

    POMDOG_ASSERT(nativeDevice != nullptr);
    using Detail::BufferBindMode;

    nativeVertexBuffer = nativeDevice->CreateBuffer(
        vertices, sizeInBytes, bufferUsage, BufferBindMode::VertexBuffer);

    POMDOG_ASSERT(nativeVertexBuffer);
}
开发者ID:colajam93,项目名称:pomdog,代码行数:25,代码来源:VertexBuffer.cpp

示例15: createRenderer

/// Creates and returns the renderer if valid
GraphicsDevice* Window::createRenderer()
{
	GraphicsDevice* renderer = NULL;

	// Try to assemble the renderer
#ifdef NEPHILIM_DESKTOP
	renderer = new RendererOpenGL();

#elif defined NEPHILIM_ANDROID || defined NEPHILIM_IOS
	if (gEnv->glesHint == 2)
		renderer = new RendererGLES2();
	/*else
		renderer = new RendererGLES();*/
#endif

	if (renderer)
	{
	//	renderer->m_target = this;
		renderer->m_window = this;

		renderer->setDefaultTarget();
		renderer->setDefaultShader();
		renderer->setDefaultBlending();
		renderer->setDefaultTransforms();
		renderer->setDefaultViewport();
		renderer->setDefaultDepthTesting();
	}

	return renderer;
}
开发者ID:GrimshawA,项目名称:Nephilim,代码行数:31,代码来源:Window.cpp


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