mgcrenderer.h

来自「3D Game Engine Design Source Code非常棒」· C头文件 代码 · 共 97 行

H
97
字号
// Magic Software, Inc.
// http://www.magic-software.com
// Copyright (c) 2000, All Rights Reserved
//
// Source code from Magic Software is supplied under the terms of a license
// agreement and may not be copied or disclosed except in accordance with the
// terms of that agreement.  The various license agreements may be found at
// the Magic Software web site.  This file is subject to the license
//
// RESTRICTED USE SOURCE CODE
// http://www.magic-software.com/License/restricted.pdf

#ifndef MGCRENDERER_H
#define MGCRENDERER_H

#include "MgcCamera.h"
#include "MgcColor.h"
#include "MgcAlphaState.h"
#include "MgcDitherState.h"
#include "MgcFogState.h"
#include "MgcLightState.h"
#include "MgcMaterialState.h"
#include "MgcShadeState.h"
#include "MgcTextureState.h"
#include "MgcVertexColorState.h"
#include "MgcWireframeState.h"
#include "MgcZBufferState.h"
class MgcGPTriMesh;
class MgcNode;
class MgcPolyline;
class MgcTriMesh;


class MgcRenderer : public MgcObject
{
    MgcDeclareRTTI;
    MgcDeclareStream;

public:
    virtual ~MgcRenderer ();
    bool IsConstructed () const;

    int GetWidth () const;
    int GetHeight () const;

    MgcCameraPtr SetCamera (MgcCamera* pkCamera);
    MgcCameraPtr GetCamera ();

    void SetState (const MgcRenderStatePtr aspkState[]);

    virtual void SetBackgroundColor (const MgcColor& rkColor);
    const MgcColor& GetBackgroundColor () const;
    virtual void ClearBackBuffer () = 0;
    virtual void DisplayBackBuffer () = 0;
    virtual void ClearZBuffer () = 0;
    virtual void ClearBuffers () = 0;

    void Draw (MgcNode* pkScene);
    virtual void Draw (const MgcPolyline& rkLine) { /**/ }
    virtual void Draw (const MgcTriMesh& rkMesh) { /**/ }
    virtual void Draw (const MgcGPTriMesh& rkMesh) { /**/ }

protected:
    // abstract base class
    MgcRenderer (int iWidth, int iHeight);
    MgcRenderer ();

    // state management
    virtual void InitializeState ();
    virtual void SetAlphaState (MgcAlphaState* pkState) = 0;
    virtual void SetDitherState (MgcDitherState* pkState) = 0;
    virtual void SetFogState (MgcFogState* pkState) = 0;
    virtual void SetLightState (MgcLightState* pkState) = 0;
    virtual void SetMaterialState (MgcMaterialState* pkState) = 0;
    virtual void SetShadeState (MgcShadeState* pkState) = 0;
    virtual void SetTextureState (MgcTextureState* pkState) = 0;
    virtual void SetVertexColorState (MgcVertexColorState* pkState) = 0;
    virtual void SetWireframeState (MgcWireframeState* pkState) = 0;
    virtual void SetZBufferState (MgcZBufferState* pkState) = 0;

    // construction
    bool m_bConstructed;

    // window parameters
    int m_iWidth, m_iHeight, m_iQuantity;
    MgcColor m_kBackgroundColor;

    // camera for establishing view frustum
    MgcCameraPtr m_spkCamera;
};

MgcSmartPointer(MgcRenderer);
MgcRegisterStream(MgcRenderer);
#include "MgcRenderer.inl"

#endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?