首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >OpenGl点看起来像破折号

OpenGl点看起来像破折号
EN

Stack Overflow用户
提问于 2014-04-06 13:58:10
回答 1查看 289关注 0票数 1

什么会导致openGL点看起来像破折号线?我正试图划出两条分界线。一个包含破折号,另一个包含点。但是当我编译和运行我的程序时,被认为是虚线的东西会以虚线的形式出现。这是我的代码:

代码语言:javascript
复制
#include <windows.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>      // (or others, depending on the system in use)
//#include <stdlib.h>


void init()
{
    glClearColor (1.0, 1.0, 1.0, 0.0);  /* Set display-window color to white.
                                           r,g,b,alpha alpha 0.0 transparent */
    glMatrixMode (GL_PROJECTION);       //  Set projection parameters. 
    gluOrtho2D (0.0, 250.0, 0.0, 250.0); // Set display area
}
void lineSegment()
{
glClear (GL_COLOR_BUFFER_BIT);  // Clear display window. color buffer
    glColor3f (0.0, 0.0, 1.0);      // Set line segment color to green.
 //glEnable(GL_LINE_STIPPLE);  
int p1 [] = {0,80};
int p2 [] = {50, 50};
int p3 [] = {100, 100};
int p4 [] = {150, 75};
int p5 [] = {200, 120};
int p6 [] = {0, 50};
int p7 [] = {50, 100};
int p8 [] = {100,80 };
int p9 [] = {150, 150};
int p10 [] = {200, 60};  
//double width dashed line
 glEnable(GL_LINE_STIPPLE);
glLineWidth(2);
glLineStipple (1, 0x00FF); /* dashed */
glBegin(GL_LINE_STRIP);
glVertex2iv (p1);
glVertex2iv(p2);
glVertex2iv (p3);
glVertex2iv (p4);
glVertex2iv (p5);

 glDisable (GL_LINE_STIPPLE); 
 glEnd();

 glColor3f (1.0, 0.0, 1.0);      // Set line segment color to green.
 glEnable(GL_LINE_STIPPLE);         
glLineWidth(3);
glLineStipple (1, 0x0101); /* dotted */
glBegin(GL_LINE_STRIP);
glVertex2iv (p6);
glVertex2iv(p7);
glVertex2iv (p8);
glVertex2iv (p9);
glVertex2iv (p10);

 glDisable (GL_LINE_STIPPLE);  

glEnd();                      
    glFlush ( );     // Process all OpenGL routines as quickly as possible.

}

int main(int argc, char *argv[])
{
    glutInit (&argc, argv);                         // Initialize GLUT.
    glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB);   // Set display mode, single buffering.
    glutInitWindowPosition (50, 100);   // Set top-left display-window position.
    glutInitWindowSize (400, 300);      // Set display-window width and height.
    glutCreateWindow ("Dash and dots "); // Create display window.
    init( );                            // Execute initialization procedure.
    glutDisplayFunc (lineSegment);       // Send graphics to display window.
    glutMainLoop ( );                    // Display everything and wait.
    return EXIT_SUCCESS;   
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-04-07 14:03:00

将虚线上的线宽设置为1.0

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22895016

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档