Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3610 in orxonox.OLD


Ignore:
Timestamp:
Mar 21, 2005, 1:36:16 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: first definition of the Grahpics-class. more to follow, (and to read about)

Location:
orxonox/trunk/src
Files:
4 edited
2 copied

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/Makefile.am

    r3608 r3610  
    5252                 lib/coord/helper_parent.cc \
    5353                 lib/data/data_tank.cc \
     54                 lib/graphics/graphics_engine.cc \
    5455                 lib/graphics/light.cc \
    5556                 lib/graphics/font/fontset.cc \
     
    104105                 lib/coord/null_parent.h \
    105106                 lib/coord/helper_parent.h \
     107                 lib/graphics/graphics_engine.h \
    106108                 lib/graphics/light.h \
    107109                 lib/graphics/font/fontset.h \
  • orxonox/trunk/src/Makefile.in

    r3608 r3610  
    6262        projectile.$(OBJEXT) character_attributes.$(OBJEXT) \
    6363        ai.$(OBJEXT) p_node.$(OBJEXT) null_parent.$(OBJEXT) \
    64         helper_parent.$(OBJEXT) data_tank.$(OBJEXT) light.$(OBJEXT) \
    65         fontset.$(OBJEXT) array.$(OBJEXT) objModel.$(OBJEXT) \
    66         model.$(OBJEXT) material.$(OBJEXT) texture.$(OBJEXT) \
    67         base_entity.$(OBJEXT) base_object.$(OBJEXT) \
    68         ini_parser.$(OBJEXT) list.$(OBJEXT) vector.$(OBJEXT) \
    69         curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT)
     64        helper_parent.$(OBJEXT) data_tank.$(OBJEXT) \
     65        graphics_engine.$(OBJEXT) light.$(OBJEXT) fontset.$(OBJEXT) \
     66        array.$(OBJEXT) objModel.$(OBJEXT) model.$(OBJEXT) \
     67        material.$(OBJEXT) texture.$(OBJEXT) base_entity.$(OBJEXT) \
     68        base_object.$(OBJEXT) ini_parser.$(OBJEXT) list.$(OBJEXT) \
     69        vector.$(OBJEXT) curve.$(OBJEXT) glmenu_imagescreen.$(OBJEXT)
    7070orxonox_OBJECTS = $(am_orxonox_OBJECTS)
    7171orxonox_LDADD = $(LDADD)
     
    8383@AMDEP_TRUE@    ./$(DEPDIR)/game_loader.Po \
    8484@AMDEP_TRUE@    ./$(DEPDIR)/glmenu_imagescreen.Po \
     85@AMDEP_TRUE@    ./$(DEPDIR)/graphics_engine.Po \
    8586@AMDEP_TRUE@    ./$(DEPDIR)/helper_parent.Po \
    8687@AMDEP_TRUE@    ./$(DEPDIR)/ini_parser.Po ./$(DEPDIR)/keynames.Po \
     
    253254                 lib/coord/helper_parent.cc \
    254255                 lib/data/data_tank.cc \
     256                 lib/graphics/graphics_engine.cc \
    255257                 lib/graphics/light.cc \
    256258                 lib/graphics/font/fontset.cc \
     
    305307                 lib/coord/null_parent.h \
    306308                 lib/coord/helper_parent.h \
     309                 lib/graphics/graphics_engine.h \
    307310                 lib/graphics/light.h \
    308311                 lib/graphics/font/fontset.h \
     
    405408@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/game_loader.Po@am__quote@
    406409@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/glmenu_imagescreen.Po@am__quote@
     410@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/graphics_engine.Po@am__quote@
    407411@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/helper_parent.Po@am__quote@
    408412@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ini_parser.Po@am__quote@
     
    718722@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
    719723@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o data_tank.obj `if test -f 'lib/data/data_tank.cc'; then $(CYGPATH_W) 'lib/data/data_tank.cc'; else $(CYGPATH_W) '$(srcdir)/lib/data/data_tank.cc'; fi`
     724
     725graphics_engine.o: lib/graphics/graphics_engine.cc
     726@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT graphics_engine.o -MD -MP -MF "$(DEPDIR)/graphics_engine.Tpo" -c -o graphics_engine.o `test -f 'lib/graphics/graphics_engine.cc' || echo '$(srcdir)/'`lib/graphics/graphics_engine.cc; \
     727@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/graphics_engine.Tpo" "$(DEPDIR)/graphics_engine.Po"; else rm -f "$(DEPDIR)/graphics_engine.Tpo"; exit 1; fi
     728@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/graphics/graphics_engine.cc' object='graphics_engine.o' libtool=no @AMDEPBACKSLASH@
     729@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/graphics_engine.Po' tmpdepfile='$(DEPDIR)/graphics_engine.TPo' @AMDEPBACKSLASH@
     730@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     731@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o graphics_engine.o `test -f 'lib/graphics/graphics_engine.cc' || echo '$(srcdir)/'`lib/graphics/graphics_engine.cc
     732
     733graphics_engine.obj: lib/graphics/graphics_engine.cc
     734@am__fastdepCXX_TRUE@   if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT graphics_engine.obj -MD -MP -MF "$(DEPDIR)/graphics_engine.Tpo" -c -o graphics_engine.obj `if test -f 'lib/graphics/graphics_engine.cc'; then $(CYGPATH_W) 'lib/graphics/graphics_engine.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/graphics_engine.cc'; fi`; \
     735@am__fastdepCXX_TRUE@   then mv -f "$(DEPDIR)/graphics_engine.Tpo" "$(DEPDIR)/graphics_engine.Po"; else rm -f "$(DEPDIR)/graphics_engine.Tpo"; exit 1; fi
     736@AMDEP_TRUE@@am__fastdepCXX_FALSE@      source='lib/graphics/graphics_engine.cc' object='graphics_engine.obj' libtool=no @AMDEPBACKSLASH@
     737@AMDEP_TRUE@@am__fastdepCXX_FALSE@      depfile='$(DEPDIR)/graphics_engine.Po' tmpdepfile='$(DEPDIR)/graphics_engine.TPo' @AMDEPBACKSLASH@
     738@AMDEP_TRUE@@am__fastdepCXX_FALSE@      $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
     739@am__fastdepCXX_FALSE@  $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o graphics_engine.obj `if test -f 'lib/graphics/graphics_engine.cc'; then $(CYGPATH_W) 'lib/graphics/graphics_engine.cc'; else $(CYGPATH_W) '$(srcdir)/lib/graphics/graphics_engine.cc'; fi`
    720740
    721741light.o: lib/graphics/light.cc
  • orxonox/trunk/src/defs/debug.h

    r3602 r3610  
    6262#define DEBUG_MODULE_WORLD_ENTITY       0
    6363#define DEBUG_MODULE_COMMAND_NODE       0
     64#define DEBUG_MODULE_GRAPHICS           0
    6465
    6566#define DEBUG_MODULE_IMPORTER           0
  • orxonox/trunk/src/lib/graphics/graphics_engine.cc

    r3609 r3610  
    1 
    2 
    31/*
    42   orxonox - the future of 3D-vertical-scrollers
     
    1210
    1311   ### File Specific:
    14    main-programmer: ...
     12   main-programmer: Benjamin Grauer
    1513   co-programmer: ...
    1614*/
    1715
    18 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD_ENTITY
     16#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
    1917
    20 #include "proto_class.h"
    21 
    22 #include "stdincl.h" // maybe
     18#include "graphics_engine.h"
    2319
    2420using namespace std;
     
    2925   \todo this constructor is not jet implemented - do it
    3026*/
    31 ProtoClass::ProtoClass ()
     27GraphicsEngine::GraphicsEngine ()
    3228{
    33    this->setClassName ("ProtoClass");
     29   this->setClassName ("GraphicsEngine");
     30
     31
     32
     33  if (SDL_Init(SDL_INIT_VIDEO) == -1)
     34    {
     35      printf ("could not initialize SDL Video\n");
     36      //      return -1;
     37    }
     38  // Set video mode
     39  // TO DO: parse arguments for settings
     40  //SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
     41  //SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
     42  //SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
     43  //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
     44 
     45
     46  SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );   
     47  SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);   
     48  SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); 
     49  SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0);
     50  SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0);
     51  SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
     52  SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);
     53
     54
     55
     56  int bpp = 16;
     57  int width = 640;
     58  int height = 480;
     59  //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/
     60  //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER;
     61
     62  Uint32 videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE;
     63
     64  /* query SDL for information about our video hardware */
     65  const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
     66 
     67  if( videoInfo == NULL)
     68    {
     69      printf ("Orxonox::initVideo() - Failed getting Video Info :%s\n", SDL_GetError());
     70      SDL_Quit ();
     71    }
     72  if( videoInfo->hw_available)
     73    videoFlags |= SDL_HWSURFACE;
     74  else
     75    videoFlags |= SDL_SWSURFACE;
     76  /*
     77  if(VideoInfo -> blit_hw)                           
     78    VideoFlags |= SDL_HWACCEL;
     79  */
     80 
     81  if((this->screen = SDL_SetVideoMode (width, height, bpp, videoFlags)) == NULL)
     82  {
     83    printf("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", width, height, bpp, videoFlags, SDL_GetError());
     84    SDL_Quit();
     85    //    return -1;
     86  }
     87 
     88  // Set window labeling
     89  SDL_WM_SetCaption ("Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION);
     90 
     91  // TO DO: Create a cool icon and use it here
     92  // SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); 
     93
     94
     95
     96}
     97
     98GraphicsEngine* GraphicsEngine::singletonRef = NULL;
     99
     100GraphicsEngine* GraphicsEngine::getInstance()
     101{
     102  if (!GraphicsEngine::singletonRef)
     103    GraphicsEngine::singletonRef = new GraphicsEngine();
     104  return GraphicsEngine::singletonRef;
    34105}
    35106
     
    39110
    40111*/
    41 ProtoClass::~ProtoClass ()
     112GraphicsEngine::~GraphicsEngine ()
    42113{
    43114  // delete what has to be deleted here
    44115}
    45116
    46 /**
    47    \brief nonsense - delete this method
    48    \param realy nothing to give
    49    \returns true or false - probably nothing?
    50 
    51    this is just to show the doxygen abilities (this for example is an extension for a long comment)
    52 */
    53 bool ProtoClass::doNonSense (int nothing) {}
  • orxonox/trunk/src/lib/graphics/graphics_engine.h

    r3609 r3610  
    11/*!
    2     \file proto_class.h
    3     \brief Definition of the proto class template, used quickly start work
    4     \todo Example: this shows how to use simply add a Marker that here has to be done something.
     2    \file graphics_engine.h
     3   
     4    \brief defines a Interface between orxonox and graphical input
    55
    6     The Protoclass exists, to help you quikly getting the run for how to develop in orxonox.
    7     It is an example for the CODING-CONVENTION, and a starting-point for every class.
     6    handles graphical SDL-initialisation, textures, resolutions, and so on
    87*/
    98
    10 #ifndef _PROTO_CLASS_H
    11 #define _PROTO_CLASS_H
     9#ifndef _GRAPHICS_ENGINE_H
     10#define _GRAPHICS_ENGINE_H
    1211
    13 #include "what realy has to be included"
     12#include <SDL/SDL.h>
     13
    1414#include "base_object.h"
    1515
    1616// FORWARD DEFINITION \\
    17 class someClassWeNeed;
    1817
    1918
    20 /*class Test;*/ /* forward definition of class Test (without including it here!)*/
    21 
    22 //! A default class that aids you to start creating a new class
    23 /**
    24    here can be some longer description of this class
    25 */
    26 class ProtoClass : public BaseObject {
    27 
     19class GraphicsEngine : public BaseObject
     20{
    2821 public:
    29   ProtoClass();
    30   virtual ~ProtoClass();
    31 
    32   bool doNonSense (int nothing);
     22  static GraphicsEngine* getInstance();
     23  virtual ~GraphicsEngine();
    3324
    3425 private:
    35   int nonSense;  //!< doxygen tag here like this for all the variables - delete this variable if you use this
     26  GraphicsEngine();
     27  static GraphicsEngine* singletonRef;
    3628
     29
     30  SDL_Surface* screen;
    3731};
    3832
    39 #endif /* _PROTO_CLASS_H */
     33#endif /* _GRAPHICS_ENGINE_H */
  • orxonox/trunk/src/orxonox.cc

    r3592 r3610  
    2525
    2626#include "orxonox.h"
     27
    2728#include "world.h"
    2829#include "camera.h"
     
    3031#include "command_node.h"
    3132#include "game_loader.h"
     33#include "graphics_engine.h"
     34
    3235#include <string.h>
    3336int verbose = 4;
     
    111114{
    112115  printf("> Initializing video\n");
    113   if (SDL_Init(SDL_INIT_VIDEO) == -1)
    114     {
    115       printf ("could not initialize SDL Video\n");
    116       return -1;
    117     }
    118   // Set video mode
    119   // TO DO: parse arguments for settings
    120   //SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
    121   //SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
    122   //SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
    123   //SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    124  
    125 
    126   SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );   
    127   SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, 16);   
    128   SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 0); 
    129   SDL_GL_SetAttribute( SDL_GL_ACCUM_RED_SIZE, 0);
    130   SDL_GL_SetAttribute( SDL_GL_ACCUM_GREEN_SIZE, 0);
    131   SDL_GL_SetAttribute( SDL_GL_ACCUM_BLUE_SIZE, 0);
    132   SDL_GL_SetAttribute( SDL_GL_ACCUM_ALPHA_SIZE, 0);
    133 
    134 
    135 
    136   int bpp = 16;
    137   int width = 640;
    138   int height = 480;
    139   //Uint32 flags = SDL_HWSURFACE | SDL_OPENGL | SDL_GL_DOUBLEBUFFER; /* \todo: SDL_OPENGL doen't permit to load images*/
    140   //Uint32 flags = SDL_HWSURFACE | SDL_GL_DOUBLEBUFFER;
    141 
    142   Uint32 videoFlags = SDL_OPENGL | SDL_HWPALETTE | SDL_RESIZABLE;
    143 
    144   /* query SDL for information about our video hardware */
    145   const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
    146  
    147   if( videoInfo == NULL)
    148     {
    149       printf ("Orxonox::initVideo() - Failed getting Video Info :%s\n", SDL_GetError());
    150       SDL_Quit ();
    151     }
    152   if( videoInfo->hw_available)
    153     videoFlags |= SDL_HWSURFACE;
    154   else
    155     videoFlags |= SDL_SWSURFACE;
    156   /*
    157   if(VideoInfo -> blit_hw)                           
    158     VideoFlags |= SDL_HWACCEL;
    159   */
    160  
    161   if((this->screen = SDL_SetVideoMode (width, height, bpp, videoFlags)) == NULL)
    162   {
    163     printf("Could not SDL_SetVideoMode(%d, %d, %d, %d): %s\n", width, height, bpp, videoFlags, SDL_GetError());
    164     SDL_Quit();
    165     return -1;
    166   }
    167  
    168   // Set window labeling
    169   SDL_WM_SetCaption ("Orxonox " PACKAGE_VERSION, "Orxonox " PACKAGE_VERSION);
    170  
    171   // TO DO: Create a cool icon and use it here
    172   // SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask); 
    173 
     116 
     117  GraphicsEngine::getInstance();
     118 
    174119  return 0;
    175120}
Note: See TracChangeset for help on using the changeset viewer.