0

私はFormsでwin7microsoftvisualstudio08に取り組んでいます。グラフィックカードを変更したところ、アプリケーションに何らかのエイリアシングが表示されました。

img

灰色の線は一種の別名であり、参照システムもほとんど見えないことが理解できます。

これを解決する方法のアイデアはありますか?

念のため、コードの一部を投稿します。1:ペイント機能

private: void Paint(){



        int w = glControl1->Width;
        int h = glControl1->Height;


        float aspect_ratio = w / (float)h;
        Matrix4 perpective = Matrix4::CreatePerspectiveFieldOfView(MathHelper::PiOver4, aspect_ratio, 0.1f, 100000.0f);
        GL::MatrixMode(MatrixMode::Projection);
        GL::LoadMatrix(perpective);

        GL::MatrixMode(MatrixMode::Modelview);
        GL::LoadIdentity();
        GL::Viewport(0, 0, w, h);

        //Situacion de la camara en el espacio
        Matrix4 lookat = Matrix4::LookAt(100, 100, 100, 0, 0, 0, 0, 0, 1);
        GL::LoadMatrix(lookat);

        GL::Scale(this->zoom, this->zoom, this->zoom);


        GL::Rotate(xrot, 1.0f, 0.0f, 0.0f);
        GL::Rotate(yrot, 0.0f, 1.0f, 0.0f);
        GL::Clear(ClearBufferMask::ColorBufferBit | ClearBufferMask::DepthBufferBit);
           GL::ClearColor(Color::LightGray);



        Draw3Daxis();
        if (allowDraw){
            DrawSurface();
            }
        }

2:画像に表示されているすべてのものを描画する関数(これはGL :: Vertex3の束にすぎません)

