Hi everyone,
I am new to OpenGL, and I need some advice for a project I am working on for one of my classes. My objective is to create a map of new england. It should look something like this picture:
I’ve been able to create some flags for the first part of our assignments, however I accomplished this by only using normal shapes.
This is my code for the flag:
#include <iostream>
//#include <GL/glut.h>
#include <glut/glut.h>
using namespace std;
void display()
{
double sin(double), cos(double);
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_POLYGON);
glColor3f(0.0, 0.80, 0.40);
glVertex2f(-1.0, -1.0);
glVertex2f(-1.0, 1.0);
glVertex2f(0.0, 1.0);
glVertex2f(0.0, -1.0);
glEnd();
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_POLYGON);
for (int i=0; i<100; i++)
{
glVertex2f(0.29*sin(2*3.1415926*i/100), 0.5*cos(2*3.1415926*i/100));
}
glEnd();
glColor3f(1.0, 1.0, 1.0);
glBegin(GL_POLYGON);
for (int i=0; i<100; i++)
{
glVertex2f(0.09 + 0.22*sin(2*3.1415926*i/100), 0.37*cos(2*3.1415926*i/100));
}
glEnd();
glColor3f(0.0, 0.80, 0.40);
glBegin(GL_POLYGON);
for (int i=0; i<100; i++)
{
glVertex2f(0.15*sin(-3.1415926*i/100), 0.33*cos(-3.1415926*i/100));
}
glEnd();
glColor3f(1.0, 0.0, 0.0);
glBegin(GL_TRIANGLES);
glVertex2f(0.0, 0.14);
glVertex2f(0.28, 0.0);
glVertex2f(0.1, -0.1);
glEnd();
glBegin(GL_TRIANGLES);
glVertex2f(0.17, 0.25);
glVertex2f(0.1, 0.05);
glVertex2f(0.17, 0.02);
glEnd();
glBegin(GL_TRIANGLES);
glVertex2f(0.0, -0.18);
glVertex2f(0.1, 0.0);
glVertex2f(0.12, -0.1);
glEnd();
glBegin(GL_TRIANGLES);
glVertex2f(0.17, 0.0);
glVertex2f(0.1, -0.1);
glVertex2f(0.16, -0.25);
glEnd();
glFlush();
}
void init()
{
glClearColor (1.0, 1.0, 1.0, 0.0);
glColor3f(1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D(-1.0, 1.0, -1.0, 1.0);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(500, 300);
glutInitWindowPosition(0,0);
glutCreateWindow("simple");
glutDisplayFunc(display);
init();
glutMainLoop();
}
My question is how can I create this map of New England, because most states are not normal shapes? Is there a tutorial someone could direct me too that would help me? Any advice would be greatly appreciated.
Thank you!