 |
www.ispwsznysa.fora.pl Informatyka Stosowania PWSZ NYSA
|
Zobacz poprzedni temat :: Zobacz następny temat |
Autor |
Wiadomość |
Kuba
Początkujący
Dołączył: 21 Sty 2008
Posty: 18
Przeczytał: 0 tematów
Skąd: Nysa
|
Wysłany: Nie 9:52, 14 Cze 2009 Temat postu: chyba B |
|
|
Kod: | #pragma warning(disable : 4244)
#pragma warning(disable : 4305)
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <GL/glaux.h>
#include <GL/gl.h>
#include <GL/glu.h>
#define MODE_NUM 3
#define M_PI 3.14
GLfloat angle = 0.0f, speed = 0.4f, two_side = 0.0f;
GLfloat odl_perspk = 100.0, odl_perspp=15.0;
GLboolean zmiana_persp = GL_TRUE;
GLboolean swiatlo1=GL_TRUE, swiatlo2=GL_TRUE;
GLint cieniowanie=GL_SMOOTH;
GLint my_w, my_h;
GLboolean wl_kamere=GL_FALSE;
GLenum mode [MODE_NUM] = {
GL_FILL,
GL_LINE,
GL_POINT };
int mode_num = 0;
GLfloat front_shininess[] = {0.0};
GLfloat front_specular[] = {0.8f, 1.0f, 0.1f, 1.0f};
GLfloat front_diffuse[] = {0.8f, 1.0f, 0.1f, 1.0f};
//GLfloat front_diffuse[] = {1.0, 0.0, 0.0, 1.0f};
//GLfloat front_specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
GLfloat back_diffuse[] = {0.2, 0.5, 0.9, 1.0f};
GLfloat torus_ambient_and_diffuse[] = { 0.0, 0.8, 0.0, 0.5f };
GLfloat torus_emission[] = { 0.3, 0.2, 0.1, 0.5F };
GLfloat bulb_ambient_and_diffuse[] = { 0.4, 0.4, 0.1, 0.5f };
GLfloat bulb_emission[] = { 0.8f, 0.7f, 0.1f, 1.0f };
GLfloat p1_emission[] = { 0.2f, 0.2f, 0.6f, 0.65f };
GLfloat p2_emission[] = { 0.8f, 0.2f, 0.1f, 0.5f };
GLfloat p3_emission[] = { 0.1f, 0.9f, 0.5f, 0.5f };
GLfloat p4_emission[] = { 0.4f, 0.2f, 0.8f, 0.7f };
GLfloat light_position[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat light1_pos[] = { 0.0f, 0.0f, 1.0f, 1.0f };
void my_init(void){
GLfloat color_amb[]={0.2f,0.3f,0.2f,1.0f};
wl_kamere=GL_TRUE;
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0, 0.0, 0.0, 0.0);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,two_side);
//glLightModelfv(GL_LIGHT_MODEL_AMBIENT,&color_amb[0]);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
//glEnable(GL_LIGHT1);
glPolygonMode(GL_BACK,GL_FILL);
glPolygonMode(GL_FRONT,GL_FILL);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_DEPTH_TEST);
glCullFace(GL_BACK); glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glEnable(GL_LINE_SMOOTH);
}
void CALLBACK key_t(void) {
two_side=1-two_side;
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,two_side);
printf("\n\rTwo side=%f",two_side);
}
void CALLBACK key_b(void) {
wl_kamere^=GL_TRUE;
if (wl_kamere)
{ /*glMatrixMode(GL_PROJECTION);*/
glPopMatrix();
glPushMatrix();
gluLookAt(30,50,-20,0,0,-50,0,1,0);
/*glMatrixMode(GL_MODELVIEW);*/
}
else {
/*glMatrixMode(GL_PROJECTION);*/
glPopMatrix();
glPushMatrix();
gluLookAt(0,0,2,0,0,-50,0,1,0);
/*glMatrixMode(GL_MODELVIEW);*/
}
printf("\n\rWlacz kamere: %s",(wl_kamere ? "TAK":"NIE"));
}
void CALLBACK key_m(void) {
mode_num--;
if (mode_num < 0)
mode_num = 0;
else
{
glPolygonMode(GL_FRONT, mode[mode_num]);
}
}
void CALLBACK key_n(void) {
mode_num++;
if (mode_num >= MODE_NUM)
mode_num = MODE_NUM - 1;
else
glPolygonMode(GL_FRONT, mode[mode_num]);
}
void CALLBACK my_display4(void){
GLfloat a,b,kat,ya,yb,xa,xb;
a=6.0;
b=1.0;
kat=89.0f;
xa=a*sin(kat*M_PI/180.0f);
ya=a*cos(kat*M_PI/180.0f);
xb=b*sin(kat*M_PI/180.0f);
yb=b*cos(kat*M_PI/180.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
///glScalef(2,2,2);
glPushMatrix();
glTranslatef(0.0, 0.0, -80.0);
glPushMatrix();
glTranslatef(20.0, -20.0, 25.0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_SPECULAR, front_specular);
glLightfv(GL_LIGHT0, GL_DIFFUSE, front_diffuse);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, bulb_ambient_and_diffuse);
glMaterialfv(GL_FRONT, GL_EMISSION, bulb_emission);
auxSolidSphere(.5);
glPopMatrix();
glDisable(GL_LIGHTING);
glBegin(GL_LINES);
glVertex3f(30,0,0);
glVertex3f(1,0,0);
glVertex3f(0,0,0);
glVertex3f(0,0,0);
glVertex3f(0,30,0);
glVertex3f(0,0,0);
glVertex3f(0,0,30);
glVertex3f(0,0,0);
glVertex3f(0,5,0);
glEnd();
glDisable(GL_LIGHTING);
glPushMatrix();
// glRotatef(angle*1.5,0,1,0); // rotacja wszystkich kul
glPushMatrix(); // kula nr 4
glRotatef(angle*2,-1,1,-1); // rotacja wszystkich kul
glTranslatef(-5,0,10);
glRotatef(angle*2,0,1,0);
glColor3f(0,0,1);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, torus_ambient_and_diffuse);
auxSolidSphere(b);
glPopMatrix();
glPushMatrix(); // kula nr 1
glTranslatef(5,0,0);
glRotatef(angle*1.5,0,1,0);
glTranslatef(0,0,-20);
glRotatef(angle*1,0,1,0);
glColor3f(1,0,0);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, torus_ambient_and_diffuse);
auxSolidSphere(b);
glPopMatrix();
glPushMatrix(); // kula nr 3
glRotatef(angle*3,-1,1,1);
glTranslatef(0,-5,0);
glRotatef(angle*4,0,1,0);
glColor3f(1,0,0);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, torus_ambient_and_diffuse);
auxSolidSphere(b);
glPopMatrix();
glPushMatrix(); // kula nr 2
glTranslatef(0,5,0);
glRotatef(angle*2,0,1,0);
glTranslatef(5,0,0);
glColor3f(1,0,0);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, torus_ambient_and_diffuse);
auxSolidSphere(b);
glPopMatrix();
//glPopMatrix();
//auxSolidSphere(a); //sfera
glPopMatrix();
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
glPopMatrix();
glEnable(GL_CULL_FACE);
glFlush();
auxSwapBuffers();
}
void CALLBACK bulb_movement(void){
angle += speed;
my_display4();
}
void CALLBACK increase_speed(AUX_EVENTREC *event){
if(speed < 25.6) speed *= 2;
printf("Aktualna predkosc wynosi %.5f \r", speed);
}
void CALLBACK decrease_speed(AUX_EVENTREC *event){
if(speed > 0.00626) speed /= 2;
printf("Aktualna predkosc wynosi %.5f \r", speed);
}
GLfloat rad2deg(GLfloat rad) {
return (rad*180/M_PI);
}
GLfloat deg2rad(GLfloat kat) {
return (kat*M_PI/180);
}
void CALLBACK my_reshape(GLsizei w, GLsizei h){
my_w=w; my_h=h;
if(!h) return;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w < h)
if (zmiana_persp) {
glFrustum(-5.0f, 5.0f, -5.0f*h/w, 5.0f*h/w, odl_perspp, odl_perspk);
printf("Funkcja glFrustum!\r");
}
else {
//gluPerspective(60, (GLdouble)h/w, odl_perspp, odl_perspk);
gluPerspective(2*rad2deg(atan2(5.0f*h/w,odl_perspp)), (GLdouble)h/w, odl_perspp, odl_perspk);
printf("Funkcja gluPerspective\r");
}
else
if (zmiana_persp) {
glFrustum(-5.0f*w/h, 5.0f*w/h, -5.0f, 5.0f, odl_perspp, odl_perspk);
printf("Funkcja glFrustum!\r");
}
else {
gluPerspective(2*rad2deg(atan2(5.0f*w/h,odl_perspp)), (GLdouble)w/h, odl_perspp, odl_perspk);
printf("Funkcja gluPerspective\r");
}
glPushMatrix();
if (wl_kamere) gluLookAt(30,10,-20,0,0,-80,0,1,0);
else gluLookAt(0,0,0,0,0,-80,0,1,0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void CALLBACK zmiana_perspektywy(void){
zmiana_persp ^= GL_TRUE;
my_reshape(my_w,my_h);
}
void CALLBACK key_a(void){
swiatlo1 ^= GL_TRUE;
if (swiatlo1) glEnable(GL_LIGHT0); else glDisable(GL_LIGHT0);
my_reshape(my_w,my_h);
}
void CALLBACK key_s(void){
swiatlo2 ^= GL_TRUE;
if (swiatlo2) glEnable(GL_LIGHT1); else glDisable(GL_LIGHT1);
my_reshape(my_w,my_h);
}
void CALLBACK inc_kon(void){
if(odl_perspk < 200) odl_perspk += 2;
my_reshape(my_w,my_h);
printf("Aktualna odlegl konca perspektywy wynosi %.5f \r", odl_perspk);
}
void CALLBACK dec_kon(void){
if (odl_perspk > 51) odl_perspk -= 2;
my_reshape(my_w,my_h);
printf("Aktualna odlegl konca perspektywy wynosi %.5f \r", odl_perspk);
}
void CALLBACK inc_pocz(void){
if(odl_perspp < 50) odl_perspp += 2;
my_reshape(my_w,my_h);
printf("Aktualna odlegl początku perspektywy wynosi %.5f \r", odl_perspp);
}
void CALLBACK dec_pocz(void){
if (odl_perspp > 1) odl_perspp -= 2;
my_reshape(my_w,my_h);
printf("Aktualna odlegl początku perspektywy wynosi %.5f \r", odl_perspp);
}
void main(void){
auxInitDisplayMode (AUX_DOUBLE | AUX_RGBA | AUX_DEPTH);
auxInitPosition (50, 100, 700, 256);
auxInitWindow ("Lighted Torus with blending");
my_init ();
auxReshapeFunc (my_reshape);
auxIdleFunc (bulb_movement);
auxKeyFunc(AUX_LEFT,inc_pocz);
auxKeyFunc(AUX_UP,inc_kon);
auxKeyFunc(AUX_RIGHT,dec_pocz);
auxKeyFunc(AUX_DOWN,dec_kon);
auxKeyFunc(AUX_z,zmiana_perspektywy);
auxKeyFunc(AUX_b, key_b); // kamera
auxKeyFunc(AUX_m, key_m); // polygon mode front +
auxKeyFunc(AUX_n, key_n); // polygon mode front -
auxKeyFunc(AUX_t, key_t); // two side lightmodel
auxKeyFunc(AUX_a, key_a); // swiatlo 0
auxKeyFunc(AUX_s, key_s); // swiatlo 1
auxMouseFunc (AUX_RIGHTBUTTON, AUX_MOUSEDOWN, increase_speed);
auxMouseFunc (AUX_LEFTBUTTON, AUX_MOUSEDOWN, decrease_speed);
auxMainLoop (my_display4);
}
|
Ostatnio zmieniony przez Kuba dnia Nie 9:52, 14 Cze 2009, w całości zmieniany 1 raz
|
|
Powrót do góry |
|
 |
|
 |
Zobacz poprzedni temat :: Zobacz następny temat |
Autor |
Wiadomość |
hehass
Nowicjusz
Dołączył: 06 Lis 2008
Posty: 5
Przeczytał: 0 tematów
Skąd: prudnik
|
Wysłany: Nie 11:50, 14 Cze 2009 Temat postu: |
|
|
#pragma warning(disable : 4244)
#pragma warning(disable : 4305)
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
const float M_PI = 3.14;
#include <GL/glaux.h>
#include <GL/gl.h>
#include <GL/glu.h>
#define MODE_NUM 3
GLfloat angle = 0.0f, speed = 0.4f, two_side = 0.0f;
GLfloat odl_perspk = 100.0, odl_perspp=15.0;
GLboolean zmiana_persp = GL_TRUE;
GLboolean swiatlo1=GL_TRUE, swiatlo2=GL_TRUE;
GLint cieniowanie=GL_SMOOTH;
GLint my_w, my_h;
GLboolean wl_kamere=GL_FALSE;
GLenum mode [MODE_NUM] = {
GL_FILL,
GL_LINE,
GL_POINT };
int mode_num = 0;
GLfloat front_shininess[] = {0.0};
GLfloat front_specular[] = {1.0f, 1.0f, 0.9f, 1.0f};
GLfloat front_diffuse[] = {1.0f, 1.0f, 0.9f, 1.0f};
//GLfloat front_diffuse[] = {1.0, 0.0, 0.0, 1.0f};
//GLfloat front_specular[] = {1.0f, 1.0f, 1.0f, 1.0f};
GLfloat back_diffuse[] = {0.2, 0.5, 0.9, 1.0f};
GLfloat torus_ambient_and_diffuse[] = { 0.0, 0.8, 0.0, 0.5f };
GLfloat czerwonka[] = { 1.0, 0.4, 1.0, 0.5f };
GLfloat zielonka[] = { 0.0, 0.0, 1.0, 0.5f };
GLfloat biel[] = { 1.0, 1.0, 1.0, 0.5f };
GLfloat granat[] = { 0.0, 1.0, 1.0, 0.5f };
GLfloat torus_emission[] = { 0.3, 0.2, 0.1, 0.5F };
GLfloat bulb_ambient_and_diffuse[] = { 0.4, 0.4, 0.1, 0.5f };
GLfloat bulb_emission[] = { 0.8f, 0.7f, 0.1f, 1.0f };
GLfloat p1_emission[] = { 0.2f, 0.2f, 0.6f, 0.65f };
GLfloat p2_emission[] = { 0.8f, 0.2f, 0.1f, 0.5f };
GLfloat p3_emission[] = { 0.1f, 0.9f, 0.5f, 0.5f };
GLfloat p4_emission[] = { 0.4f, 0.2f, 0.8f, 0.7f };
GLfloat light_position[] = { 0.0f, 0.0f, 0.0f, 1.0f };
GLfloat light1_pos[] = { 0.0f, 0.0f, 1.0f, 1.0f };
void my_init(void){
GLfloat color_amb[]={0.2f,0.3f,0.2f,1.0f};
wl_kamere=GL_TRUE;
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glClearColor(0.0, 0.0, 0.0, 0.0);
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,two_side);
//glLightModelfv(GL_LIGHT_MODEL_AMBIENT,&color_amb[0]);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
//glEnable(GL_LIGHT1);
glPolygonMode(GL_BACK,GL_FILL);
glPolygonMode(GL_FRONT,GL_FILL);
glEnable(GL_AUTO_NORMAL);
glEnable(GL_NORMALIZE);
glEnable(GL_DEPTH_TEST);
glCullFace(GL_BACK); glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glEnable(GL_LINE_SMOOTH);
}
void CALLBACK key_t(void) {
two_side=1-two_side;
glLightModelf(GL_LIGHT_MODEL_TWO_SIDE,two_side);
printf("\n\rTwo side=%f",two_side);
}
void CALLBACK key_b(void) {
wl_kamere^=GL_TRUE;
if (wl_kamere)
{ /*glMatrixMode(GL_PROJECTION);*/
glPopMatrix();
glPushMatrix();
gluLookAt(30,50,-20,0,0,-50,0,1,0);
/*glMatrixMode(GL_MODELVIEW);*/
}
else {
/*glMatrixMode(GL_PROJECTION);*/
glPopMatrix();
glPushMatrix();
gluLookAt(0,0,2,0,0,-50,0,1,0);
/*glMatrixMode(GL_MODELVIEW);*/
}
printf("\n\rWlacz kamere: %s",(wl_kamere ? "TAK":"NIE"));
}
void CALLBACK key_m(void) {
mode_num--;
if (mode_num < 0)
mode_num = 0;
else
{
glPolygonMode(GL_FRONT, mode[mode_num]);
}
}
void CALLBACK key_n(void) {
mode_num++;
if (mode_num >= MODE_NUM)
mode_num = MODE_NUM - 1;
else
glPolygonMode(GL_FRONT, mode[mode_num]);
}
void CALLBACK my_display4(void){
GLfloat a,b,kat,ya,yb,xa,xb;
a=6.0;
b=1.0;
kat=89.0f;
xa=a*sin(kat*M_PI/180.0f);
ya=a*cos(kat*M_PI/180.0f);
xb=b*sin(kat*M_PI/180.0f);
yb=b*cos(kat*M_PI/180.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
///glScalef(2,2,2);
glPushMatrix();
glTranslatef(0.0, 0.0, -80.0);
glPushMatrix();
glTranslatef(20.0, -20.0, 25.0);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);
glLightfv(GL_LIGHT0, GL_SPECULAR, front_specular);
glLightfv(GL_LIGHT0, GL_DIFFUSE, front_diffuse);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, bulb_ambient_and_diffuse);
glMaterialfv(GL_FRONT, GL_EMISSION, bulb_emission);
auxSolidSphere(.5);
glPopMatrix();
glEnable(GL_LIGHTING);
glPushMatrix();
//glRotatef(angle*1.5,0,1,0); // rotacja wszystkich kul
glPushMatrix(); // kula nr 1
glTranslatef(0,-5,0);
glRotatef(angle*2,0,0,1);
glTranslatef(5,5,0);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, czerwonka);
auxSolidSphere(b);
glPopMatrix();
glPushMatrix(); // kula nr 2
glRotatef(angle*3,0,0,1);
glTranslatef(5,0,10);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, zielonka);
auxSolidSphere(b);
glPopMatrix();
glPushMatrix(); // kula nr 3
glRotatef(angle*4,0,1,0); // rotacja wszystkich kul
glTranslatef(0,-5,-3);
glRotatef(angle*4,1,0,0); // rotacja wszystkich kul
glTranslatef(5,-3,0);
//glRotatef(angle*2,0,1,0);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, biel);
auxSolidSphere(b);
glPopMatrix();
glPushMatrix(); // kula nr 4
glRotatef(angle*5,1,0,0); // rotacja wszystkich kul
glTranslatef(8,-8,0);
// glRotatef(angle*2,1,0,0);
glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, granat);
auxSolidSphere(b);
glPopMatrix();
//glPushMatrix(); // kula nr 2
// glTranslatef(-(xa+xb),ya+yb,0);
// glRotatef(angle*1,0,1,0);
// glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, torus_ambient_and_diffuse);
// auxSolidSphere(b);
//glPopMatrix();
//glPushMatrix(); // kula nr 3
// glTranslatef(0,ya+yb,xa+xb);
// glRotatef(angle*4,0,1,0);
// glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, torus_ambient_and_diffuse);
// auxSolidSphere(b);
//glPopMatrix();
//glPushMatrix(); // kula nr 4
// glTranslatef(0,ya+yb,-(xa+xb));
// glRotatef(angle*3,0,1,0);
// glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, torus_ambient_and_diffuse);
// auxSolidSphere(b);
//glPopMatrix();
glPopMatrix();
auxSolidSphere(1); //sfera
glPopMatrix();
glDepthMask(GL_TRUE);
glDisable(GL_BLEND);
glPopMatrix();
glEnable(GL_CULL_FACE);
glFlush();
auxSwapBuffers();
}
void CALLBACK bulb_movement(void){
angle += speed;
my_display4();
}
void CALLBACK increase_speed(AUX_EVENTREC *event){
if(speed < 25.6) speed *= 2;
printf("Aktualna predkosc wynosi %.5f \r", speed);
}
void CALLBACK decrease_speed(AUX_EVENTREC *event){
if(speed > 0.00626) speed /= 2;
printf("Aktualna predkosc wynosi %.5f \r", speed);
}
GLfloat rad2deg(GLfloat rad) {
return (rad*180/M_PI);
}
GLfloat deg2rad(GLfloat kat) {
return (kat*M_PI/180);
}
void CALLBACK my_reshape(GLsizei w, GLsizei h){
my_w=w; my_h=h;
if(!h) return;
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
if(w < h)
if (zmiana_persp) {
glFrustum(-5.0f, 5.0f, -5.0f*h/w, 5.0f*h/w, odl_perspp, odl_perspk);
printf("Funkcja glFrustum!\r");
}
else {
//gluPerspective(60, (GLdouble)h/w, odl_perspp, odl_perspk);
gluPerspective(2*rad2deg(atan2(5.0f*h/w,odl_perspp)), (GLdouble)h/w, odl_perspp, odl_perspk);
printf("Funkcja gluPerspective\r");
}
else
if (zmiana_persp) {
glFrustum(-5.0f*w/h, 5.0f*w/h, -5.0f, 5.0f, odl_perspp, odl_perspk);
printf("Funkcja glFrustum!\r");
}
else {
gluPerspective(2*rad2deg(atan2(5.0f*w/h,odl_perspp)), (GLdouble)w/h, odl_perspp, odl_perspk);
printf("Funkcja gluPerspective\r");
}
glPushMatrix();
if (wl_kamere) gluLookAt(30,10,-20,0,0,-80,0,1,0);
else gluLookAt(0,0,0,0,0,-80,0,1,0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void CALLBACK zmiana_perspektywy(void){
zmiana_persp ^= GL_TRUE;
my_reshape(my_w,my_h);
}
void CALLBACK key_a(void){
swiatlo1 ^= GL_TRUE;
if (swiatlo1) glEnable(GL_LIGHT0); else glDisable(GL_LIGHT0);
my_reshape(my_w,my_h);
}
void CALLBACK key_s(void){
swiatlo2 ^= GL_TRUE;
if (swiatlo2) glEnable(GL_LIGHT1); else glDisable(GL_LIGHT1);
my_reshape(my_w,my_h);
}
void CALLBACK inc_kon(void){
if(odl_perspk < 200) odl_perspk += 2;
my_reshape(my_w,my_h);
printf("Aktualna odlegl konca perspektywy wynosi %.5f \r", odl_perspk);
}
void CALLBACK dec_kon(void){
if (odl_perspk > 51) odl_perspk -= 2;
my_reshape(my_w,my_h);
printf("Aktualna odlegl konca perspektywy wynosi %.5f \r", odl_perspk);
}
void CALLBACK inc_pocz(void){
if(odl_perspp < 50) odl_perspp += 2;
my_reshape(my_w,my_h);
printf("Aktualna odlegl początku perspektywy wynosi %.5f \r", odl_perspp);
}
void CALLBACK dec_pocz(void){
if (odl_perspp > 1) odl_perspp -= 2;
my_reshape(my_w,my_h);
printf("Aktualna odlegl początku perspektywy wynosi %.5f \r", odl_perspp);
}
void main(void){
float M_PI = 3.14;
auxInitDisplayMode (AUX_DOUBLE | AUX_RGBA | AUX_DEPTH);
auxInitPosition (50, 100, 700, 256);
auxInitWindow ("Lighted Torus with blending");
my_init ();
auxReshapeFunc (my_reshape);
auxIdleFunc (bulb_movement);
auxKeyFunc(AUX_LEFT,inc_pocz);
auxKeyFunc(AUX_UP,inc_kon);
auxKeyFunc(AUX_RIGHT,dec_pocz);
auxKeyFunc(AUX_DOWN,dec_kon);
auxKeyFunc(AUX_z,zmiana_perspektywy);
auxKeyFunc(AUX_b, key_b); // kamera
auxKeyFunc(AUX_m, key_m); // polygon mode front +
auxKeyFunc(AUX_n, key_n); // polygon mode front -
auxKeyFunc(AUX_t, key_t); // two side lightmodel
auxKeyFunc(AUX_a, key_a); // swiatlo 0
auxKeyFunc(AUX_s, key_s); // swiatlo 1
auxMouseFunc (AUX_RIGHTBUTTON, AUX_MOUSEDOWN, increase_speed);
auxMouseFunc (AUX_LEFTBUTTON, AUX_MOUSEDOWN, decrease_speed);
auxMainLoop (my_display4);
}
|
|
Powrót do góry |
|
 |
|
|
Nie możesz pisać nowych tematów Nie możesz odpowiadać w tematach Nie możesz zmieniać swoich postów Nie możesz usuwać swoich postów Nie możesz głosować w ankietach
|
fora.pl - załóż własne forum dyskusyjne za darmo
Powered by phpBB © 2001, 2005 phpBB Group
|