www.pudn.com > OpenGL32.rar > OpenGL1View.h
// OpenGL1View.h : interface of the COpenGL1View class // ///////////////////////////////////////////////////////////////////////////// #include#include #include #include #include #include #include #include #include #include #if !defined(AFX_OPENGL1VIEW_H__B8797846_B38E_4C1D_A1F3_F96FFD010E3F__INCLUDED_) #define AFX_OPENGL1VIEW_H__B8797846_B38E_4C1D_A1F3_F96FFD010E3F__INCLUDED_ #if _MSC_VER > 1000 #pragma once #endif // _MSC_VER > 1000 #define MAP_W 32 #define MAP_SCALE 24.0f #define MAP MAP_W*MAP_SCALE/2 #define KEY_DOWN(vk_code)((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0) #define RAND_COORD(x) ((float)rand()/RAND_MAX * (x)) #define FRAND (((float)rand()-(float)rand())/RAND_MAX) static char *filename[] = {"3Front.bmp","3Left.bmp","3RBack.bmp","3Right.bmp","3Top.bmp","sand0.bmp"}; #include "vectorlib.h" #include "BITMAP.H" #define RAND_COORD(x) ((float)rand()/RAND_MAX * (x)) class COpenGL1View : public CView { protected: // create from serialization only COpenGL1View(); DECLARE_DYNCREATE(COpenGL1View) GLint angleX,angleY; // Attributes public: COpenGL1Doc* GetDocument(); UINT texture[6]; float g_terrain [MAP_W*MAP_W][3]; GLuint g_index [MAP_W*MAP_W* 2]; float g_texcoord [MAP_W*MAP_W][2]; UINT g_cactus[4]; // Operations public: float g_eye [3]; float g_look[3]; float rad_xz; float g_Angle; float g_elev; // Overrides // ClassWizard generated virtual function overrides //{{AFX_VIRTUAL(COpenGL1View) public: virtual void OnDraw(CDC* pDC); // overridden to draw this view virtual BOOL PreCreateWindow(CREATESTRUCT& cs); protected: virtual BOOL OnPreparePrinting(CPrintInfo* pInfo); virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo); virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo); //}}AFX_VIRTUAL // Implementation public: void texture0(UINT textur); void InitTerrain(float h); CClientDC * m_pDC; virtual ~COpenGL1View(); #ifdef _DEBUG virtual void AssertValid() const; virtual void Dump(CDumpContext& dc) const; #endif protected: bool LoadT8(char *filename, GLuint &texture); // Generated message map functions protected: float GetHeight(float x, float z); void LoadT16(char *filename, GLuint &texture); void ShowTree(float x,float z,float h,float s,int cactus); void DrawScene(); //{{AFX_MSG(COpenGL1View) afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); afx_msg void OnDestroy(); afx_msg void OnSize(UINT nType, int cx, int cy); afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags); //}}AFX_MSG DECLARE_MESSAGE_MAP() private: CRect m_OldRect; BOOL bSetupPixelFormat(); void Init(); }; #ifndef _DEBUG // debug version in OpenGL1View.cpp inline COpenGL1Doc* COpenGL1View::GetDocument() { return (COpenGL1Doc*)m_pDocument; } #endif ///////////////////////////////////////////////////////////////////////////// //{{AFX_INSERT_LOCATION}} // Microsoft Visual C++ will insert additional declarations immediately before the previous line. #endif // !defined(AFX_OPENGL1VIEW_H__B8797846_B38E_4C1D_A1F3_F96FFD010E3F__INCLUDED_)