我正在使用 Forms 开发 win7 microsoft visual studio 08。我刚换了显卡,我的应用程序中出现了某种混叠。
可以看出,灰线有点混叠,也是几乎不可见的参考系统。
知道如何解决这个问题吗?
我将发布部分代码以防万一: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");
}