void candeeirodetecto() { candeeirodetectoG=(GLuint*)malloc(6*sizeof(GLuint)); candeeirodetectoGn=(GLuint*)malloc(6*sizeof(GLuint)); candeeirodetectoGt=(GLuint*)malloc(6*sizeof(GLuint)); float* base,*suporte, *blampada,*slampada,*lampada; float* basen=NULL,*suporten=NULL, *blampadan=NULL,*slampadan=NULL,*lampadan=NULL; float* baset=NULL,*suportet=NULL, *blampadat=NULL,*slampadat=NULL,*lampadat=NULL; res =cubo(0.5f,0.05f,0.2f,0,0,0,basen,baset); base=res[0]; basen=res[1]; baset=res[2]; res = cilindro(0.75f,0.015f,100,0,0,0,suporten,suportet); suporte=res[0]; suporten=res[1]; suportet=res[2]; res=cubo(1.2f,0.05f,0.1f,0,0,0,blampadan,blampadat); blampada=res[0]; blampadan=res[1]; blampadat=res[2]; res=cilindro(0.05f,0.02f,100,0,0,0,slampadan,slampadat); slampada=res[0]; slampadan=res[1]; slampadat=res[2]; res=cilindro(0.15f,0.05f,100,0,0,0,lampadan,lampadat); lampada=res[0]; lampadan=res[1]; lampadat=res[2]; glGenBuffers(6,candeeirodetectoG); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoG[0]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float),base,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoG[1]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float),suporte,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoG[2]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float), blampada,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoG[3]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float), slampada,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoG[4]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float), lampada,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glGenBuffers(6,candeeirodetectoGn); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGn[0]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float),basen,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGn[1]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float),suporten,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGn[2]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float), blampadan,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGn[3]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float), slampadan,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGn[4]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float), lampadan,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glGenBuffers(6,candeeirodetectoGt); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGt[0]); glBufferData(GL_ARRAY_BUFFER,172*sizeof(float),baset,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGt[1]); glBufferData(GL_ARRAY_BUFFER,(resolucao*24)*sizeof(float),suportet,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGt[2]); glBufferData(GL_ARRAY_BUFFER,72*sizeof(float), blampadat,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGt[3]); glBufferData(GL_ARRAY_BUFFER,(resolucao*24)*sizeof(float), slampadat,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,candeeirodetectoGt[4]); glBufferData(GL_ARRAY_BUFFER,(resolucao*24)*sizeof(float), lampadat,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); }
void LightingScene::display() { myCylinder cilindro(30,5,true); myCylinder cilindro_flat(30,5,false); // ---- BEGIN Background, camera and axis setup // Clear image and depth buffer everytime we update the scene glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); // Initialize Model-View matrix as identity (no transformation glMatrixMode(GL_MODELVIEW); glLoadIdentity(); // Apply transformations corresponding to the camera position relative to the origin CGFscene::activeCamera->applyView(); light0->draw(); light1->draw(); light2->draw(); light3->draw(); light4->draw(); // Draw axis axis.draw(); // ---- END Background, camera and axis setup // ---- BEGIN Primitive drawing section glPushMatrix(); glTranslated(2,0,11); glScaled(1,8,1); cilindro.draw(); glPopMatrix(); glPushMatrix(); glTranslated(7.5,4,0); glRotated(90.0,1,0,0); glScaled(15,0.2,8); wall->draw(); glPopMatrix(); //clock clockAppearance->apply(); clock.draw(); switch (robot.robot->texture) { case 0: robotAppearance->apply(); break; case 1: earthAppearance->apply(); break; } robot.draw(); //LeftWall glPushMatrix(); glTranslated(0,4,7.5); glRotated(-90.0,0,0,1); glScaled(8,0.2,15); windowAppearance->apply(); windowWall->draw(); glPopMatrix(); //impostor glPushMatrix(); glTranslated(-0.5,1,3); glScaled(0.65,0.22,0.33); wallpaperAppearance->apply(); wall->drawImpostor(); glPopMatrix(); //Floor glPushMatrix(); glTranslated(7.5,0,7.5); glScaled(15,0.2,15); floorAppearance->apply(); wall->draw(12,10); glPopMatrix(); // Board A glPushMatrix(); glTranslated(4,4,0.2); glScaled(BOARD_WIDTH,BOARD_HEIGHT,1); glRotated(90.0,1,0,0); slidesAppearance->apply(); boardA->draw(); glPopMatrix(); //PlaneB glPushMatrix(); glTranslated(10.5,4,0.2); glScaled(BOARD_WIDTH,BOARD_HEIGHT,1); glRotated(90.0,1,0,0); boardAppearance->apply(); boardB->draw(); glPopMatrix(); //First Table glPushMatrix(); glTranslated(5,-6.5,8); tableAppearance->apply(); table->draw(); glPopMatrix(); // We have been drawing in a memory area that is not visible - the back buffer, // while the graphics card is showing the contents of another buffer - the front buffer // glutSwapBuffers() will swap pointers so that the back buffer becomes the front buffer and vice-versa glutSwapBuffers(); }
void mesalta() { mesaltaG=(GLuint*)malloc(6*sizeof(GLuint)); mesaltaGn=(GLuint*)malloc(6*sizeof(GLuint)); mesaltaGt=(GLuint*)malloc(6*sizeof(GLuint)); float* descanso,*diagonal, *base,*perna,*btampo,*tampo; float* descanson=NULL,*diagonaln=NULL, *basen=NULL,*pernan=NULL,*btampon=NULL,*tampon=NULL; float* descansot=NULL,*diagonalt=NULL, *baset=NULL,*pernat=NULL,*btampot=NULL,*tampot=NULL; res =cubo(0.5f,0.02f,0.02f,0,0,0,descanson,descansot); descanso=res[0]; descanson=res[1]; descansot=res[2]; res = cubo(0.3136f,0.02f,0.02f,0,0,0,diagonaln,diagonalt); diagonal=res[0]; diagonaln=res[1]; diagonalt=res[2]; res=cubo(0.4f,0.05f,0.4f,0,0,0,basen,baset); base=res[0]; basen=res[1]; baset=res[2]; res=cilindro(1.25f,0.04f,100,0,0,0,pernan,pernat); perna=res[0]; pernan=res[1]; pernat=res[2]; res=cubo(0.2f,0.2f,0.2f,0,0,0,btampon,btampot); btampo=res[0]; btampon=res[1]; btampot=res[2]; res=cilindro(0.05f,0.4f,100,0,0,0,tampon,tampot); tampo=res[0]; tampon=res[1]; tampot=res[2]; glGenBuffers(6,mesaltaG); glBindBuffer(GL_ARRAY_BUFFER,mesaltaG[0]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float),descanso,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaG[1]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float),diagonal,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaG[2]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float), base,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaG[3]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float), perna,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaG[4]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float), btampo,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaG[5]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float), tampo,GL_STATIC_DRAW); glVertexPointer(3,GL_FLOAT,0,0); glGenBuffers(6,mesaltaGn); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGn[0]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float),descanson,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGn[1]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float),diagonaln,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGn[2]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float), basen,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGn[3]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float), pernan,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGn[4]); glBufferData(GL_ARRAY_BUFFER,108*sizeof(float), btampon,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGn[5]); glBufferData(GL_ARRAY_BUFFER,(resolucao*36)*sizeof(float), tampon,GL_STATIC_DRAW); glNormalPointer(GL_FLOAT,0,0); glGenBuffers(6,mesaltaGt); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGt[0]); glBufferData(GL_ARRAY_BUFFER,72*sizeof(float),descansot,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGt[1]); glBufferData(GL_ARRAY_BUFFER,72*sizeof(float),diagonalt,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGt[2]); glBufferData(GL_ARRAY_BUFFER,72*sizeof(float), baset,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGt[3]); glBufferData(GL_ARRAY_BUFFER,(resolucao*24)*sizeof(float), pernat,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGt[4]); glBufferData(GL_ARRAY_BUFFER,72*sizeof(float), btampot,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); glBindBuffer(GL_ARRAY_BUFFER,mesaltaGt[5]); glBufferData(GL_ARRAY_BUFFER,(resolucao*24)*sizeof(float), tampot,GL_STATIC_DRAW); glTexCoordPointer(2,GL_FLOAT,0,0); }
int main() { int rep=1,opc=1; float r=0,h=0; while (rep==1) { printf ("Programa que calcula...\n"); printf ("1=La superficie de un circulo\n"); printf ("2=una esfera\n"); printf ("3=un cilindro\n"); printf ("Que desea hacer?: "); scanf ("%i",&opc); while (opc<1 || opc>3) { printf ("Opcion invalida, por favor ingrese de nuevo"); scanf ("%i",&opc); } switch (opc) { case 1: printf ("Ingrese el valor del radio: "); scanf ("%f",&r); while (r<0) { printf ("El radio no puede ser negativo, ingrese de nuevo: "); scanf ("%f",&r); } printf ("El area es: %.2f\n",area(r)); break; case 2: printf ("Ingrese el valor del radio: "); scanf ("%f",&r); while (r<0) { printf ("El radio no puede ser negativo, ingrese de nuevo: "); scanf ("%f",&r); } printf ("El volumen es: %.2f\n",esfera(r)); break; case 3: printf ("Ingrese el valor del radio: "); scanf ("%f",&r); while (r<0) { printf ("El radio no puede ser negativo, ingrese de nuevo: "); scanf ("%f",&r); } printf ("Ingrese el valor de la altura: "); scanf ("%f",&h); while (r<0) { printf ("La altura no puede ser negativa, ingrese de nuevo: "); scanf ("%f",&h); } printf ("El volumen es: %.2f\n",cilindro(r,h)); break; } printf ("Desea repetir el programa? 1=SI 2=NO: "); scanf ("%i",&rep); while (rep<1 || rep>2) { printf ("El valor es invalido, ingrese de nuevo: "); scanf ("%i",&rep); } } system ("PAUSE"); }