System::Void Draw3Daxis(){
         OpcionesPlot* opciones;
         opciones=OpcionesPlot::Instance();
         int extra=2;
         int sqrnumber=10;

        //Planos en los ejes
        GL::Color3(Color::White);
        GL::Begin(BeginMode::Quads);
        if(opciones->draw3DXYaxis){
            GL::Vertex3(0,0,0);
            GL::Vertex3(LENGTH,0,0);
            GL::Vertex3(LENGTH,LENGTH,0);
            GL::Vertex3(0,LENGTH,0);
         }
         if(opciones->draw3DXZaxis){
             GL::Vertex3(0,0,0);
             GL::Vertex3(LENGTH,0,0);
             GL::Vertex3(LENGTH,0,LENGTH);
             GL::Vertex3(0,0,LENGTH);
         }
         if(opciones->draw3DYZaxis){
             GL::Vertex3(0,0,0);
             GL::Vertex3(0,LENGTH,0);
             GL::Vertex3(0,LENGTH,LENGTH);
             GL::Vertex3(0,0,LENGTH);
        }
         GL::End();


         // ejes XYZ
         GL::Color3(Color::Black);
         GL::Begin(BeginMode::Lines);
         if(opciones->draw3DXYaxis){
            GL::Vertex3(0,0,0);
            GL::Vertex3(LENGTH+extra,0,0);
            GL::Vertex3(0,0,0);
            GL::Vertex3(0,LENGTH+extra,0);
         }
         if(opciones->draw3DXZaxis){
             GL::Vertex3(0,0,0);
             GL::Vertex3(LENGTH+extra,0,0);
             GL::Vertex3(0,0,0);
             GL::Vertex3(0,0,LENGTH+extra);
         }
         if(opciones->draw3DYZaxis){
             GL::Vertex3(0,0,0);
             GL::Vertex3(0,LENGTH+extra,0);
             GL::Vertex3(0,0,0);
             GL::Vertex3(0,0,LENGTH+extra);
        }

         //--> lineas de los planos
         GL::Color3(Color::DarkGray);
         for(int i=1;i<=sqrnumber;i++){
             if(i==sqrnumber)
                 GL::Color3(Color::Black);
             if(opciones->draw3DXYaxis){
                 GL::Vertex3(LENGTH/sqrnumber*i,0,0);
                 GL::Vertex3(LENGTH/sqrnumber*i,LENGTH,0);
                 GL::Vertex3(0,LENGTH/sqrnumber*i,0);
                 GL::Vertex3(LENGTH,LENGTH/sqrnumber*i,0);
             }
             if(opciones->draw3DXZaxis){
                 GL::Vertex3(LENGTH/sqrnumber*i,0,0);
                 GL::Vertex3(LENGTH/sqrnumber*i,0,LENGTH);
                 GL::Vertex3(0,0,LENGTH/sqrnumber*i);
                 GL::Vertex3(LENGTH,0,LENGTH/sqrnumber*i);

             }
             if(opciones->draw3DYZaxis){
                 GL::Vertex3(0,0,LENGTH/sqrnumber*i);
                 GL::Vertex3(0,LENGTH,LENGTH/sqrnumber*i);
                 GL::Vertex3(0,LENGTH/sqrnumber*i,0);
                 GL::Vertex3(0,LENGTH/sqrnumber*i,LENGTH);
             }

         }
        GL::End();
        // triangulos para los ejes
        //----->cuadrado
        GL::Color3(Color::Black);
        GL::Begin(BeginMode::Quads);
        float quadside=0.7;
        if(opciones->draw3DXYaxis){
            GL::Vertex3((float)LENGTH+extra,quadside,quadside);
            GL::Vertex3((float)LENGTH+extra,-quadside,quadside);
            GL::Vertex3((float)LENGTH+extra,-quadside,-quadside);
            GL::Vertex3((float)LENGTH+extra,quadside,-quadside);

            GL::Vertex3(quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(-quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(-quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(quadside,(float)LENGTH+extra,-quadside);


         }
         if(opciones->draw3DXZaxis){
            GL::Vertex3((float)LENGTH+extra,quadside,quadside);
            GL::Vertex3((float)LENGTH+extra,-quadside,quadside);
            GL::Vertex3((float)LENGTH+extra,-quadside,-quadside);
            GL::Vertex3((float)LENGTH+extra,quadside,-quadside);

            GL::Vertex3(quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(-quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(-quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(quadside,-quadside,(float)LENGTH+extra);
         }
         if(opciones->draw3DYZaxis){
            GL::Vertex3(quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(-quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(-quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(quadside,(float)LENGTH+extra,-quadside);

            GL::Vertex3(quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(-quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(-quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(quadside,-quadside,(float)LENGTH+extra);

        }
        GL::End();


        // --> triangulos para hacer la punta
        GL::Begin(BeginMode::Triangles);
        if(opciones->draw3DXYaxis){
            GL::Vertex3((float)LENGTH+extra,quadside,quadside);
            GL::Vertex3((float)LENGTH+extra,-quadside,quadside);
            GL::Vertex3(LENGTH+extra+5,0,0);
            GL::Vertex3((float)LENGTH+extra,-quadside,quadside);
            GL::Vertex3((float)LENGTH+extra,-quadside,-quadside);
            GL::Vertex3(LENGTH+extra+5,0,0);
            GL::Vertex3((float)LENGTH+extra,-quadside,-quadside);
            GL::Vertex3((float)LENGTH+extra,quadside,-quadside);
            GL::Vertex3(LENGTH+extra+5,0,0);
            GL::Vertex3((float)LENGTH+extra,quadside,-quadside);
            GL::Vertex3((float)LENGTH+extra,quadside,quadside);
            GL::Vertex3(LENGTH+extra+5,0,0);

            GL::Vertex3(quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(-quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(0,LENGTH+extra+5,0);
            GL::Vertex3(-quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(-quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(0,LENGTH+extra+5,0);
            GL::Vertex3(-quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(0,LENGTH+extra+5,0);
            GL::Vertex3(quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(0,LENGTH+extra+5,0);

        }
        if(opciones->draw3DXZaxis){
            GL::Vertex3((float)LENGTH+extra,quadside,quadside);
            GL::Vertex3((float)LENGTH+extra,-quadside,quadside);
            GL::Vertex3(LENGTH+extra+5,0,0);
            GL::Vertex3((float)LENGTH+extra,-quadside,quadside);
            GL::Vertex3((float)LENGTH+extra,-quadside,-quadside);
            GL::Vertex3(LENGTH+extra+5,0,0);
            GL::Vertex3((float)LENGTH+extra,-quadside,-quadside);
            GL::Vertex3((float)LENGTH+extra,quadside,-quadside);
            GL::Vertex3(LENGTH+extra+5,0,0);
            GL::Vertex3((float)LENGTH+extra,quadside,-quadside);
            GL::Vertex3((float)LENGTH+extra,quadside,quadside);
            GL::Vertex3(LENGTH+extra+5,0,0);

            GL::Vertex3(quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(-quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(0,0,LENGTH+extra+5);
            GL::Vertex3(-quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(-quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(0,0,LENGTH+extra+5);
            GL::Vertex3(-quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(0,0,LENGTH+extra+5);
            GL::Vertex3(quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(0,0,LENGTH+extra+5);
         }
         if(opciones->draw3DYZaxis){
            GL::Vertex3(quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(-quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(0,LENGTH+extra+5,0);
            GL::Vertex3(-quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(-quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(0,LENGTH+extra+5,0);
            GL::Vertex3(-quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(0,LENGTH+extra+5,0);
            GL::Vertex3(quadside,(float)LENGTH+extra,-quadside);
            GL::Vertex3(quadside,(float)LENGTH+extra,quadside);
            GL::Vertex3(0,LENGTH+extra+5,0);

            GL::Vertex3(quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(-quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(0,0,LENGTH+extra+5);
            GL::Vertex3(-quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(-quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(0,0,LENGTH+extra+5);
            GL::Vertex3(-quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(0,0,LENGTH+extra+5);
            GL::Vertex3(quadside,-quadside,(float)LENGTH+extra);
            GL::Vertex3(quadside,quadside,(float)LENGTH+extra);
            GL::Vertex3(0,0,LENGTH+extra+5);

        }
        GL::End();
        Write3D(LENGTH,3,3,GLUT_BITMAP_9_BY_15,"X");
        Write3D(3,LENGTH,3,GLUT_BITMAP_9_BY_15,"Y");
        Write3D(3,3,LENGTH,GLUT_BITMAP_9_BY_15,"Z");
     }
4

1 に答える 1

2

オブジェクトの各セットを描画する前に、深度テストを無効にしてみてください(最初に参照面、次に軸、次に参照グリッド)。

軸が参照面とZファイティングしているようです。

複数のオプションがあります-

  1. (平面ではなく)線を描画するときに深度テストを無効にします。これにより、Zファイティングが発生しないようになります。
  2. 深度テストをオンのままにしますが、平面を描画するときにglPolygonOffsetを使用してそれらをオフセットし、zファイティングがまったく発生しないようにします。
  3. 平面を描画するときはDepthFuncとしてGL_LEQUAL(またはその他)を使用しますが、線を描画するときはGL_EQUALを使用します。これで問題はありません。
于 2012-07-03T16:02:31.830 に答える