How to resolve the algorithm OpenGL step by step in the OCaml programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm OpenGL step by step in the OCaml programming language
Table of Contents
Problem Statement
Display a smooth shaded triangle with OpenGL.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm OpenGL step by step in the OCaml programming language
Source code in the ocaml programming language
open GL
open Glut
let display() =
glClearColor 0.3 0.3 0.3 0.0;
glClear[GL_COLOR_BUFFER_BIT; GL_DEPTH_BUFFER_BIT];
glShadeModel GL_SMOOTH;
glLoadIdentity();
glTranslate (-15.0) (-15.0) (0.0);
glBegin GL_TRIANGLES;
glColor3 1.0 0.0 0.0;
glVertex2 0.0 0.0;
glColor3 0.0 1.0 0.0;
glVertex2 30.0 0.0;
glColor3 0.0 0.0 1.0;
glVertex2 0.0 30.0;
glEnd();
glFlush();
;;
let reshape ~width ~height =
glViewport 0 0 width height;
glMatrixMode GL_PROJECTION;
glLoadIdentity();
glOrtho(-30.0) 30.0 (-30.0) 30.0 (-30.0) 30.0;
glMatrixMode GL_MODELVIEW;
;;
let () =
ignore(glutInit Sys.argv);
glutInitWindowSize 640 480;
ignore(glutCreateWindow "Triangle");
glutDisplayFunc ~display;
glutReshapeFunc ~reshape;
glutMainLoop();
;;
You may also check:How to resolve the algorithm Pi step by step in the Lambdatalk programming language
You may also check:How to resolve the algorithm Multisplit step by step in the Nim programming language
You may also check:How to resolve the algorithm Create an HTML table step by step in the Elixir programming language
You may also check:How to resolve the algorithm Pascal's triangle step by step in the Euphoria programming language
You may also check:How to resolve the algorithm Kaprekar numbers step by step in the CoffeeScript programming language