| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 
 | #if defined(__BORLANDC__)
 
#pragma hdrstop
#include <condefs.h>
 
USELIB("SDL.LIB");
USEUNIT("..\ecam\fctl.cpp");
USEUNIT("..\ecam\door.cpp");
USEUNIT("..\ecam\hyd.cpp");
USEUNIT("..\ecam\colours.cpp");
USEUNIT("..\ecam\statusArea.cpp");
USEUNIT("..\efis\pfd.cpp");
USEUNIT("..\libGC-common\dl.cpp");
USEUNIT("..\libGC-common\diom.cpp");
USEUNIT("..\libGC-common\configfile.cpp");
USEUNIT("..\libGC-common\targa.cpp");
USEUNIT("..\libGC-common\position.cpp");
USEUNIT("..\libGC-SDL\openGL.cpp");
USERES("a340gc.res");
//---------------------------------------------------------------------------
#define WIN32
#endif
//---------------------------------------------------------------------------
#ifdef WIN32
# include <windows.h>
#endif
//---------------------------------------------------------------------------
 
 
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
 
 
#include <stdlib.h>
 
#include "openGL.h"
#include "diom.h"
#include "dl.h"
#include "fctl.h"
#include "door.h"
#include "hyd.h"
#include "pfd.h"
 
#ifdef WIN32
# define FONT_VGA    "font.tga"
# define CONF_FILE   "a340gc.conf"
# define SEARCH_PATH ""
#else
# include <paths.h>
#endif
 
 
GLboolean drawOutline = false;
GLfloat   fZoom = 1.0;
GLint     iPage = 3;
 
 
static void handle_key_down( SDL_keysym* keysym )
{
  switch( keysym->sym ) {
  case SDLK_ESCAPE:
      exit(0);
      break;
  case SDLK_SPACE:
      drawOutline = !drawOutline;
      break;
  case SDLK_HOME:
      fZoom *= 1.1;
      break;
  case SDLK_END:
      fZoom /= 1.1;
      break;
  case '1':
  case '2':
  case '3':
  case '4':
  case '5':
      iPage = ((int)(keysym->sym) - (int)'1');
      break;
  default:
      break;
  }
}
 
static void process_events( void )
{
  /* Our SDL event placeholder. */
  SDL_Event event;
 
  /* Grab all the events off the queue. */
  while( SDL_PollEvent( &event ) ) {
    switch( event.type ) {
    case SDL_KEYDOWN:
      /* Handle key presses. */
      handle_key_down( &event.key.keysym );
      break;
    case SDL_QUIT:
      /* Handle quit requests (like Ctrl-c). */
      exit(0);
      break;
    }
  }
}
 
 
 
//---------------------------------------------------------------------------
#ifdef WIN32
# pragma argsused
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
#else
int main()
#endif
 
 { // C'EST ICI QU ON ME POINTE L ERREUR !!!
  /* Information about the current video settings. */
  const SDL_VideoInfo* info = NULL;
  /* Dimensions of our window. */
  int width = 0;
  int height = 0;
  /* Color depth in bits of our window. */
  int bpp = 0;
  /* Flags we will pass into SDL_SetVideoMode. */
  int flags = 0;
 
  if (!diom_init(CONF_FILE, SEARCH_PATH)) {
    printf("Failed to initialize Data Input Output Module:\n %s\n %s\n",
    diom_errorString(),
    dlerror());
    return 1;
  }
 
  GLEnvironment glEnv;
 
  /* Let's get some video information. */
  info = SDL_GetVideoInfo( );
 
  if( !info ) {
    /* This should probably never happen. */
    fprintf( stderr, "Video query failed: %s\n",
         SDL_GetError( ) );
    return -1;
  }
 
//    width = 640;
//    height = 480;
  width = 800;
  height = 600;
  bpp = info->vfmt->BitsPerPixel;
 
 
  SDL_GL_SetAttribute( SDL_GL_RED_SIZE, 5 );
  SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, 5 );
  SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, 5 );
  SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16 );
  SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
 
  flags = SDL_OPENGL | SDL_FULLSCREEN;
 
  /*
   * Set the video mode
   */
  if( SDL_SetVideoMode( width, height, bpp, flags ) == 0 ) {
    /*
     * This could happen for a variety of reasons,
     * including DISPLAY not being set, the specified
     * resolution not being available, etc.
     */
    fprintf( stderr, "Video mode set failed: %s\n",
             SDL_GetError( ) );
    return -1;
  }
 
  glEnv.setViewport(width, height);
  glEnv.setOrtho(-0.6666, 0.6666, -0.5, 0.5, 0, 1);
  glEnv.setShademodel(GL_FLAT);
  glEnv.loadFont(FONT_VGA);
 
  glClearColor( 0, 0, 0, 0 );
 
  ECAM_FCTL ecam_fctl(glEnv);
  ECAM_DOOR ecam_door(glEnv);
  ECAM_HYD  ecam_hyd(glEnv);
  EFIS_PFD  efis_pfd(glEnv);
 
  while ( 1 ) {
    process_events();
 
    glEnv.startPaint();
    glScaled(fZoom, fZoom, 1);
    glTranslatef(-0.5,-0.5,0);
 
    switch (iPage) {
      case 0: {
        ecam_fctl.lineWidth(fZoom*2);
        ecam_fctl.paint();
        break;
      }
      case 1: {
        ecam_door.lineWidth(fZoom*2);
        ecam_door.paint();
        break;
      }
      case 2: {
        ecam_hyd.lineWidth(fZoom*2);
        ecam_hyd.paint();
        break;
      }
      case 3: {
        efis_pfd.lineWidth(fZoom*2);
        efis_pfd.paint();
        break;
      }
    }
 
    if (drawOutline == true) {
      glColor3ub(255,255,255);
      glBegin(GL_LINE_LOOP);
        glVertex3f(0,0,0);
        glVertex3f(1,0,0);
        glVertex3f(1,1,0);
        glVertex3f(0,1,0);
      glEnd();
    }
    glEnv.endPaint();
  }
 
  /* Never reached. */
  return 0;
} | 
Partager