update: 2012/04/27
A. 說明:
在繼續學習 OpenGL ES 前, 想先對 OpenGL 多瞭解一些, 這裡的學習記錄,
可能會多次的更新與修正, 僅供參考.
------------------------------------------------------------------------------------------
B. 環境:
1. MacBook Pro (13-inch, Mid 2009)
2. Mac OS X 10.7.3
3. Xcode 4.3.2
4. 檢測目前的環境:
OpenGL Extensions Viewer
說明: 可以看到目前這台電腦支援的 OpenGL 版本為:
完全支援: 1.1 ~ 2.1
部分支援: 3.0 ~ 3.3
全不支援: 4.0 ~ 4.2
------------------------------------------------------------------------------------------
完全支援: 1.1 ~ 2.1
部分支援: 3.0 ~ 3.3
全不支援: 4.0 ~ 4.2
------------------------------------------------------------------------------------------
C. 新增專案:
1. Xcode > File > New > Project... > Mac OS X > Application >
Command Line Tool > Next
Product Name: OpenGLStart
Company Identifier: com.blogspot Type: C++
Use Automatic Reference Counting: checked
> Next > Create
2. 新增 Framework:
OpenGL
- OpenGL is the premier environment for developing portable,
interactive 2D and 3D graphics applications.
GLUT
- OpenGL Utility Toolkit- OpenGL is the premier environment for developing portable,
interactive 2D and 3D graphics applications.
GLUT
------------------------------------------------------------------------------------------
//This is just for basic io, you really DON'T need it
//#include <iostream>
//@add
#include <OpenGL/OpenGL.h> // OpenGL Library
#include <GLUT/GLUT.h> // GLUT Library, will make you life easier
//@add
void display()
{
// Clear the buffer
glClear(GL_COLOR_BUFFER_BIT);
// Let us begin drawing some points
glBegin(GL_POLYGON);
// Specify the points
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
// Ok we are done specifying points
glEnd();
// Write this out to the screen
glFlush();
}
//int main(int argc, const char * argv[])
//@update: just remove "const"
int main(int argc, char * argv[])
{
// insert code here...
//std::cout << "Hello, World!\n";
//@add for OpenGL
//
// Init glut
glutInit(&argc, argv);
// Name the window and create it
//
// default position: upper-left corner
// default size: 300 x 300 pixels
glutCreateWindow("Hello OpenGL");
// Set the callback function, will be called as needed
glutDisplayFunc(display);
// Start the main loop running,
// nothing after this will execute for all eternity (right now)
glutMainLoop();
//@ will not be executed (update: 2012/04/26)
//return 0;
}
------------------------------------------------------------------------------------------
E. 編譯並執行:
F. 備註:
1. MeshLab 軟體.
可用來讀取與編輯鬆散的 3D 三角形面的網狀模型.
(unstructured 3D triangular meshes)
p.s. 可以從 The Stanford 3D Scanning Repository 下載 3D 模型檔.
(bunny\reconstruction\bun_zipper.ply)
看看可愛的 Bunny ~
看看可愛的 Bunny ~
------------------------------------------------------------------------------------------
2. Nate Robins - OpenGL - Tutors
a. 下載:
Tutors source code package (tutors-src.zip 920KB)
b. 解壓縮後, 開啓 tutors.xcodeproj
將右上方的 "active scheme" 選為 shapes 或 lightmaterial, 然後執行.
shapes:
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。