Developed an OpenGL program based on the VC ++ 6.0 dialog box, which contains all OPENGL learning content, from projection, 3D transformation, to BERZER, BSPLINE, semi-axis, and one-dimensional texture, very suitable for beginners. please mail mgamegame@126.com if you have any questions.
Body
1. Create a dialog box-based project named OpenGLVCd;
2. Convert gl. h, glu. h, glut. h, opengl32.lib, glu32.lib, and glu32.lib
Copy opengl32.dll, glu32.dll, and glu32.dll to the project directory, and add the gl. h, glu. h, and glut. h files to the project;
3. "Project-settings-link": link opengl32.lib, glu32.lib, and glu32.lib to the project;
4. Create a common class such
Class COpenGLAdd {......};
5. Add # include "gl. h"; # include "glu. h"; # include "glut. h" to the OpenGLAdd. h file header of the class ";
6. Add the italics in OpenGLVCdDlg. h.
# Include "OpenGLAdd. h" Class COpenGLAdd;//////////////////////////////////////// ///////////////////////////////////// // COpenGLVCdDlg dialog Class COpenGLVCdDlg: public CDialog { // Construction Public: COpenGLVCdDlg (CWnd * pParent = NULL); // standard constructor COpenGLAdd * gg ;...... |
7. add italics to OpenGLVCdDlg. cpp.
BOOL COpenGLVCdDlg: OnInitDialog () { ........ SetIcon (m_hIcon, FALSE); // Set small icon// TODO: Add extra initialization here Gg = new COpenGLAdd ;////////// Gg-> initial (this );////////// Return TRUE; // return TRUE unless you set the focus to a control } Void COpenGLVCdDlg: OnPaint () { If (IsIconic ()) { CPaintDC dc (this); // device context for painting ....... Dc. DrawIcon (x, y, m_hIcon ); } Else { Gg-> draw ();/////////// CDialog: OnPaint (); } } COpenGLVCdDlg: OnKeyDown () // used for moving, rotating, and scaling scenes COpenGLVCdDlg: OnLButtonDown () // select the coordinate origin COpenGLVCdDlg: OnSize () // adapt the OpenGl window to the dialog box window |
Programs in the dimage folder are used to generate 128,256,512 million texture files;
Usage:
1. Use image processing software such as drawing and Photoshop for editing. The size must be 128X128,256X256,512X512;
Save as bmp file format;
2. Right-click Bitmap --> import to import the Bitmap file;
3. Modify the ID of the imported bitmap in the file Dimage. cpp, for example, IDB_BITMAP3;
Void CDimageDlg: OnButton1 () { CDC * pdc = GetDC (); CBitmap bmp; Bmp. LoadBitmap (IDB_BITMAP3 ); BITMAP bit; Bmp. GetBitmap (& bit ); Cdc bmp dc; Bmp dc. CreateCompatibleDC (pdc ); CBitmap * poldbm = bmp DC. SelectObject (& bmp );.... |
Run the program, enter the file name and select the size, and then click "output" to upload the. txt texture file;