Yeah I don’t know of any functions or tools for doing that either but I’m still a noob too so there prob is some simple method for it.
I don’t know what/how exactly you plan to use it but one basic way I can think of that might help you do whatever you need to do is to draw the whole first just using GL_LINES.
With your example of a square:
Draw the hole first - lets say a small square. (using GL_LINES)
Then make up the outside square using a number of small rectangles or whatever shapes you need.
Heres some example code:
void drawShape(){
//the hole in the middle starts here
glBegin(GL_LINES);
glColor3f(0,0,0);
glVertex2i(250,250);
glVertex2i(300,250);
glEnd();
glBegin(GL_LINES);
glVertex2i(300,250);
glVertex2i(300,300);
glEnd();
glBegin(GL_LINES);
glVertex2i(300,300);
glVertex2i(250,300);
glEnd();
glBegin(GL_LINES);
glVertex2i(250,300);
glVertex2i(250,250);
glEnd();
//The outside shapes start here
glBegin(GL_QUADS);
glColor3f(0,0,1);
glVertex3f(150,150,0);
glVertex3f(400,150,0);
glVertex3f(400,250,0);
glVertex3f(150,250,0);
glEnd();
glBegin(GL_QUADS);
glVertex3f(150,300,0);
glVertex3f(400,300,0);
glVertex3f(400,400,0);
glVertex3f(150,400,0);
glEnd();
glBegin(GL_QUADS);
glVertex3f(150,250,0);
glVertex3f(250,250,0);
glVertex3f(250,300,0);
glVertex3f(150,300,0);
glEnd();
glBegin(GL_QUADS);
glVertex3f(300,250,0);
glVertex3f(400,250,0);
glVertex3f(400,300,0);
glVertex3f(300,300,0);
glEnd();
glFlush();
}
Once you know the coordinates of the hole you wouldn’t even need to draw its outline just know where to place the outside shapes around it.
I hope this can help you out but it’s pretty basic. If not there’s some other threads about similar sort of things i’ve noticed around here somewhere. They seem a little more complicated though but maybe you can look into them for ideas.
good luck
Michael