Example #1
0
void render(Game *game)
{
    float w, h;
    glClear(GL_COLOR_BUFFER_BIT);
    //Draw shapes...

    //draw box
    for (int j=0;j<5;j++){
        Shape *s;
        glColor3ub(0,255,0);
        s = &game->box[j];
        glPushMatrix();
        glTranslatef(s->center.x, s->center.y, s->center.z);
        w = s->width;
        h = s->height;
        glBegin(GL_QUADS);
        glVertex2i(-w,-h);
        glVertex2i(-w, h);
        glVertex2i( w, h);
        glVertex2i( w,-h);
        glEnd();
        glPopMatrix();
    }
    //-----------------------------------------------------
    

    //DRAW CIRCLE:
    //static int first_time=1;
    //if (first_time){
    glPushMatrix();
    glColor3ub(0,255,0);
    glBegin(GL_TRIANGLE_FAN);
    int num_segments=100;
    Shape *s;
    s = &game->circle;
    for(int seg = 0; seg < num_segments; seg++)
    {
        float theta = 2.0f * 3.1415926f * float(seg) / float(num_segments);//get the current angle

        float x = s->radius * cosf(theta);//calculate the x component
        float y = s->radius * sinf(theta);//calculate the y component

        glVertex2f(s->center.x + x + 0.5, s->center.y + y + 0.5);//output vertex

    }
    glEnd();
    glPopMatrix();
    //first_time=0;
    //}
    //********************************************************
    for (int i=0; i<game->n; i++){
        //draw all particles here
        glPushMatrix();
        glColor3ub(0,0,((int)100 + 155*rnd()));
        Vec *c = &game->particle[i].s.center;
        w = 2;
        h = 2;
        glBegin(GL_QUADS);
        glVertex2i(c->x-w, c->y-h);
        glVertex2i(c->x-w, c->y+h);
        glVertex2i(c->x+w, c->y+h);
        glVertex2i(c->x+w, c->y-h);
        glEnd();
        glPopMatrix();
    }
    
    //DRAW TEXTS:    
	//glBindTexture(GL_TEXTURE_2D, 0);  
	unsigned int cref = 0x00ff00ff;
    
    Rect r0;
    r0.bot = WINDOW_HEIGHT-20;
	r0.left = 10;
    r0.center = 0;
	ggprint12(&r0, 70, cref, "Waterfall Model, BY: Keith Harryman");    
  
    Rect r1;
    r1.bot = WINDOW_HEIGHT - WINDOW_HEIGHT/7 - BOX_HEIGHT;
	r1.left = WINDOW_WIDTH/7 + 0.3 - BOX_WIDTH/2;
    r1.center = 0;
	ggprint12(&r1, 30, cref, "Requirements");    
	
	Rect r2;
    r2.bot = WINDOW_HEIGHT - 2*WINDOW_HEIGHT/7 - BOX_HEIGHT;
	r2.left = 2*WINDOW_WIDTH/7 + 0.3 - BOX_WIDTH/2;
    r2.center = 0;
	ggprint12(&r2, 30, cref, "Design"); 
	
	Rect r3;
    r3.bot = WINDOW_HEIGHT - 3*WINDOW_HEIGHT/7 - BOX_HEIGHT;
	r3.left = 3*WINDOW_WIDTH/7 + 0.3 - BOX_WIDTH/2;
    r3.center = 0;
	ggprint12(&r3, 30, cref, "Coding");
	
	Rect r4;
    r4.bot = WINDOW_HEIGHT - 4*WINDOW_HEIGHT/7 - BOX_HEIGHT;
	r4.left = 4*WINDOW_WIDTH/7 + 0.3 - BOX_WIDTH/2;
    r4.center = 0;
	ggprint12(&r4, 30, cref, "Testing");
	
	Rect r5;
    r5.bot = WINDOW_HEIGHT - 5*WINDOW_HEIGHT/7 - BOX_HEIGHT;
	r5.left = 5*WINDOW_WIDTH/7 + 0.3 - BOX_WIDTH/2;
    r5.center = 0;
	ggprint12(&r5, 30, cref, "Maintenance");
    
}
Example #2
0
void render(Game *game)
{
    float w, h;
    glClear(GL_COLOR_BUFFER_BIT);
    //Draw shapes...

    static int firsttime = 1;
    static int verts[60][2];
    static int n = 60;

    glColor3ub(50, 150,50);
    if(firsttime){
        float angle = 0;
        float inc = (3.14459 * 2.0) / (float)n;
        for(int i = 0; i < n; i++){
            verts[i][0] = cos(angle) * game->circle.radius + game->circle.center.x;
            verts[i][1] = sin(angle) * game->circle.radius + game->circle.center.y;
            angle += inc;


        }


        firsttime = 0;
    }


    glPushMatrix();
    glBegin(GL_TRIANGLE_FAN);
    for(int i = 0; i < n; i++){
        glVertex2i(verts[i][0],  verts[i][1]);



    }

    glEnd();
    glPopMatrix();

    Rect rect;
    rect.bot=WINDOW_HEIGHT-30;
    rect.left=0;
    rect.center=0;
    ggprint16(&rect, 50, 0x00ffffff,"Waterfall Model");


    //Draw the  boxes here
    for(int j = 0; j < NUM_BOXES; j++){
        Shape *s;
        glColor3ub(44,70,80);
        s = &game->box[j];
        glPushMatrix();
        glTranslatef(s->center.x, s->center.y, s->center.z);
        w = s->width;
        h = s->height;
        glBegin(GL_QUADS);
        glVertex2i(-w,-h);
        glVertex2i(-w, h);
        glVertex2i( w, h);
        glVertex2i( w,-h);
        glEnd();
        glPopMatrix();
    }




    //draw all particles here
    for(int i=0; i < game->n; i++){

        int red = rand() % 20;
        int green = rand() % 100;
        int blue = rand() % 255;

        glPushMatrix();

        glColor3ub(red,green, blue);

        Vec *c = &game->particle[i].s.center;
        w = 2;
        h = 2;
        glBegin(GL_QUADS);
        glVertex2i(c->x-w, c->y-h);
        glVertex2i(c->x-w, c->y+h);
        glVertex2i(c->x+w, c->y+h);
        glVertex2i(c->x+w, c->y-h);
        glEnd();
        glPopMatrix();
    }

    int bot = 240;
    int left = 55;
    int center = 0;

    Rect rect2;
    rect2.bot=bot;
    rect2.left=left;
    rect2.center=center;
    ggprint12(&rect2, 37, 0x00ffffff,"Requirements");

    Rect rect3;
    rect3.bot=bot-30;
    rect3.left=left+75;
    rect3.center=center;
    ggprint12(&rect3, 37, 0x00ffffff,"Design");

    Rect rect4;
    rect4.bot=bot - 60;
    rect4.left= left + 130;
    rect4.center=0;
    ggprint12(&rect4, 37, 0x10ffffff,"Coding");

    Rect rect5;
    rect5.bot= bot -90;
    rect5.left= left + 180;
    rect5.center=0;
    ggprint12(&rect5, 37, 0x00ffffff,"Testing");

    Rect rect6;
    rect6.bot= bot - 120;
    rect6.left= left + 210;
    rect6.center=0;
    ggprint12(&rect6, 37, 0x00ffffff,"Maintenance");


}