2014-04-06 5 views
1

OpenGL 점이 파선으로 보이게하는 원인은 무엇입니까? 두 개의 별도 라인을 그려야합니다. 하나는 대시를 포함하고 다른 하나는 점을 포함합니다. 그러나 점선으로되어있는 것은 프로그램을 컴파일하고 실행할 때 대시로 표시됩니다. 여기 내 코드 :OpenGl 점이 대시처럼 보임

#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; 
} 

답변

1

으로 점선의 선폭을 설정하십시오.

관련 문제