Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

OgreSDLRenderSystem.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004     (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://ogre.sourceforge.net/
00006 
00007 Copyright © 2000-2002 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __SDLRENDERSYSTEM_H__
00026 #define __SDLRENDERSYSTEM_H__
00027 
00028 #include "OgrePlatform.h"
00029 #include "OgreRenderSystem.h"
00030 
00031 #include <SDL.h>
00032 
00033 #if OGRE_PLATFORM == PLATFORM_WIN32
00034 #   include <windows.h>
00035 #   include <wingdi.h>
00036 #   include "gl.h"
00037 #   define GL_GLEXT_PROTOTYPES
00038 #   include "glprocs.h"
00039 #   include <GL/glu.h>
00040 #elif OGRE_PLATFORM == PLATFORM_LINUX
00041 #   include <GL/gl.h>
00042 #   include <GL/glu.h>
00043 #elif OGRE_PLATFORM == PLATFORM_APPLE
00044 #   include <OpenGL/gl.h>
00045 #   define GL_EXT_texture_env_combine 1
00046 #   include <OpenGL/glext.h>
00047 #   include <OpenGL/glu.h>
00048 #endif
00049 
00050 
00051 
00052 namespace Ogre {
00053 
00057     class SDLRenderSystem : public RenderSystem
00058     {
00059     private:
00060 
00061         // Allowed video modes
00062         SDL_Rect** mVideoModes;
00063 
00064         // Rendering loop control
00065         bool mStopRendering;
00066 
00067         // Array of up to 8 lights, indexed as per API
00068         // Note that a null value indicates a free slot
00069         #define MAX_LIGHTS 8
00070         Light* mLights[MAX_LIGHTS];
00071 
00072         // view matrix to set world against
00073         Matrix4 mViewMatrix;
00074         Matrix4 mWorldMatrix;
00075         Matrix4 mTextureMatrix;
00076 
00077         // XXX 8 max texture units?
00078         int mTextureCoordIndex[OGRE_MAX_TEXTURE_COORD_SETS];
00079 
00080 
00081         void initConfigOptions(void);
00082         void initInputDevices(void);
00083         void processInputDevices(void);
00084 
00085         void setGLLight(int index, Light* lt);
00086         void makeGLMatrix(GLfloat gl_matrix[16], const Matrix4& m);
00087  
00088         GLint getBlendMode(SceneBlendFactor ogreBlend);
00089 
00090         void setLights();
00091 
00092         // Store last depth write state
00093         bool mDepthWrite;
00094 
00095         GLint convertCompareFunction(CompareFunction func);
00096         GLint convertStencilOp(StencilOperation op);
00097 
00098         // Save stencil settings since GL insists on having them in groups
00099         // Means we have to call functions more than once, but what the hey
00100         GLint mStencilFunc, mStencilRef;
00101         GLuint mStencilMask;
00102         GLint mStencilFail, mStencilZFail, mStencilPass;
00103 
00104 
00105     public:
00106         // Default constructor / destructor
00107         SDLRenderSystem();
00108         ~SDLRenderSystem();
00109 
00110 
00111 
00112         // ----------------------------------
00113         // Overridden RenderSystem functions
00114         // ----------------------------------
00118         const String& getName(void) const;
00122         ConfigOptionMap& getConfigOptions(void);
00126         void setConfigOption(const String &name, const String &value);
00130         String validateConfigOptions(void);
00134         RenderWindow* initialise(bool autoCreateWindow);
00138         void reinitialise(void); // Used if settings changed mid-rendering
00142         void shutdown(void);
00143 
00147         void startRendering(void);
00151         void setAmbientLight(float r, float g, float b);
00155         void setShadingType(ShadeOptions so);
00159         void setTextureFiltering(TextureFilterOptions fo);
00163         void setLightingEnabled(bool enabled);
00167         RenderWindow* createRenderWindow(const String &name, int width, int height, int colourDepth,
00168             bool fullScreen, int left = 0, int top = 0, bool depthBuffer = true,
00169             RenderWindow* parentWindowHandle = 0);
00170 
00171         RenderTexture * createRenderTexture( const String & name, int width, int height );
00172 
00176         void destroyRenderWindow(RenderWindow* pWin);
00180         String getErrorDescription(long errorNumber);
00181 
00185         void convertColourValue(const ColourValue& colour, unsigned long* pDest);
00186 
00187         // -----------------------------
00188         // Low-level overridden members
00189         // -----------------------------
00193         void _addLight(Light *lt);
00197         void _removeLight(Light *lt);
00201         void _modifyLight(Light* lt);
00205         void _removeAllLights(void);
00209         void _pushRenderState(void);
00213         void _popRenderState(void);
00217         void _setWorldMatrix(const Matrix4 &m);
00221         void _setViewMatrix(const Matrix4 &m);
00225         void _setProjectionMatrix(const Matrix4 &m);
00229         void _setSurfaceParams(const ColourValue &ambient,
00230             const ColourValue &diffuse, const ColourValue &specular,
00231             const ColourValue &emissive, Real shininess);
00235         unsigned short _getNumTextureUnits(void);
00239         void _setTexture(int unit, bool enabled, const String &texname);
00243         void _setTextureCoordSet(int stage, int index);
00247         void _setTextureCoordCalculation(int stage, TexCoordCalcMethod m);
00251         void _setTextureBlendMode(int stage, const LayerBlendModeEx& bm);
00255         void _setTextureAddressingMode(int stage, Material::TextureLayer::TextureAddressingMode tam);
00259         void _setTextureMatrix(int stage, const Matrix4& xform);
00263         void _setSceneBlending(SceneBlendFactor sourceFactor, SceneBlendFactor destFactor);
00267         void _setAlphaRejectSettings(CompareFunction func, unsigned char value);
00271         void _setViewport(Viewport *vp);
00275         void _beginFrame(void);
00279         void _render(RenderOperation& op);
00283         void _endFrame(void);
00287         void _setCullingMode(CullingMode mode);
00291         void _setDepthBufferParams(bool depthTest = true, bool depthWrite = true, CompareFunction depthFunction = CMPF_LESS_EQUAL);
00295         void _setDepthBufferCheckEnabled(bool enabled = true);
00299         void _setDepthBufferWriteEnabled(bool enabled = true);
00303         void _setDepthBufferFunction(CompareFunction func = CMPF_LESS_EQUAL);
00307         void _setDepthBias(ushort bias);
00311         void _setFog(FogMode mode, ColourValue colour, Real density, Real start, Real end);
00315         void _makeProjectionMatrix(Real fovy, Real aspect, Real nearPlane, Real farPlane, Matrix4& dest);
00319         void _setRasterisationMode(SceneDetailLevel level);
00323         void setStencilCheckEnabled(bool enabled);
00327         bool hasHardwareStencil(void);
00331         ushort getStencilBufferBitDepth(void);
00335         void setStencilBufferFunction(CompareFunction func);
00339         void setStencilBufferReferenceValue(ulong refValue);
00343         void setStencilBufferMask(ulong mask);
00347         void setStencilBufferFailOperation(StencilOperation op);
00351         void setStencilBufferDepthFailOperation(StencilOperation op);
00355         void setStencilBufferPassOperation(StencilOperation op);
00361         void setStencilBufferParams(CompareFunction func = CMPF_ALWAYS_PASS, 
00362             ulong refValue = 0, ulong mask = 0xFFFFFFFF, 
00363             StencilOperation stencilFailOp = SOP_KEEP, 
00364             StencilOperation depthFailOp = SOP_KEEP,
00365             StencilOperation passOp = SOP_KEEP);
00366         // ----------------------------------
00367         // End Overridden members
00368         // ----------------------------------
00369 
00370 
00371 
00372     };
00373 }
00374 #endif
00375 

Copyright © 2002 by The OGRE Team