glview.h
上传用户:lbr_007
上传日期:2019-05-31
资源大小:282k
文件大小:2k
- // glview.h
- //
- #ifndef GLVIEW_3D_IMAGE_INCLUDE
- #define GLVIEW_3D_IMAGE_INCLUDE
- #include <dibsect.h>
- #include "matrix3d.h"
- #include "geo.h"
- void ComputeNormalVector(double p1[3], double p2[3],
- double p3[3], double n[3]);
- void NormalVector(GLdouble p1[3], GLdouble p2[3],
- GLdouble p3[3], GLdouble n[3]);
- class GLView3D {
- void InitImage(void)
- {
- m_hGLContext = 0;
- m_IsInitialized = 0;
- m_red_bg = m_green_bg = m_blue_bg = 1.0;
- m_reRender = true;
- m_pickMode = false;
- }
- void InitGeometry(void);
- protected:
- // OpenGL specific
- BOOL SetWindowPixelFormat(HDC hDC);
- BOOL SetImagePixelFormat(HDC hDC);
- void MakeImageCurrent(HDC hDC)
- {
- wglMakeCurrent(hDC,m_hGLContext);
- }
- BOOL CreateImageGLContext(HDC hDC);
- int CreateView(void);
- void InitializeOpenGL(void);
- void PushMatrixValues(void);
- void PopMatrixValues(void);
- protected:
- // OpenGL attributes
- HGLRC m_hGLContext;
- int m_IsInitialized;
- int m_GLPixelIndex;
- DIBSection m_dib;
- Matrix3D m_view_matrix;
- Matrix3D m_model_matrix;
- Matrix3D m_saved_matrix;
- double m_red_bg; // colors between 0 and 1
- double m_green_bg;
- double m_blue_bg;
- bool m_reRender;
- bool m_pickMode;
- INT32 m_pickX, m_pickY, m_pickID;
- public:
- GLView3D(void);
- virtual ~GLView3D(void);
- DIBSection * GetDIB(void){ return &m_dib;}
- void CreateImage(UINT32 width, UINT32 height);
- void SizeImage(UINT32 width, UINT32 height);
- virtual void RebuildImage(void){ m_reRender = true;}
- virtual void RenderImage(void);
- virtual void RenderPrimaryImage(void);
- virtual void SetOrientation(void);
- virtual void DrawImage(CWnd * wnd);
- int IsInitialized(void)const{ return m_IsInitialized;}
- void SetViewState(const Matrix3D& matrix);
- Matrix3D& GetViewState(void){ return m_view_matrix;}
- void SetModelState(const Matrix3D& matrix){ m_model_matrix = matrix;}
- Matrix3D& GetModelState(void){ return m_model_matrix;}
- void SetSavedState(const Matrix3D& matrix);
- Matrix3D& GetSavedState(void){ return m_saved_matrix;}
- void SetBackgroundColor(double r, double g, double b);
- void DrawCone(double * v, bool pointingOut = true);
- void PickObject(int x, int y, int& id);
- };
- #endif