Inicio > Foros
Resultados 1 al 3 de 3
Tema: Problemas Opengl
-
19/02/2006, 16:44Cholo
- Fecha de ingreso
- 16 ene, 05
- Mensajes
- 47
Problemas Opengl
Hola a todos a ver si me podeis ayudar, mi problema es que intento ejecutar una instruccion: glutWireSphere y nose que libreria tengo que tener para ejecutarla en el codigo.
-
20/02/2006, 09:34anticuado
- Fecha de ingreso
- 12 ene, 05
- Mensajes
- 631
puedes poner algun dato mas? la quieres poner asi, a pelo, en tu codigo fuente? controlas algo de opengl? has segido algun tutorial (basico) para ello?
En principio, si has consegido dibujar "algo", basta con poner
glutSolidSphere(radio,"divisiones en x", "divisiones en y");
Si tienes alguna duda pregunta.
Si no has seguido ningun tutorial, xuuungo... :wink:
-
20/02/2006, 09:54Cholo
- Fecha de ingreso
- 16 ene, 05
- Mensajes
- 47
Hola a todos tengo un gran problema a ver si me lo podeis solucionar.
Tengo que hacer un trabajo que simile un sistema solar con el sol, la
luna y la tierra. Ademas de hacer que la tierra y la luna efectuen sus
movimientos de rotacion y translacion respectivos. Uso windows no linux y
el programa Bloodshed Dev-C++. Mi codigo hecho hasta el momento es:
#include <windows.h>
#include <conio.h>
#include <gl\gl.h>
#include <gl\glaux.h>
#include <gl\glu.h>
void myinit(void);
void drawPlane(void);
void CALLBACK dayAdd (void);
void CALLBACK daySubtract (void);
void CALLBACK yearAdd (void);
void CALLBACK yearSubtract (void);
void CALLBACK display(void);
void CALLBACK myReshape(GLsizei w, GLsizei h);
static int day =0, year = 0;
void CALLBACK dayAdd (void)
{
day = (day + 1) % 360;
}
void CALLBACK daySubtract (void)
{
day = (day - 1) % 360;
}
void CALLBACK yearAdd (void)
{
year = (year + 5) % 360;
}
void CALLBACK yearSubtract (void)
{
year = (year - 5) % 360;
}
void CALLBACK display(void)
{
// Borramos la pantalla antes de dibujar
glClear(GL_COLOR_BUFFER_BIT);
//Datos del Sol
glPushMatrix();
glColor3f (1.0, 1.0, 0.0);// ponemos el color del sol
glPushMatrix();
auxSolidSphere (1.0); //dibujamos el Sol
glPopMatrix();
//Datos del planeta
glRotatef ((GLfloat) year, 0.0, 1.0, 0.0);//Translacion del planeta
sobre el sol
glTranslatef (0, 0.0, 2.5f); // lo situamos en la pantalla
glRotatef ((GLfloat) day, 1.0, 0.0, 1.0); // rotamos la tierra sobre si
misma
glColor3f (0.0, 0.0, 1.0); //le damos el color al planeta
auxWireSphere (0.2); //dibujamos un planeta de mallas
glPopMatrix();
glPushMatrix(); //fijamos la matriz
//Datos de la luna
glRotatef ((GLfloat) year, 0.0, 1.0, 0.0); // translacion sobre el
planeta
glTranslatef (0, 0.0, 3.0f);//la situamos en pantalla
glRotatef ((GLfloat) day, 0.0f, 0.5, 3.0f); //rota sobre si misma
glColor3f (1.0, 0.0, 0.0);
auxWireSphere (0.1);
glPopMatrix();
glFlush();
glPushMatrix();
//fIN LUNA
glFlush();
}
void myinit (void) {
glShadeModel (GL_FLAT);
}
void CALLBACK myReshape(GLsizei w, GLsizei h)
{
h = (h == 0) ? 1 : h;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(90.0, (GLfloat) w/(GLfloat) h, 1.0, 20.0);
glMatrixMode(GL_MODELVIEW);//iniciamos la pila en la que metemos los
objetos
glLoadIdentity();
glTranslatef (0.0, 0.0, -5.0);
}
/* Programa principal.
* Abre la ventana con el tamaño inicial, una barra de titulo,
* modo de pantalla RGBA, y maneja los eventos de entrada.
*/
int main(int argc, char** argv)
{
auxInitDisplayMode (AUX_SINGLE | AUX_RGB);
auxInitPosition (0, 0, 500, 500);
auxInitWindow ("Composición de transformaciones de modelado");
myinit ();
auxKeyFunc (AUX_LEFT, yearSubtract);
auxKeyFunc (AUX_RIGHT, yearAdd);
auxKeyFunc (AUX_UP, dayAdd);
auxKeyFunc (AUX_DOWN, daySubtract);
auxReshapeFunc (myReshape);
auxMainLoop(display); //llamada para dibujar
return(0);
}
El codigo dibuja el sol, la luna y la tierra.Y con el teclado (flechas
arriba, abajo,dcha,izq) realizo el movimiento de la tierra y la luna de
translacion y rotacion al rededor del sol. Pero yo lo que quiero es que
la luna gire alrededor de la tierra cuando esta se mueve. Algien me
puede decir la solucion o escribir el codigo de como seria para que la
luna se moviera alredeodr de la tierra.
Powered by vBulletin® Version 4.2.5
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.
Traducción por vBulletin Castellano Copyright © 2025.
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.
Traducción por vBulletin Castellano Copyright © 2025.
AutoLinker v1.3 by Poker Forum