Hi people. My name is Samuel. I'm trying to draw a simple flag, using the glut library on C. For your information, I have my experience working with C# and C++ but I have never tried C before. I let you guys know that so you know that you can talk me with concepts and I will understand. I just copy/paste a code at the web which suppose to draw a simple white and red lines in order to can create a flag with a star on it after that. The code that I have is as follow:
Code:
#include "windows.h"
#include "stdafx.h"
#include "glut.h"
#include <cmath>
void DrawStripes ()
{
int iStripes = 5;
float fDeltaY = 1.0 / iStripes;
float fStartX = 0.0;
float fEndX = 1.0;
for (int iStripeIndex = 0; iStripeIndex < 5; ++iStripeIndex) {
if (iStripeIndex % 2 == 0) {
glColor3f(204.0/255.0, 0.0, 0.0); // to make the red color
} else {
glColor3f(1.0, 1.0, 1.0); // to make the white color
}
float fStartY = iStripeIndex*fDeltaY;
float fEndY = (iStripeIndex + 1)*fDeltaY;
glBegin(GL_QUADS);
glVertex2f(fStartX, fStartY);
glVertex2f(fEndX, fStartY);
glVertex2f(fEndX, fEndY);
glVertex2f(fStartX, fEndY);
glEnd();
}
}
void Initialize() {
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
void Draw() {
DrawStripes();
}
int main(int iArgc, char** cppArgv) {
glutInit(&iArgc, cppArgv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(900, 500);
glutInitWindowPosition(200, 200);
glutCreateWindow("Bandera de Puerto Rico");
Initialize();
glutDisplayFunc(Draw);
glutMainLoop();
return 0;
}
I run the code and the output is just a white screen. A professor says that he made this code as an example and it should be showing the output that you can see in this link:
http://i1227.photobucket.com/albums/...t1/Coutput.png
I don't have experience in C but knowing C++ I still cant find the error. I'm sorry if this is a dumb question but if someone can help me to get the right output I will really appreciate it.
Samuel