0 Members and 1 Guest are viewing this topic.
//Zer0Flag @ drunken-nanomites.org#include <Windows.h>#include <gl/GL.h>#include <gl/GLU.h>#include <GL/glut.h>#include <iostream>#include <time.h>using namespace std;float fRotation[20] = { 0.0f };float fKoordSize = 60.0f;float fJump = 0.0f;time_t ExecutionTime = NULL;void changeSize(int iWidth, int iHeight) { if (iHeight <= 0) { iHeight = 1; } float ratio = iWidth / iHeight; glViewport(0, 0, iWidth, iHeight); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(45.0f, ratio, 0.1f, 100.0f); glMatrixMode(GL_MODELVIEW); glLoadIdentity();}void renderScene(void) { Sleep(50); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); time_t CurrentTime = time(NULL); long ullCurrentTicks = CurrentTime - ExecutionTime; if (ullCurrentTicks <= 11) { switch (ullCurrentTicks) { case 1: for ( int Ix = 0 ; Ix <= 4; Ix += 4) { for ( int Iy = 0; Iy <= 4; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 2: for ( int Ix = 0 ; Ix <= 8; Ix += 4) { for ( int Iy = 0; Iy <= 8; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 3: for ( int Ix = 0 ; Ix <= 12; Ix += 4) { for ( int Iy = 0; Iy <= 12; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 4: for ( int Ix = 0 ; Ix <= 16; Ix += 4) { for ( int Iy = 0; Iy <= 16; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 5: for ( int Ix = 0 ; Ix <= 20; Ix += 4) { for ( int Iy = 0; Iy <= 20; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 6: for ( int Ix = 0 ; Ix <= 24; Ix += 4) { for ( int Iy = 0; Iy <= 24; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 7: for ( int Ix = 0 ; Ix <= 28; Ix += 4) { for ( int Iy = 0; Iy <= 28; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 8: for ( int Ix = 0 ; Ix <= 32; Ix += 4) { for ( int Iy = 0; Iy <= 32; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 9: for ( int Ix = 0 ; Ix <= 36; Ix += 4) { for ( int Iy = 0; Iy <= 36; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 10: for ( int Ix = 0 ; Ix <= 40; Ix += 4) { for ( int Iy = 0; Iy <= 40; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; case 11: for ( int Ix = 0 ; Ix <= 44; Ix += 4) { for ( int Iy = 0; Iy <= 44; Iy += 4) { glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef(((fKoordSize/2) - 8)* (-1) + Ix,((fKoordSize/2) - 8)* (-1) + Iy,0); glutWireCube(2.0); } } break; } } if (ullCurrentTicks > 11 && ullCurrentTicks <= 18) { int i = 0; for ( int Ix = 0 ; Ix <= 60 ; Ix += 4) { for(int Iy = 0 ; Iy <= 60 ; Iy += 4) { fJump = (((rand() % 8) + 1 )); glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef((fKoordSize/2 * (-1)) + Ix,(fKoordSize/2 * (-1)) + Iy,fJump); glutWireCube(2.0); } } } if (ullCurrentTicks > 18 && ullCurrentTicks <= 25) { int i = 0; for ( int Ix = 0 ; Ix <= 60 ; Ix += 4) { for(int Iy = 0 ; Iy <= 60 ; Iy += 4) { fJump = (((rand() % 8) + 1 )); glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); glTranslatef((fKoordSize/2 * (-1)) + Ix,(fKoordSize/2 * (-1)) + Iy,fJump); glRotatef(fRotation[i],1.0f,1.0f,0.0f); glutWireCube(2.0); fRotation[i++] += 1.0f; } } } if (ullCurrentTicks > 25 && ullCurrentTicks <= 32) { int i = 0; for ( int Ix = 0 ; Ix <= 60 ; Ix += 4) { for(int Iy = 0 ; Iy <= 60 ; Iy += 4) { fJump = (((rand() % 8) + 1 )); glLoadIdentity(); glEnable(GL_DEPTH_TEST); gluLookAt(0.0f, 0.0f,fKoordSize,0.0f,0.0f,0.0f,0.0f,1.0f,0.0f); switch ((((rand() % 30) + 10) /10)) { case 1: glColor3f(0.5f,0.0f,0.0f); break; case 2: glColor3f(0.0f,0.5f,0.0f); break; case 3: glColor3f(0.0f,0.0f,0.8f); break; } glTranslatef((fKoordSize/2 * (-1)) + Ix,(fKoordSize/2 * (-1)) + Iy,fJump); glRotatef(fRotation[i],1.0f,1.0f,0.0f); glutWireCube(2.0); fRotation[i++] += 1.0f; } } } if(ullCurrentTicks > 32) { } glutSwapBuffers();}void processNormalKeys(unsigned char key, int x, int y) { if (key == 27) // Exit on ESC { exit(0); }}void main(int argc, char **argv) { ExecutionTime = time(NULL); glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100,100); glutInitWindowSize(320,320); glutCreateWindow("OpenGL Tests"); glutDisplayFunc(renderScene); glutReshapeFunc(changeSize); glutIdleFunc(renderScene); glutKeyboardFunc(processNormalKeys); glutMainLoop();}
<..>(sorry for the noobis question) <..>
sorry I have never used OpenGl, how did you install it? (sorry for the noobis question) I checked the site but I saw so much things to download. I just don't now where to start...
Using glut is pretty much the easiest way to start writing opengl software. You just download the library, put the headers into your compilers "gl" header path and have your project link to the libraries.This will get you startedhttp://www.gamedev.net/page/resources/_/reference/programming/sweet-snippets/basics-of-glut-r1680v1 of the opengl red book is also available online if you dont want to go download the new editions.
God.. people should STOP admitting that they are "noobs"