moss-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Moss-devel] CVS: moss/3Dsia/client/3Dcf/src Makefile.am,1.3,1.4 World.c


From: Manfred Morgner <address@hidden>
Subject: [Moss-devel] CVS: moss/3Dsia/client/3Dcf/src Makefile.am,1.3,1.4 World.cxx,1.4,1.5 main.cxx,1.3,1.4
Date: Sun, 10 Nov 2002 09:46:46 -0500

Update of /cvsroot/moss/moss/3Dsia/client/3Dcf/src
In directory subversions:/tmp/cvs-serv26706/src

Modified Files:
        Makefile.am World.cxx main.cxx 
Log Message:
Tried to make the (C)World a better place to code.


Index: Makefile.am
===================================================================
RCS file: /cvsroot/moss/moss/3Dsia/client/3Dcf/src/Makefile.am,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** Makefile.am 5 Nov 2002 12:49:16 -0000       1.3
--- Makefile.am 10 Nov 2002 14:46:44 -0000      1.4
***************
*** 1,9 ****
! bin_PROGRAMS = 3dfclient
  
  CXXFLAGS = -Wall -g -O3 -D_REENTRANT
  INCLUDES=-I../include
  
! 3dfclient_SOURCES = main.cxx World.cxx
! 3dfclient_LDADD = $(lflags) $(glflags)
  
  
--- 1,9 ----
! bin_PROGRAMS = 3df.client
  
  CXXFLAGS = -Wall -g -O3 -D_REENTRANT
  INCLUDES=-I../include
  
! 3df_client_SOURCES = main.cxx World.cxx
! 3df_client_LDADD = $(lflags) $(glflags)
  
  

Index: World.cxx
===================================================================
RCS file: /cvsroot/moss/moss/3Dsia/client/3Dcf/src/World.cxx,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -r1.4 -r1.5
*** World.cxx   3 Nov 2002 19:55:11 -0000       1.4
--- World.cxx   10 Nov 2002 14:46:44 -0000      1.5
***************
*** 39,76 ****
  CWorld::CWorld(int nParams, char* aszParams[])
    {
    m_dXrot = .0;
    m_dYrot = .0;
    m_dZrot = .0;
  
    glutInit(&nParams, aszParams);
    glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH);
!   glutInitWindowSize(800, 600);
    glutInitWindowPosition(0, 0);
    m_nWindow = glutCreateWindow("3df.client");
  
!   }
  
  CWorld::~CWorld()
    {
!   
    }
  
! void CWorld::InitGL(int nWidth, int nHeight)
    {
!   GLfloat light_position[] = { 2.0, 5.0, 5.0, 2.0};
!   GLfloat white_light[] = {1.0, 1.0, 1.0, 1.0};
!   GLfloat mat_ambient[] = {0.2,0.2,0.2,1};
!   GLfloat mat_specular[] = {0.2, 0.2, 0.2, 1.0};
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glShadeModel(GL_SMOOTH);
!   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, mat_ambient);
!   glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular);
!   glLightfv(GL_LIGHT0, GL_POSITION, light_position);
!   glLightfv(GL_LIGHT0, GL_DIFFUSE, white_light);
!   glLightfv(GL_LIGHT0, GL_SPECULAR, white_light);
    glClearDepth(1.0);
    glDepthFunc(GL_LEQUAL);
    glEnable(GL_DEPTH_TEST);
!   glEnable(GL_BLEND);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);
--- 39,105 ----
  CWorld::CWorld(int nParams, char* aszParams[])
    {
+   GLfloat afLP[] = {.0, .0, .0, 1.};     // light posiiton
+   GLfloat afWL[] = {1.0, 1.0, 1.0, 1.0}; // withe light
+   GLfloat afMA[] = {0.2,0.2,0.2,1};      // ambient material
+   GLfloat afMP[] = {0.2, 0.2, 0.2, 1.0}; // specular material
+ 
+   m_afLightPosition    = afLP;
+   m_afWhiteLight       = afWL;
+   m_afMaterialAmbient  = afMA;
+   m_afMaterialSpecular = afMP;
+ 
    m_dXrot = .0;
    m_dYrot = .0;
    m_dZrot = .0;
+   m_nWidth      = 640;
+   m_nHeight     = 480;
+   m_bFullScreen = false;
+ 
+   m_nWindow = 0;
  
    glutInit(&nParams, aszParams);
    glutInitDisplayMode(GLUT_RGBA | GLUT_ALPHA | GLUT_DOUBLE | GLUT_DEPTH);
!   glutInitWindowSize(m_nWidth, m_nHeight);
    glutInitWindowPosition(0, 0);
    m_nWindow = glutCreateWindow("3df.client");
+   cout << "GLUT Window created. Handle: " << m_nWindow << endl;
  
!   } // CWorld::CWorld(int nParams, char* aszParams[])
  
  CWorld::~CWorld()
    {
!   glutDestroyWindow(m_nWindow);
!   m_nWindow = 0;
    }
  
