游戏开发论坛

 找回密码
 立即注册
搜索
查看: 2151|回复: 4

画三角形时,为何会出现多余的线条?

[复制链接]

1

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
发表于 2005-11-2 16:45:00 | 显示全部楼层 |阅读模式
画三角形时,为何会出现多余的线条?
如图:
如果DeviceType设置成Reference,又可正常显示,但那样的话速度太慢了
sf_2005112164436.png

59

主题

984

帖子

1200

积分

金牌会员

Rank: 6Rank: 6

积分
1200
发表于 2005-11-2 16:57:00 | 显示全部楼层

Re:画三角形时,为何会出现多余的线条?

。。。。。。。。。。
把代码发上来看看啊

1

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
 楼主| 发表于 2005-11-2 17:00:00 | 显示全部楼层

Re:画三角形时,为何会出现多余的线条?

代码是这里下载的
http://www.c-unit.com/downloads/CU_MDX_Camera.zip
按F6就可以切换WireFrame与SolidFrame模式
查看了IndexBuffer的程序部分没有问题

组成IndexBuffer的代码是TriangleStripPlane类的GenerateIndices方法
Device初始化的代码在Graphics类的Initialize方法与BuildPresentParameters方法

/// <summary>
        /// Initializes Direct3D.
        /// </summary>
        /// <param name="windowed">True for windowed mode. False for fullscreen mode.</param>
        /// <param name="control">Render window.</param>
        public void Initialize( bool windowed, Control control )
        {
            m_windowed = windowed;
            m_renderWindow = control;
            m_displayMode = Manager.Adapters[0].CurrentDisplayMode;
            m_caps = Manager.GetDeviceCaps( 0, DeviceType.Hardware );

            // Check for hardware T&L
            CreateFlags flags;
            if ( m_caps.DeviceCaps.SupportsHardwareTransformAndLight )
            {
                flags = CreateFlags.HardwareVertexProcessing;
            }
            else
            {
                flags = CreateFlags.SoftwareVertexProcessing;
            }
            // Check for pure device
            if ( (m_caps.DeviceCaps.SupportsPureDevice) && ((flags & CreateFlags.HardwareVertexProcessing) != 0) )
            {
                flags |= CreateFlags.PureDevice;
            }

            BuildPresentParameters();
            try
            {
                m_device = new Device( 0, DeviceType.Hardware, m_renderWindow, flags, m_pp );
            }
            catch ( DirectXException )
            {
                throw new DirectXException( "Unable to create the Direct3D device." );
            }

            // Cancel automatic device reset on resize
            m_device.DeviceResizing += new System.ComponentModel.CancelEventHandler( CancelResize );

        }

        /// <summary>
        /// Builds the PresentParameters class.
        /// </summary>
        public void BuildPresentParameters()
        {
            m_pp = new PresentParameters();
            Format adaptorFormat = (Windowed) ? m_displayMode.Format : Format.X8R8G8B8;
            if ( Manager.CheckDeviceFormat( 0, DeviceType.Hardware, adaptorFormat, Usage.DepthStencil, ResourceType.Surface, DepthFormat.D24S8 ) )
            {
                m_pp.AutoDepthStencilFormat = DepthFormat.D24S8;
            }
            else if ( Manager.CheckDeviceFormat( 0, DeviceType.Hardware, adaptorFormat, Usage.DepthStencil, ResourceType.Surface, DepthFormat.D24X8 ) )
            {
                m_pp.AutoDepthStencilFormat = DepthFormat.D24X8;
            }
            else if ( Manager.CheckDeviceFormat( 0, DeviceType.Hardware, adaptorFormat, Usage.DepthStencil, ResourceType.Surface, DepthFormat.D16 ) )
            {
                m_pp.AutoDepthStencilFormat = DepthFormat.D16;
            }
            else
            {
                throw new Direct3DXException( "Unable to find a supported depth stencil format" );
            }

            m_pp.BackBufferWidth           = (Windowed) ? 0 : m_displayMode.Width;
            m_pp.BackBufferHeight          = (Windowed) ? 0 : m_displayMode.Height;
            m_pp.BackBufferFormat          = adaptorFormat;
            m_pp.BackBufferCount           = 1;
            m_pp.MultiSample               = MultiSampleType.None;
            m_pp.MultiSampleQuality        = 0;
            m_pp.SwapEffect                = SwapEffect.Discard;
            m_pp.DeviceWindow              = m_renderWindow;
            m_pp.Windowed                  = Windowed;
            m_pp.EnableAutoDepthStencil    = true;
            m_pp.PresentFlag               = PresentFlag.DiscardDepthStencil;
            m_pp.FullScreenRefreshRateInHz = (Windowed) ? 0 : m_displayMode.RefreshRate;
            m_pp.PresentationInterval      = PresentInterval.Immediate;
        }

59

主题

984

帖子

1200

积分

金牌会员

Rank: 6Rank: 6

积分
1200
发表于 2005-11-2 17:47:00 | 显示全部楼层

Re:画三角形时,为何会出现多余的线条?

我试了一下在我机器上运行没有问题
把DeviceType设置成Reference可以运行可能是显卡不支持

1

主题

3

帖子

0

积分

新手上路

Rank: 1

积分
0
 楼主| 发表于 2005-11-2 17:51:00 | 显示全部楼层

Re:画三角形时,为何会出现多余的线条?

我也觉得可能是这样,明天向公司申请要新显卡,呵呵
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2026-1-22 11:49

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表