Skip to main content

Posts

Showing posts with the label OpenGL

C Program to create a Teapot using OpenGL

  C Program to create a Teapot using OpenGL # include <stdio.h> # include <GL/glut.h> void wall ( double thickness ) { glPushMatrix ( ) ; glTranslated ( 0.5 , 0.5 * thickness , 0.5 ) ; glScaled ( 1.0 , thickness , 1.0 ) ; glutSolidCube ( 1.0 ) ; glPopMatrix ( ) ; } void tableLeg ( double thick , double len ) { glPushMatrix ( ) ; glTranslated ( 0 , len / 2 , 0 ) ; glScaled ( thick , len , thick ) ; glutSolidCube ( 1.0 ) ; glPopMatrix ( ) ; } void table ( double topWid , double topThick , double legThick , double legLen ) { glPushMatrix ( ) ; glTranslated ( 0 , legLen , 0 ) ; glScaled ( topWid , topThick , topWid ) ; glutSolidCube ( 1.0 ) ; glPopMatrix ( ) ; double dist = 0.95 * topWid / 2.0 - legThick / 2.0 ; glPushMatrix ( ) ; glTranslated ( dist , 0 , dist ) ; tableLeg ( legThick , legLen ) ; glTranslated ( 0.0 , 0.0 , - 2 * dist ) ; tableLeg ( legThick , legLen ) ; glTra...

OpenGL program project on Sinking Ship

   OpenGL program project on Sinking Ship # include <stdio.h> # include <GL/glut.h> # include <stdlib.h> # include <GL/freeglut.h> # include <time.h> # include <bits/stdc++.h> # define WIDTH 768 # define HEIGHT 1024 using namespace std ; typedef struct { GLfloat x ; GLfloat y ; GLfloat z ; } vec3f ; const vec3f _FONT_SIZE_NORMAL = { 0.5f , 0.5f , 1.0f } ; const vec3f _FONT_SIZE_BIG = { 1.0f , 1.0f , 1.0f } ; const vec3f _FONT_SIZE_SMALL = { 0.25f , 0.25f , 1.0f } ; const vec3f * FONT_SIZE_NORMAL = & _FONT_SIZE_NORMAL ; const vec3f * FONT_SIZE_BIG = & _FONT_SIZE_BIG ; const vec3f * FONT_SIZE_SMALL = & _FONT_SIZE_SMALL ; struct timespec tim , tim2 ; void sun ( ) ; void ice ( ) ; void sky ( ) ; void display ( ) ; void display0 ( ) ; void display1 ( ) ; void display2 ( ) ; void display3 ( ) ; void display4 ( ) ; void ship ( int , double ) ; void rescueShip ( int , double ) ; void d...