! void CWorld::InitGL(int nWidth, int nHeight, bool bFullScreen)
    {
!   m_nWidth      = nWidth;
!   m_nHeight     = nHeight;
!   m_bFullScreen = bFullScreen;
! 
!   if (m_bFullScreen)
!     {
!     glutFullScreen();
!     }
!   else // if (m_bFullScreen)
!     {
!     glutReshapeWindow(m_nWidth, m_nHeight);
!     } // else if (m_bFullScreen)
! 
    glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    glShadeModel(GL_SMOOTH);
! 
!   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT,  m_afMaterialAmbient);
!   glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, m_afMaterialSpecular);
! 
!   glLightfv(GL_LIGHT0, GL_POSITION, m_afLightPosition);
!   glLightfv(GL_LIGHT0, GL_DIFFUSE,  m_afWhiteLight);
!   glLightfv(GL_LIGHT0, GL_SPECULAR, m_afWhiteLight);
! 
    glClearDepth(1.0);
    glDepthFunc(GL_LEQUAL);
    glEnable(GL_DEPTH_TEST);
! //  glEnable(GL_BLEND);
    glEnable(GL_LIGHT0);
    glEnable(GL_LIGHTING);
***************
*** 78,85 ****
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    glColor4f(1.0, 1.0, 1.0, 0.9);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
!   gluPerspective(45.0f,(GLfloat)nWidth/(GLfloat)nHeight,0.1f,100.0f);
!   gluLookAt(2,2,6,0,0,0,0,1,0);
    glMatrixMode(GL_MODELVIEW);
    } // void CWorld::InitGL(int nWidth, int nHeight)
--- 107,115 ----
    glBlendFunc(GL_SRC_ALPHA, GL_ONE);
    glColor4f(1.0, 1.0, 1.0, 0.9);
+ 
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
!   gluPerspective(45.f, (GLfloat)nWidth/(GLfloat)nHeight, .1f, 100.f);
!   gluLookAt(2, 2, 6, 0, 0, 0, 0, 1, 0);
    glMatrixMode(GL_MODELVIEW);
    } // void CWorld::InitGL(int nWidth, int nHeight)
***************
*** 92,101 ****
      nHeight=1;
      } // if( nHeight==0)
!     
    glViewport(0, 0, nWidth, nHeight);
!   
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
-     
    gluPerspective(45.0f,(GLfloat)nWidth/(GLfloat)nHeight,0.1f,100.0f);
    glMatrixMode(GL_MODELVIEW);
--- 122,130 ----
      nHeight=1;
      } // if( nHeight==0)
! 
    glViewport(0, 0, nWidth, nHeight);
! 
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(45.0f,(GLfloat)nWidth/(GLfloat)nHeight,0.1f,100.0f);
    glMatrixMode(GL_MODELVIEW);
***************
*** 116,132 ****
  
    // Positioning the light
! //  GLfloat light_position[] = { 2.0 , 5.0, 5.0, 1.0};
    GLfloat light_position[] = { .0 , .0, .0, 1.0};
!   glLightfv(GL_LIGHT0, GL_POSITION, light_position);
!   
    // Drawing a yellow sphere on the lights position
    // (like a sun)
-   glColor3f(1.f,1.f,.0f);
    glPushMatrix();
!   glTranslatef(2.f, 5.f, 5.f);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glutSolidSphere(.2f, 32, 32);
    gluLookAt(2,2,6,0,0,0,0,1,0);
    glPopMatrix();
    // Creating the world cube
    // all entities have to be in them
--- 145,163 ----
  
    // Positioning the light
!   // the position is relative to the current coordinate
!   // root in the moment, the light source will be positioned
!   // thats why it has to be "absolute zero"
    GLfloat light_position[] = { .0 , .0, .0, 1.0};
