Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Useful reference: https://docs.microsoft.com/en-us/windows/desktop/opengl/glmatrixmode
- // This code is suitable for the following OpenGL primitives:
- // GL_POINTS , GL_LINES , GL_LINE_STRIP , GL_LINE_LOOP , GL_POLYGON , GL_TRIANGLES , GL_TRIANGLE_STRIP.
- //#include <Windows.h>
- //#include <GL\glew.h>
- //#include <GL\freeglut.h>
- //#include <iostream>
- //
- //using namespace std;
- //
- //void display() // Drawing function
- //{
- //
- // //glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
- //
- // glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
- // //Indicates the buffers currently enabled for color writing.
- //
- // glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
- //
- // glLoadIdentity(); //has to be at beg of any prog that has transformations
- //
- // glLineWidth(2.0); // when we connect line
- //
- // //glColor3f(1, 0, 0.0); // to color the lines def=white
- //
- // glBegin(GL_TRIANGLE_STRIP); // the shape you want to draw
- //
- // glColor3f(1, 0, 0);
- // glVertex3f(0.2f, 0.2f, 0.0f); // drawing the points
- // glVertex3f(0.4f, 0.2f, 0.0f);
- // glVertex3f(0.5f, 0.5f, 0.0f);
- //
- // glColor3f(1,1,0);
- // glVertex3f(0.4f, 0.8f, 0.0f);
- //
- // glColor3f(1, 1, 1);
- // glVertex3f(0.2f, 0.8f, 0.0f);
- //
- // glColor3f(0, 0, 1);
- // glVertex3f(0.1f, 0.5f, 0.0f);
- //
- // glEnd();
- // glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
- //}
- //
- //void main(int argc, char* argv[]) {
- //
- // // Initialize GLUT
- // glutInit(&argc, argv);
- //
- // // Set up some memory buffers for our display
- // glutInitDisplayMode(GLUT_SINGLE);
- //
- // // Set the window size
- // glutInitWindowSize(400, 400);
- //
- // // Create the window with the title "Hello,GL"
- // glutCreateWindow("Hello, GL");
- // // Bind the two functions (above) to respond when necessary
- //
- // glutDisplayFunc(display);
- // // Very important! This initializes the entry points in the OpenGL driver so we can
- // // call all the functions in the API.
- //
- // glutMainLoop(); // to show the frame
- //}
- // This code is suitable for the following OpenGL primitives:
- // GL_QUADS.
- //#include <Windows.h>
- //#include <GL\glew.h>
- //#include <GL\freeglut.h>
- //#include <iostream>
- //
- //using namespace std;
- //
- //void display() // Drawing function
- //{
- //
- // glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
- //
- // glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
- // //Indicates the buffers currently enabled for color writing.
- //
- // glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
- //
- // glLoadIdentity(); //has to be at beg of any prog that has transformations
- //
- // glLineWidth(2.0); // when we connect line
- //
- // glBegin(GL_QUADS); //the shape you want to draw
- //
- // glColor3f(0, 0, 0); // to color the lines def=white
- //
- // glVertex3f(-0.5f, 0.5f, 0.0f); // drawing the points
- // glVertex3f(-0.5f, 0.3f, 0.0f);
- // glVertex3f(-0.2f, 0.1f, 0.0f);
- // glVertex3f(-0.2f, 0.8f, 0.0f);
- //
- // glVertex3f(0.5f, 0.5f, 0.0f);
- // glVertex3f(0.5f, 0.3f, 0.0f);
- // glVertex3f(0.2f, 0.1f, 0.0f);
- // glVertex3f(0.2f, 0.8f, 0.0f);
- //
- // glEnd();
- // glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
- //}
- //
- //void main(int argc, char* argv[]) {
- //
- // // Initialize GLUT
- // glutInit(&argc, argv);
- //
- // // Set up some memory buffers for our display
- // glutInitDisplayMode(GLUT_SINGLE);
- //
- // // Set the window size
- // glutInitWindowSize(400, 400);
- //
- // // Create the window with the title "Hello,GL"
- // glutCreateWindow("Hello, GL");
- // // Bind the two functions (above) to respond when necessary
- //
- // glutDisplayFunc(display);
- // // Very important! This initializes the entry points in the OpenGL driver so we can
- // // call all the functions in the API.
- //
- // glutMainLoop(); // to show the frame
- //}
- // This code is suitable for the following OpenGL primitives:
- // GL_QUAD_STRIP.
- //#include <Windows.h>
- //#include <GL\glew.h>
- //#include <GL\freeglut.h>
- //#include <iostream>
- //
- //using namespace std;
- //
- //void display() // Drawing function
- //{
- //
- // glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
- //
- // glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
- // //Indicates the buffers currently enabled for color writing.
- //
- // glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
- //
- // glLoadIdentity(); //has to be at beg of any prog that has transformations
- //
- // glLineWidth(2.0); // when we connect line
- //
- // glBegin(GL_QUAD_STRIP); //the shape you want to draw
- //
- // glColor3f(0, 0, 0); // to color the lines def=white
- //
- // glColor3f(0,0,0);
- // glVertex3f(0.1f, -0.2f, 0.0f); // drawing the points
- // glVertex3f(0.2f, 0.3f, 0.0f);
- // glVertex3f(-0.3f, -0.2f, 0.0f);
- // glVertex3f(-0.1f, 0.5f, 0.0f);
- //
- //
- // glColor3f(1,1,1);
- // glVertex3f(-0.5f, 0.3f, 0.0f);
- // glVertex3f(-0.5f, 0.7f, 0.0f);
- //
- // glColor3f(1, 0, 0);
- // glVertex3f(-0.9f, 0.3f, 0.0f);
- // glVertex3f(-0.8f, 0.6f, 0.0f);
- //
- // glEnd();
- // glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
- //}
- //
- //void main(int argc, char* argv[]) {
- //
- // // Initialize GLUT
- // glutInit(&argc, argv);
- //
- // // Set up some memory buffers for our display
- // glutInitDisplayMode(GLUT_SINGLE);
- //
- // // Set the window size
- // glutInitWindowSize(400, 400);
- //
- // // Create the window with the title "Hello,GL"
- // glutCreateWindow("Hello, GL");
- // // Bind the two functions (above) to respond when necessary
- //
- // glutDisplayFunc(display);
- // // Very important! This initializes the entry points in the OpenGL driver so we can
- // // call all the functions in the API.
- //
- // glutMainLoop(); // to show the frame
- //}
- // Cool Shape for GL_TRIANGLE_STRIP , GL_TRIANGLE
- //#include <Windows.h>
- //#include <GL\glew.h>
- //#include <GL\freeglut.h>
- //#include <iostream>
- //
- //using namespace std;
- //
- //void display() // Drawing function
- //{
- //
- // glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
- //
- // glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
- // //Indicates the buffers currently enabled for color writing.
- //
- // glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
- //
- // glLoadIdentity(); //has to be at beg of any prog that has transformations
- //
- // glLineWidth(2.0); // when we connect line
- //
- // glBegin(GL_TRIANGLES); //the shape you want to draw
- //
- // glColor3f(0, 0, 0); // to color the lines def=white
- // glVertex3f(0.0f, 0.0f, 0.0f); // drawing the points
- // glVertex3f(0.5f, 0.0f, 0.0f);
- // glVertex3f(0.5f, 0.5f, 0.0f);
- //
- // glVertex3f(0.0f, 0.0f, 0.0f);
- // glVertex3f(0.0f, 0.5f, 0.0f);
- // glVertex3f(-0.5f, 0.5f, 0.0f);
- //
- //
- // glVertex3f(0.0f, 0.0f, 0.0f);
- // glVertex3f(-0.5f, 0.0f, 0.0f);
- // glVertex3f(-0.5f, -0.5f, 0.0f);
- //
- // glVertex3f(0.0f, 0.0f, 0.0f);
- // glVertex3f(0.0f, -0.5f, 0.0f);
- // glVertex3f(0.5f, -0.5f, 0.0f);
- //
- // glEnd();
- // glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
- //}
- //
- //void main(int argc, char* argv[]) {
- //
- // // Initialize GLUT
- // glutInit(&argc, argv);
- //
- // // Set up some memory buffers for our display
- // glutInitDisplayMode(GLUT_SINGLE);
- //
- // // Set the window size
- // glutInitWindowSize(400, 400);
- //
- // // Create the window with the title "Hello,GL"
- // glutCreateWindow("Hello, GL");
- // // Bind the two functions (above) to respond when necessary
- //
- // glutDisplayFunc(display);
- // // Very important! This initializes the entry points in the OpenGL driver so we can
- // // call all the functions in the API.
- //
- // glutMainLoop(); // to show the frame
- //}
- // This code is suitable for the following OpenGL primitives:
- // GL_TRIANGLE_FAN
- #include <Windows.h>
- #include <GL\glew.h>
- #include <GL\freeglut.h>
- #include <iostream>
- using namespace std;
- void display() // Drawing function
- {
- glClearColor(1, 1, 0, 0.0); //Set color of background (def=black) to any color (yellow)
- glClear(GL_COLOR_BUFFER_BIT); //takes a single argument that is the bitwise OR of several values indicating which buffer is to be cleared.
- //Indicates the buffers currently enabled for color writing.
- glMatrixMode(GL_MODELVIEW); //Applies subsequent matrix operations to the modelview matrix stack.
- glLoadIdentity(); //has to be at beg of any prog that has transformations
- glLineWidth(2.0); // when we connect line
- glBegin(GL_TRIANGLE_FAN);
- glColor3f(0, 0, 0); // to color the lines def=black
- glVertex3f(0.0f, 0.0f, 0.0f); // drawing the points
- glVertex3f(0.5f, 0.0f, 0.0f);
- glVertex3f(0.5f, 0.5f, 0.0f);
- glColor3f(1, 0, 0);
- glVertex3f(0.0f, 0.5f, 0.0f);
- glColor3f(0, 1, 0);
- glVertex3f(-0.5f, 0.5f, 0.0f);
- glColor3f(0, 0, 1);
- glVertex3f(-0.5f, 0.0f, 0.0f);
- glColor3f(0, 1, 1);
- glVertex3f(-0.5f, -0.5f, 0.0f);
- glColor3f(1, 1, 1);
- glVertex3f(0.0f, -0.5f, 0.0f);
- glColor3f(1, 1, 0);
- glVertex3f(0.5f, -0.5f, 0.0f);
- glColor3f(1,1,1);
- glVertex3f(0.5f, 0.0f, 0.0f);
- glEnd();
- glFlush(); //The glFlush function empties all these buffers, causing all issued commands to be executed as quickly as they are accepted by the actual rendering engine.
- }
- void main(int argc, char* argv[]) {
- // Initialize GLUT
- glutInit(&argc, argv);
- // Set up some memory buffers for our display
- glutInitDisplayMode(GLUT_SINGLE);
- // Set the window size
- glutInitWindowSize(400, 400);
- // Create the window with the title "Hello,GL"
- glutCreateWindow("Hello, GL");
- // Bind the two functions (above) to respond when necessary
- glutDisplayFunc(display);
- // Very important! This initializes the entry points in the OpenGL driver so we can
- // call all the functions in the API.
- glutMainLoop(); // to show the frame
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement