C++ with OpenGL, 373 Bytes.
This is my first time really working with C++ and OpenGL on a challenge, so let me know what I can improve.
#include<GL/glut.h>
#define v glVertex2d
#define r(w,x,y,z) v(w,x);v(w,z);v(y,z);v(y,x);
void d(){glScaled(1/16.0f,1/16.0f,1);glBegin(GL_QUADS);glColor3f(1,0,0);r(-16,-16,16,16)glColor3f(1,1,1);r(-3,-10,3,10)r(-10,-3,10,3)glEnd();glFlush();}int main(int c,char**a){glutInit(&c,a);glutInitWindowSize(320,320);glutCreateWindow("");glutDisplayFunc(d);glutMainLoop();return 0;}
Compiled with the MinGW version of g++ on Windows with FreeGlut.
Creates a 320 x 320 screen displaying the Flag.
Whenever a redraw happens, it spawns a smaller flag inside itself. This is because I never clear the screen, nor reset the matrix.
However, a redraw does not happen automatically.
Ungolfed Code
#include <GL/glut.h>
#define rect(w,x,y,z) glVertex2d(w,x);glVertex2d(w,z);glVertex2d(y,z);glVertex2d(y,x);
void display(){
glClear();
glScaled(1/16.0f,1/16.0f,1);
glBegin(GL_QUADS);
glColor3f(1,0,0);
rect(-16,-16,16,16)
glColor3f(1,1,1);
rect(-3,-10,3,10)
rect(-10,-3,10,3)
glEnd();
glFlush();
}
int main(int argc, char **argv){
glutInit(&argc, argv);
glutInitWindowSize(320,320);
glutCreateWindow("Swiss Flag");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
Link to the Compiled Executable
echo 🇨🇭
- I assume this is not allowed \$\endgroup\$