// Project / Properties:
// Must add Linker / Input / Additional Dependencies: opengl32.lib glu32.lib glut32.lib
// Must set Linker / Advanced / Entry Point to: mainCRTStartup
#include <GL/glut.h> //OpenGL, GLU, and GLUT libraries/headers must be in correct places
#include <stdio.h>
char* str="Hello OpenGL"; // string to display
void init(void)
{
glClearColor(1.0,1.0,1.0,0.0); // white background
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0.0, 100.0, 0.0, 100.0); // orthogonal 2D view, set clipping window
}
void lines_text(void)
{
//draw some lines
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,0.0,0.0);
glBegin(GL_LINES);
glVertex2i(10,40);
glVertex2i(80,80);
glVertex2i(10,80);
glVertex2i(80,40);
glEnd();
//draw some black text
glColor3f(0.0,0.0,0.0);
glRasterPos2i(10,10);
for (int k=0; k<13; k++)
glutBitmapCharacter(GLUT_BITMAP_9_BY_15, str[k]);
glFlush();
}
void main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE|GLUT_RGB);
glutInitWindowPosition(50,100); //physical position of window on desktop
glutInitWindowSize(400,300); //physical width and height of window
glutCreateWindow("Example OpenGL program");
init();
glutDisplayFunc(lines_text); //callback function for display is lines_text
glutMainLoop();
}