Category : glut

#include <windows.h> // for MS Windows #include <GL/glut.h> // GLUT, include glu.h and gl.h /* Global variables */ char title[] = "3D Shapes"; /* Initialize OpenGL Graphics */ void initGL() { glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Set background color to black and opaque glClearDepth(1.0f); // Set background depth to farthest glEnable(GL_DEPTH_TEST); // Enable depth testing ..

Read more

I’m drawing a floor plan. It’s a ortho projection. In the rendering callback, first I paint the floor (z=0) with a pattern, and for the moment I’m filling the whole screen with that pattern. All good. Now it’s time to paint the walls, which are just just a lot of skinny rectangles cut into triangles, ..

Read more

I had this cube in my openGL code: glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_TEXTURE_2D); glTexImage2D( GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, ubImage); glTranslatef(1.5f, 0.0f, -7.0f); glRotatef(angleCube, 1.0f, 1.0f, 1.0f); glBegin(GL_QUADS); glVertex3f(1.0f, 1.0f, -1.0f); glVertex3f(-1.0f, 1.0f, -1.0f); glVertex3f(-1.0f, 1.0f, 1.0f); glVertex3f(1.0f, 1.0f, 1.0f); glVertex3f(1.0f, -1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, 1.0f); glVertex3f(-1.0f, -1.0f, -1.0f); glVertex3f(1.0f, -1.0f, ..

Read more

I am trying to print a point using OpenGL and GLUT, but I just get blank screen when I run the following code. Any help will be appreciated. Thank You. #include<GL/glut.h> void display() { glColor3f(1.0, 0.0, 0.0); glBegin(GL_POINTS); glVertex2f(0.0, 0.0); glEnd(); glFlush(); } void main(int argc, char** argv) { glutInit(&argc, argv); glutInitWindowSize(640, 480); glutCreateWindow("example"); glutInitDisplayMode(GLUT_SINGLE ..

Read more