Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2931 in orxonox.OLD for orxonox/trunk/importer/framework.cc


Ignore:
Timestamp:
Nov 20, 2004, 1:33:51 PM (21 years ago)
Author:
bensch
Message:

orxonox/trunk/importer: included mouse-speed-turning (touch the screen and the object will start to move). Also included windows.h if in WIN32. general cleanup of framework

File:
1 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/importer/framework.cc

    r2863 r2931  
    1 #include "windowHandler.h" // Include the Whandler Basecode
    2 #include "object.h"
     1#include "framework.h"
    32
    43int verbose = 1;
    5 WindowHandler wHandler;  // Create an instance of the whandler basecode class
    6 Object* obj;
    7 float rotator = 0.0;
    8   GLfloat whiteLight[] = {1.0, 1.0, 0.0,1.0};
    94
    105void DrawGLScene()
    116{
    12   rotator +=.001;
     7  rotatorP += rotatorV;
    138 
    149  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
     
    1813  glLoadIdentity();     
    1914  gluPerspective(45.0f,500/375,0.1f,100.0f);
    20   gluLookAt (5*sin(rotator),7.5,5*cos(rotator), 0,0,0, 0,1,0);
    21   whiteLight[1] = .5+.5*sin(rotator*10);
    22   whiteLight[2] = .5+.5*sin(rotator*10);
     15  gluLookAt (5*sin(rotatorP),7.5,5*cos(rotatorP), 0,0,0, 0,1,0);
    2316
    24   GLfloat lightPosition[] = {10.0*sin(rotator*10), 10, 19.0, 0.0};
    25   glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
    26 
    27   glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
    2817  obj->draw();
    2918
     
    5342    obj = new Object();
    5443 
     44  glEnable(GL_LIGHTING);
     45  glEnable(GL_DEPTH_TEST);
     46
     47  GLfloat whiteLight[] = {1.0, 1.0, 1.0,1.0};
     48  GLfloat light0Position[] = {10.0, 10.0, 10.0, 0.0};
     49  GLfloat light1Position[] = {-10.0, -7.0, -6.0, 0.0};
    5550  GLfloat lmodelAmbient[] = {.1, .1, .1, 1.0};
     51
     52  glEnable(GL_LIGHT0);
     53  glLightfv(GL_LIGHT0, GL_POSITION, light0Position);
    5654  glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteLight);
    5755  glLightfv(GL_LIGHT0, GL_SPECULAR, whiteLight);
    58   glEnable(GL_LIGHTING);
    59   glEnable(GL_LIGHT0);
    60   glEnable(GL_DEPTH_TEST);
    61 
     56 
     57  glEnable(GL_LIGHT1);
     58  glLightfv(GL_LIGHT1, GL_POSITION, light1Position);
     59  glLightfv(GL_LIGHT1, GL_DIFFUSE, whiteLight);
     60  glLightfv(GL_LIGHT1, GL_SPECULAR, whiteLight);
     61 
     62  rotatorP = .0;
     63  rotatorV = .0;
    6264  // Build the font from a TGA image font.tga in the data directory
    6365  // Hide the mouse cursor
    64   SDL_ShowCursor(0);
     66    SDL_ShowCursor(2);
    6567
    6668  // This is the main loop for the entire program and it will run until done==TRUE
     
    7375    while ( SDL_PollEvent(&event) ) {
    7476      switch (event.type) {
     77      case SDL_MOUSEMOTION:
     78        if (verbose >=3)
     79          printf("Mouse motion about %d,%d Pixels to (%d,%d).\n",
     80                 event.motion.xrel, event.motion.yrel,
     81                 event.motion.x, event.motion.y);
     82        break;
     83      case SDL_MOUSEBUTTONDOWN:
     84        printf("MouseButton %d pressed at (%d,%d).\n",
     85               event.button.button, event.button.x, event.button.y);
     86        rotatorV = ( 250-event.button.x) / 500.0 /100;
     87       
     88        break;
     89      case SDL_MOUSEBUTTONUP:
     90        printf("MouseButton %d released at (%d,%d).\n",
     91               event.button.button, event.button.x, event.button.y);
     92
     93       
     94        break;
     95
    7596        // If a quit event was recieved
    7697      case SDL_QUIT:
Note: See TracChangeset for help on using the changeset viewer.