RenderView.h
上传用户:zbjingming
上传日期:2010-01-02
资源大小:2436k
文件大小:5k
- //********************************************
- // RenderView.h : interface of the CRenderView class
- //********************************************
- // feigz@ox.ios.ac.cn
- // Created :
- // Modified
- //********************************************
- #if !defined(AFX_RENDERVIEW_H__06A35633_72E5_11D1_A6C2_00A0242C0A32__INCLUDED_)
- #define AFX_RENDERVIEW_H__06A35633_72E5_11D1_A6C2_00A0242C0A32__INCLUDED_
- #if _MSC_VER >= 1000
- #pragma once
- #endif // _MSC_VER >= 1000
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <windows.h>
- #include <GL/gl.h>
- #include <GL/glu.h>
- #include <GL/glaux.h>
- #define INTS int
- #define REAL float
- #define Error 0
- #define NoError 1
- #define FALSE 0
- #define TRUE 1
- #define MINREAL 1.0e-5
- #define MAXREAL 1.0e10
- #define MAXINTS (0x7f<<24)
- #define zero(x) fabs(x) < MINREAL
- #define upint(x) (INTS)(x+1-MINREAL)
- #define addr(i,j) (long)(j)*cam.width+i
- #define MIN(x,y) ((x)<(y)?(x):(y))
- #define LEFT_EG 0x01
- #define RIGHT_EG 0x02
- #define HORIZ 0x04
- #define DCV 0x08
- #define UCV 0x10
- #define MAX_TEX 20
- #define CHARS signed char /* 1 byte signed char */
- #define CHARU unsigned char /* 1 byte unsigned char */
- #define INT2S signed short /* 2 byte signed int */
- #define INT2U unsigned short /* 2 byte unsigned int */
- #define INT4S signed long /* 4 byte signed int */
- #define INT4U unsigned long /* 4 byte unsigned int */
- #define INT8U unsigned long long /* 8 byte unsigned int */
- #define FLOAT float /* 4 byte */
- /* for material type */
- #define DIFFUSE 1
- #define SPECULAR 2
- #define ENERGY 8
- #define SAMEKD 16
- #define SAMEKS 32
- #define SAMEKT 64
- /* for image type */
- #define COLOR2 1
- #define COLOR16 4
- #define COLOR256 8
- #define HIGHCOLOR 16
- #define TRUECOLOR 24
- #define ALPHACOLOR 32
- /* Patch type */
- #define cTRIANGLE 't'
- #define cQUADRIC 'q'
- /* Texture mapping type */
- #define CLAMP_TEXTURE 0
- #define REPEAT_TEXTURE 1
- /* Data struct */
- typedef struct texture_2d
- {
- char fname[30];
- INT2U type; /* CLAMP_TEXTURE or REPEAT_TEXTEXTURE */
- } TEXTURE_2D;
- typedef struct point3d /* point in 3D */
- {
- FLOAT x, y, z; /* 3D coordinate */
- FLOAT r, g, b; /* color */
- FLOAT u, v; /* texture coordinate */
- } POINT3D;
- typedef struct surface /* surface */
- {
- INT4U pointn; /* point number */
- INT4U triangle; /* triangle number */
- INT4U quadric; /* quadrangle number */
- POINT3D *pointlist; /* points list */
- INT4U *patchlist; /* patches list(list of point No.)*/
- INT4U texId; /* texture index */
- } SURFACE;
- typedef struct object /* OBJECT */
- {
- INT4U SurfNum; /* surface number and list size*/
- SURFACE *surflist; /* surfaces list in the object*/
- } OBJECT;
- class CToolDoc;
- class CRenderView : public CView
- {
- protected: // create from serialization only
- CRenderView();
- DECLARE_DYNCREATE(CRenderView)
- // Attributes
- public:
- CToolDoc* GetDocument();
- // Operations
- public:
- // OpenGL specific
- BOOL SetWindowPixelFormat(HDC hDC);
- BOOL CreateViewGLContext(HDC hDC);
- void MoveEye(int type, GLfloat amount, int update);
- void InitTex( int TexIndex );
- void CloseTex();
- void LoadAllTexture();
- void FreeAllTexture();
- void freelist();
- void InitLookAt();
- void ReadData();
- unsigned char *OpenTexImage( INT2U TexIndex, INT2U *rslx, INT2U *rsly );
- void InitRenderWin();
- void Render(void);
- void write_rgb(char *filename);
- void CalcTexKd( int TexIndex, float *Kdr, float *Kdg, float *Kdb );
- void markDiscontinuous(short xlen, short ylen, float *depth, unsigned char **mark);
- void write_bmp();
- HGLRC m_hGLContext;
- int m_GLPixelIndex;
- unsigned char *ImageDatas[MAX_TEX];
- INT2U rslxs[MAX_TEX], rslys[MAX_TEX];
- int texnum;
- // Mouse
- BOOL m_LeftButtonDown;
- BOOL m_RightButtonDown;
- CPoint m_LeftDownPos;
- CPoint m_RightDownPos;
- HCURSOR m_CursorRotation;
- void InitGeometry(void);
- // Colors
- float m_ClearColorRed;
- float m_ClearColorGreen;
- float m_ClearColorBlue;
- // Overrides
- // ClassWizard generated virtual function overrides
- //{{AFX_VIRTUAL(CRenderView)
- 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:
- virtual ~CRenderView();
- #ifdef _DEBUG
- virtual void AssertValid() const;
- virtual void Dump(CDumpContext& dc) const;
- #endif
- protected:
- // Generated message map functions
- protected:
- //{{AFX_MSG(CRenderView)
- afx_msg void OnDestroy();
- afx_msg void OnSize(UINT nType, int cx, int cy);
- afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
- afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
- afx_msg void OnMouseMove(UINT nFlags, CPoint point);
- afx_msg void OnPaint();
- afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
- //}}AFX_MSG
- DECLARE_MESSAGE_MAP()
- };
- #ifndef _DEBUG // debug version in RenderView.cpp
- inline CToolDoc* CRenderView::GetDocument()
- { return (CToolDoc*)m_pDocument; }
- #endif
- #endif