/* Hello World for OpenGL  */

#include <GL/gl.h>
#include <GL/glu.h>
#include <GL/glut.h>

void drawing(void);

/* This program will create a window with GLUT-library 
 * that will remain open until it will be closed  */

int main(int argc, char** argv)
{
    glutInit(&argc, argv); /* initializarion of OpenGL library */
    glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); /*define a drawing mode */
    glutInitWindowSize(300, 300); /* Define a size to a window */
    glutInitWindowPosition(100, 100); /* Define a placement of a window */
    glutCreateWindow("Window title"); /* Put a window title text to window */

    glClearColor(0.0, 0.0, 0.0, 0.0);  /* Define the background color */

    glutDisplayFunc(drawing); /* call function that will create a content to window */
    glutMainLoop(); /* Leave the window open until CTRL-C */
    return 0;
}


/*

*/
void drawing(void)
{
    glClear(GL_COLOR_BUFFER_BIT); /* clear background*/

    glColor3f(1.0, 0.5,0.5); /* define drawing color */
    glBegin(GL_TRIANGLES);    /* Start to make combined object */
      glVertex3f (-1.0, -1.0, 0.0); /* Draw one line */
      glVertex3f (1.0, -1.0, 0.0); /* Draw one line */
      glVertex3f (0.0, 1.0, 0.0); /* Draw one line */
    glEnd(); /* end combined object*/

    glFlush();  /* put everything to the screen */
}

i have the code like this but it only draws a normal triangle

but i want draw the triangle like this:

[IMG]http://i43.tinypic.com/2edt4w9.png[/IMG]

can someone help me the code? i dont know how to draw the triangle like the picture...

thanks so much...

Edited 6 Years Ago by tien113: n/a

You need to draw an arc in order to get the (circular), cut-outs that your picture has.

Instead of a triangle with "line, line, line", think NOT a triangle, and "line, arc, line, line, arc, line, and line arc, line".

Once you learn to draw an arc, you'll have no problem getting what you want. Forget the "triangle" drawing - that's not a triangle that you're trying to draw. Do you see how the sides of your image are NOT just straight lines with an arc in the middle. The lines which make up the sides of the image, angle inward near the center.

So each side of your image is a line, arc, line. Not a triangle, by definition.

its so complicated to calculate many line to the triangle like picture...

can u have easier way to draw it ???

Edited 6 Years Ago by tien113: n/a

This article has been dead for over six months. Start a new discussion instead.