1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
| program Project2;
{$APPTYPE CONSOLE}
uses
SysUtils,
opengl,
openilu in '..\projet\openilu.pas',
glfw in '..\projet\glfw.pas',
openil in '..\projet\openil.pas',
openilut in '..\projet\openilut.pas',
GL in '..\projet\GL.pas';
var
image : GLuint;
{Initialisation de DevIl Et loadage de la texture en mémoire(ou pas)}
procedure InitIl();
begin
ilinit();
Ilutinit();
Iluinit();
ilutEnable(ILUT_OPENGL_CONV);
ilutRenderer(IL_OPENGL);
// Fin de l'initialisation pure
{Chargement des textures en Mémoires}
if FileExists('texture/sanstitre2.jpg') then
image := ilutGLLoadImage ('texture/sanstitre2.jpg')
else
GLFWTerminate();
end;
procedure Draw();
var
width, height : integer;
t : double;
Begin
t := glfwGetTime();
glfwGetWindowSize( width, height );
if height < 1 then
height := 1;
glViewport( 0, 0, width, height );
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glClear( GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT );
glMatrixMode( GL_PROJECTION ); // Select projection matrix
glLoadIdentity(); // Start with an identity matrix
gluPerspective( // Set perspective view
65, // Field of view
width/height, // Window aspect (assumes square pixels)
1.0, // Near Z clipping plane
100.0 // Far Z clippling plane
);
glMatrixMode( GL_PROJECTION );
gluLookAt( // Set camera position and orientation
5, 5, 10, // Camera position (x,y,z)
0.0, 1.0, 0.0, // View point (x,y,z)
0.0, 1.0, 0.0);
{----------Ici on commence a codé------------}
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, image);
glBegin(GL_QUADS);
glTexCoord2i(1,0);glVertex3f(-1,-1,1);
glTexCoord2i(0,0);glVertex3f(1,-1,1);
glTexCoord2i(0,1);glVertex3f(1,1,1);
glTexCoord2i(1,1);glVertex3f(-1,1,1);
glColor3f(0,1,0); glVertex3f(1,1,-1);
glColor3f(0,0,1); glVertex3f(-1,1,-1);
glColor3f(1,0,0); glVertex3f(-1,1,1);
glColor3f(1,0,0); glVertex3f(1,1,1);
glColor3f(0,0,1); glVertex3f(-1,-1,-1);
glColor3f(0,1,0); glVertex3f(1,-1,-1);
glColor3f(1,0,0); glVertex3f(1,1,-1);
glColor3f(1,0,0); glVertex3f(-1,1,-1);
glColor3f(0,1,0); glVertex3f(1,-1,-1);
glColor3f(0,0,1); glVertex3f(1,-1,1);
glColor3f(1,0,0); glVertex3f(1,1,1);
glColor3f(1,0,0); glVertex3f(1,1,-1);
glColor3f(0,0,1); glVertex3f(-1,-1,-1);
glColor3f(0,1,0); glVertex3f(-1,-1,1);
glColor3f(1,0,0); glVertex3f(-1,1,1);
glColor3f(1,0,0); glVertex3f(-1,1,-1);
glColor3f(0,1,0); glVertex3f(1,-1,-1);
glColor3f(0,0,1); glVertex3f(-1,-1,-1);
glColor3f(0,1,0); glVertex3f(-1,-1,1);
glColor3f(0,0,1); glVertex3f(1,-1,1);
glEnd();
glEnable(GL_BLEND);
glPopMatrix();
glDisable(GL_TEXTURE_2D);
End;
procedure InitGLFW();
begin
glfwInit(); {Initialisation GLFW}
glfwOpenWindow(
1024, 768, // Width and height of window
8, 8, 8, // Number of red, green, and blue bits for color buffer
8, // Number of bits for alpha buffer
24, // Number of bits for depth buffer (Z-buffer)
0, // Number of bits for stencil buffer
GLFW_WINDOW{GLFW_FULLSCREEN}
);
glfwSetWindowTitle( '.Sluged''' );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LEQUAL );
end;
procedure MainLoop();
begin
repeat
Draw();
glfwSwapBuffers();
until((glfwGetKey(GLFW_KEY_ESC)) and glfwGetWindowParam(GLFW_OPENED)=1);
glfwTerminate();
end;
begin
InitGLFW;
InitIl;
MainLoop;
end. |
Partager