! 
    // Drawing a yellow sphere on the lights position
    // (like a sun)
    glPushMatrix();
!   glColor3f(1.f,1.f,.0f);
!   glTranslatef(2.f, 5.f, -5.f);
    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glutSolidSphere(.2f, 32, 32);
    gluLookAt(2,2,6,0,0,0,0,1,0);
    glPopMatrix();
+ 
    // Creating the world cube
    // all entities have to be in them
***************
*** 182,190 ****
    switch (key)
      {
!     case 27:
        glutDestroyWindow(m_nWindow);
        exit(0);
        break;
!     
      case 'x': m_dXrot += .8; break;
      case 'X': m_dXrot -= .8; break;
--- 213,223 ----
    switch (key)
      {
!     case  27:
!     case 'Q':
!     case 'q':
        glutDestroyWindow(m_nWindow);
        exit(0);
        break;
! 
      case 'x': m_dXrot += .8; break;
      case 'X': m_dXrot -= .8; break;
***************
*** 193,197 ****
      case 'z': m_dZrot += .8; break;
      case 'Z': m_dZrot -= .8; break;
      }
!   }// void CWorld::KeyPressed(unsigned char key, int x, int y)
  
--- 226,250 ----
      case 'z': m_dZrot += .8; break;
      case 'Z': m_dZrot -= .8; break;
+ 
+     case 'f':
+     case 'F':
+       m_bFullScreen = !m_bFullScreen;
+       if (m_bFullScreen == true)
+         {
+         glutFullScreen();
+         }
+       else
+         {
+         glutReshapeWindow(m_nWidth, m_nHeight);
+         }
+       break;
+ 
+     default: return;
      }
!   glutPostRedisplay();
!   } // void CWorld::KeyPressed(unsigned char key, int x, int y)
  
+ void CWorld::MouseFunction(int nButton, int nStatus, int x, int y)
+   {
+   glutPostRedisplay();
+   } // void CWorld::MouseFunction(int nButton, int nStatus, int x, int y)

Index: main.cxx
===================================================================
RCS file: /cvsroot/moss/moss/3Dsia/client/3Dcf/src/main.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** main.cxx    3 Nov 2002 13:24:18 -0000       1.3
--- main.cxx    10 Nov 2002 14:46:44 -0000      1.4
***************
*** 42,45 ****
--- 42,46 ----
  void DrawScene()
    {
+   if (g_poWorld == 0) return;
    g_poWorld->DrawGLScene();
    }
***************
*** 47,70 ****
  void Idle()
    {
!   usleep(100);
!   g_poWorld->DrawGLScene();
    }
  
  void KeyPressed(unsigned char key, int x, int y)
    {
    g_poWorld->KeyPressed(key, x, y);
    }
!       
  
  int main(int nParams, char* aszParams[])
    {
    g_poWorld = new CWorld(nParams, aszParams);
! 
! 
    glutDisplayFunc(DrawScene);
-   glutFullScreen();
    glutIdleFunc(Idle);
    glutKeyboardFunc(KeyPressed);
!   g_poWorld->InitGL(800, 600);
    glutMainLoop();
  
--- 48,84 ----
  void Idle()
    {
! //  usleep(100);
! //  if (g_poWorld == 0) return;
! //  g_poWorld->DrawGLScene();
    }
  
  void KeyPressed(unsigned char key, int x, int y)
    {
+   if (g_poWorld == 0) return;
    g_poWorld->KeyPressed(key, x, y);
    }
! 
! void MouseFunction(int nButton, int nState, int x, int y)
!   {
!   if (g_poWorld == 0) return;
!   g_poWorld->MouseFunction(nButton, nState, x, y);
!   }
  
  int main(int nParams, char* aszParams[])
    {
    g_poWorld = new CWorld(nParams, aszParams);
! /*
!   g_poWorld->CallbackSet("DrawScene", DrawScene)
!   g_poWorld->CallbackSet("Idle",      Idle)
!   g_poWorld->CallbackSet("Keyboard",  KeyPressed)
!   g_poWorld->CallbackSet("Mouse",     MouseFunction)
! */
    glutDisplayFunc(DrawScene);
    glutIdleFunc(Idle);
    glutKeyboardFunc(KeyPressed);
! //  glutMouseFunc(MouseFunction);
! 
!   g_poWorld->InitGL(800, 600, false);
! 
    glutMainLoop();
  





reply via email to

[Prev in Thread] Current Thread [Next in Thread]