zoukankan      html  css  js  c++  java
  • 使用定点缓存进行绘制

    代码
    //定义顶点结构:
    struct ColorVertex
    {
    ColorVertex()
    {
    }

    ColorVertex(
    float x, float y, float z, D3DCOLOR c)
    {
    _x
    = x;
    _y
    = y;
    _z
    = z;
    _color
    = c;
    }
    float _x, _y, _z;
    D3DCOLOR _color;

    static const DWORD FVF;
    };
    const DWORD ColorVertex::FVF = D3DFVF_XYZ | D3DFVF_DIFFUSE;

    //声明一个顶点缓存接口
    IDirect3DVertexBuffer9* triangle = 0;


    //创建顶点缓存
    Device->CreateVertexBuffer(
    3 * sizeof(ColorVertex),
    D3DUSAGE_WRITEONLY,
    ColorVertex::FVF,
    D3DPOOL_MANAGED,
    &triangle,
    0
    );

    //访问顶点缓存内容
    ColorVertex* colorVertices;
    triangle
    ->Lock(0, 0, (void**)&triangle, 0);
    colorVertices[
    0] = ColorVertex(-1.0f, 0.0f, 2.0f, D3DCOLOR_XRGB(255, 0, 0));
    colorVertices[
    0] = ColorVertex(0.0f, 1.0f, 2.0f, D3DCOLOR_XRGB(0, 255, 0));
    colorVertices[
    0] = ColorVertex(1.0f, 0.0f, 2.0f, D3DCOLOR_XRGB(0, 0, 255));
    triangle
    ->Unlock();


    //绘制
    Device->SetFVF(ColorVertex::FVF);
    Device
    ->SetStreamSource(0, triangle, 0, sizeof(ColorVertex));
    D3DXMatrixTranslation(
    &WorldMatrix, -1.25f, 0.0f, 0.0f);
    Device
    ->SetTransform(D3DTS_WORLD, &WorldMatrix);
    Device
    ->SetRenderState(D3DRS_SHADEMODE, D3DSHADE_FLAT);
    Device
    ->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
  • 相关阅读:
    SQL Server Alwayson架构下 服务器 各虚拟IP漂移监控告警的功能实现 -2(虚拟IP视角)
    Android LitePal
    Android SQLite
    汇编语言知识点总结
    三层架构
    将博客搬至CSDN
    回溯(二)
    Android持久化技术
    Android广播时间——实现强制下线功能
    Android广播机制(2)
  • 原文地址:https://www.cnblogs.com/sifenkesi/p/1769995.html
Copyright © 2011-2022 走看看