Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/src/importer/windowHandler.cc @ 3363

Last change on this file since 3363 was 3140, checked in by bensch, 20 years ago

orxonox/trunk: merged branches/images back into the trunk.
merged with command: svn merge bensches/images/ trunk/ -r 3084:HEAD

Conflicts in configure/.ac

resolved in favor of branches/images (newer)

Mayor differences:

  1. Image-Importing capability.
  2. configure remade for usage with sdl-image/jpeglib and so on.
  3. Absolutely no change in the trunk/src
File size: 2.4 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Benjamin Grauer
13   co-programmer: ...
14*/
15
16#include "windowHandler.h"
17#include <stdio.h>
18void WindowHandler::ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
19{
20        if (height==0)  // Prevent A Divide By Zero By
21        {
22                height=1;// Making Height Equal One
23        }
24
25        glViewport(0,0,width,height); // Reset The Current Viewport
26
27       
28        glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
29        glLoadIdentity();       
30
31
32        // Calculate The Aspect Ratio Of The Window
33        gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
34        gluLookAt (0,0,15, 0,0,0, 0,1,0);
35
36        glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
37        glLoadIdentity(); // Reset The Modelview Matrix
38
39}
40
41
42int WindowHandler::InitGL(GLvoid)                                                                               // All Setup For OpenGL Goes Here
43{
44        glEnable(GL_TEXTURE_2D); // Enable Texture Mapping
45        glShadeModel(GL_SMOOTH); // Enable Smooth Shading
46        glClearColor(0.00f, 0.00f, 0.00f, 0.0f); // Black Background
47        glClearDepth(1.0f);  // Depth Buffer Setup
48        glEnable(GL_DEPTH_TEST); // Enables Depth Testing
49        glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
50        glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);  // Really Nice Perspective Calculations
51
52    return TRUE;
53}
54
55
56GLvoid WindowHandler::KillGLWindow(GLvoid) // Properly Kill The Window
57{
58        SDL_Quit();
59}
60
61
62BOOL WindowHandler::CreateGLWindow(char* title, int width, int height, int bits, BOOL fullscreenflag)
63{
64        Uint32 flags;
65        int size;
66
67        /* Initialize SDL */
68        if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
69                fprintf(stderr, "Couldn't init SDL: %s\n", SDL_GetError());
70                return FALSE;
71        }
72
73        flags = SDL_OPENGL;
74        if ( fullscreenflag ) {
75                flags |= SDL_FULLSCREEN;
76        }
77        SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 1 );
78        if ( (screen = SDL_SetVideoMode(width, height, 0, flags)) == NULL ) {
79                return FALSE;
80        }
81        SDL_GL_GetAttribute( SDL_GL_STENCIL_SIZE, &size);
82
83        ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
84
85        if (!InitGL()) // Initialize Our Newly Created GL Window
86        {
87          KillGLWindow();  // Reset The Display
88          return FALSE;
89        }
90
91        return TRUE;
92}
93
94
Note: See TracBrowser for help on using the repository browser.