added venus and earth
This commit is contained in:
parent
1ae25d4e14
commit
0ae64708ab
51
window.c
51
window.c
@ -33,15 +33,12 @@ static uint _screenId = 0;
|
||||
/*!\brief une surface représentant une sphere */
|
||||
static surface_t * _sun = NULL;
|
||||
static surface_t * _mercury = NULL;
|
||||
static surface_t * _venus = NULL;
|
||||
static surface_t * _earth = NULL;
|
||||
|
||||
/* des variable d'états pour activer/désactiver des options de rendu */
|
||||
static int _use_tex = 1, _use_color = 0, _use_lighting = 1;
|
||||
|
||||
/*!\brief on peut bouger la caméra vers le haut et vers le bas avec cette variable */
|
||||
/*static float _ycam = 0.0f;
|
||||
static float _xcam = 0.0f;
|
||||
static float _zcam = 10.0f;*/
|
||||
|
||||
typedef struct cam_t cam_t;
|
||||
|
||||
struct cam_t {
|
||||
@ -91,30 +88,43 @@ int main(int argc, char ** argv) {
|
||||
/*!\brief init de nos données, spécialement les trois surfaces
|
||||
* utilisées dans ce code */
|
||||
void init(void) {
|
||||
uint id, id2;
|
||||
uint sun_id, mercury_id, venus_id, earth_id;
|
||||
/*vec4 g = {0, 1, 0, 1};*/
|
||||
/* on créé nos trois type de surfaces */
|
||||
_sun = mkSphere(12, 12, 1); /*ça fait 12x12x2 trianles !*/
|
||||
/* on change les couleurs de surfaces */
|
||||
/*_sun->dcolor = g; */
|
||||
_mercury = mkSphere(12, 12, (1/227.0f) * 12.0f);
|
||||
id = getTexFromBMP("images/2k-sun.bmp");
|
||||
id2 = getTexFromBMP("images/2k-mercury.bmp");
|
||||
setTexId(_sun, id);
|
||||
setTexId(_mercury, id2);
|
||||
_venus = mkSphere(12, 12, (1/113.0f) * 12.0f);
|
||||
_earth = mkSphere(12, 12, (1/108.0f) * 12.0f);
|
||||
|
||||
sun_id = getTexFromBMP("images/2k-sun.bmp");
|
||||
mercury_id = getTexFromBMP("images/2k-mercury.bmp");
|
||||
venus_id = getTexFromBMP("images/2k-venus-surface.bmp");
|
||||
earth_id = getTexFromBMP("images/2k-earth-daymap.bmp");
|
||||
setTexId(_sun, sun_id);
|
||||
setTexId(_mercury, mercury_id);
|
||||
setTexId(_venus, venus_id);
|
||||
setTexId(_earth, earth_id);
|
||||
/* si _use_tex != 0, on active l'utilisation de la texture pour les
|
||||
* trois */
|
||||
if(_use_tex) {
|
||||
enableSurfaceOption(_mercury, SO_USE_TEXTURE);
|
||||
enableSurfaceOption(_sun, SO_USE_TEXTURE);
|
||||
enableSurfaceOption(_venus, SO_USE_TEXTURE);
|
||||
enableSurfaceOption(_earth, SO_USE_TEXTURE);
|
||||
}
|
||||
/* si _use_lighting != 0, on active l'ombrage */
|
||||
if(_use_lighting) {
|
||||
enableSurfaceOption(_sun, SO_USE_LIGHTING);
|
||||
enableSurfaceOption(_mercury, SO_USE_LIGHTING);
|
||||
enableSurfaceOption(_venus, SO_USE_LIGHTING);
|
||||
enableSurfaceOption(_earth, SO_USE_LIGHTING);
|
||||
}
|
||||
disableSurfaceOption(_sun, SO_USE_COLOR);
|
||||
disableSurfaceOption(_mercury, SO_USE_COLOR);
|
||||
disableSurfaceOption(_venus, SO_USE_COLOR);
|
||||
disableSurfaceOption(_earth, SO_USE_COLOR);
|
||||
atexit(sortie);
|
||||
}
|
||||
|
||||
@ -155,6 +165,19 @@ void draw(void) {
|
||||
translate(nmv, 10.0f, 1.0f, 0.0f);
|
||||
rotate(nmv, a, 0.0f, 1.0f, 0.0f); // rotation
|
||||
transform_n_raster(_mercury, nmv, projMat);
|
||||
|
||||
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
||||
rotate(nmv, a - 10, 0.0f, 1.0f, 0.0f); // orbit mouvement
|
||||
translate(nmv, 20.0f, 1.0f, 0.0f);
|
||||
rotate(nmv, a, 0.0f, -1.0f, 0.0f); // rotation anti-clockwise
|
||||
transform_n_raster(_venus, nmv, projMat);
|
||||
|
||||
memcpy(nmv, mvMat, sizeof nmv); /* copie mvMat dans nmv */
|
||||
rotate(nmv, a - 20, 0.0f, 1.0f, 0.0f); // orbit mouvement
|
||||
translate(nmv, 30.0f, 1.0f, 0.0f);
|
||||
rotate(nmv, a, 0.0f, 1.0f, 0.0f); // rotation
|
||||
transform_n_raster(_earth, nmv, projMat);
|
||||
|
||||
/* déclarer qu'on a changé (en bas niveau) des pixels du screen */
|
||||
gl4dpScreenHasChanged();
|
||||
/* fonction permettant de raffraîchir l'ensemble de la fenêtre*/
|
||||
@ -266,6 +289,14 @@ void sortie(void) {
|
||||
freeSurface(_sun);
|
||||
_sun = NULL;
|
||||
}
|
||||
if(_venus) {
|
||||
freeSurface(_venus);
|
||||
_venus = NULL;
|
||||
}
|
||||
if(_earth) {
|
||||
freeSurface(_earth);
|
||||
_earth = NULL;
|
||||
}
|
||||
/* libère tous les objets produits par GL4Dummies, ici
|
||||
* principalement les screen */
|
||||
gl4duClean(GL4DU_ALL);
|
||||
|
Loading…
Reference in New Issue
Block a user