Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {$apptype GUI}
- uses Gl,Glu,Glut;
- const width = 600;
- height = 600;
- res_y = 200;
- res_x = 200;
- var torot, torot1, torot2: double;
- texture_id: GLuint;
- procedure drawSphere;
- var sphere: PGLUquadricObj;
- begin
- sphere := gluNewQuadric();
- gluQuadricTexture(sphere, GL_TRUE);
- gluSphere(sphere, 50.0, 20, 20);
- gluDeleteQuadric(sphere);
- end;
- procedure display(); cdecl;
- begin
- glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
- gLLoadIdentity();
- glRotatef(torot, 0, 1, 0);
- glBindTexture(GL_TEXTURE_2D, texture_id);
- drawSphere();
- glFlush();
- glutSwapBuffers();
- end;
- function prepareTexture: GLuint;
- var texture_data: array [0..res_y - 1, 0..res_x - 1, 0..2] of byte;
- texture_id: GLuint;
- x, y: integer;
- begin
- for y := 0 to res_y - 1 do begin
- for x := 0 to res_x - 1 do begin
- texture_data[y, x, 0] := random(256);
- texture_data[y, x, 1] := random(256);
- texture_data[y, x, 2] := random(256);
- end;
- end;
- glEnable(GL_TEXTURE_2D);
- glGenTextures(1, @texture_id);
- glBindTexture(GL_TEXTURE_2D, texture_id);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
- glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
- glTexImage2D(GL_TEXTURE_2D, 0, 3, res_x, res_y, 0, GL_RGB, GL_UNSIGNED_BYTE, @texture_data);
- prepareTexture := texture_id;
- end;
- procedure initGl;
- begin
- glClearColor(0.0,0.0,0.0,0.0);
- glMatrixMode(GL_projection);
- glLoadIdentity;
- glOrtho(-200, 200, -200, 200, -200, 200);
- glMatrixMode(GL_MODELVIEW);
- glLoadIdentity();
- glClearDepth(1.0);
- glEnable(GL_LEQUAL);
- END;
- procedure keyboard(code:byte;x,y:longint); cdecl;
- begin
- case code of
- 27:halt;
- end;
- end;
- procedure initgLUT;
- BEGIN
- glutInitDisplayMode(GLUT_DOUBLE or GLUT_RGB);
- glutInitWindowSize(width,height);
- glutCreateWindow('DOLBOEB');
- glutDisplayFunc(@display);
- glutKeyboardFunc(@keyboard);
- end;
- begin
- initGlut;initGL;
- texture_id := preparetexture;
- glutMainLoop();
- end.
Add Comment
Please, Sign In to add comment