在vs2010裡使用opengl

2021-09-08 21:46:40 字數 1219 閱讀 1113

確切的說opengl已經包括在vc2010裡面了、所以無需任何的安裝、只要輸入相應的庫檔案和標頭檔案便可以了、下面是個簡單的示例、

使用vc2010新建乙個win32程式、下一步裡選擇新建空工程專案、然後再在source files裡新增乙個cpp檔案、輸入以下的內容、

前兩行是引入opengl的兩個庫檔案、然後是引入兩個gl的標頭檔案

#pragma comment(lib, "opengl32.lib")

#pragma comment(lib, "glu32.lib")#include

#include

#include

hwnd hwnd;

hdc hdc;

hglrc hrc;

void

game_init();

void

game_main();

void

game_shutdown();

//set up pixel format for graphics initialization

void

setuppixelformat()

//initialize opengl graphics

void

initgraphics()

//resize graphics to fit window

void

resizegraphics()

//draw frame

void

drawgraphics()

//handle window events and messages

long winapi mainwndproc (hwnd hwnd, uint umsg, wparam wparam, lparam lparam)

return1;

}int winapi winmain (hinstance hinstance, hinstance hprevinstance, lpstr lpcmdline, int

ncmdshow)

drawgraphics();

}wgldeletecontext(hrc);

releasedc(hwnd, hdc);

}

執行**後將生成以下的圖案

在vs2010裡使用opengl

確切的說opengl已經包括在vc2010裡面了 所以無需任何的安裝 只要輸入相應的庫檔案和標頭檔案便可以了 下面是個簡單的示例 使用vc2010新建乙個win32程式 下一步裡選擇新建空工程專案 然後再在source files裡新增乙個cpp檔案 輸入以下的內容 前兩行是引入opengl的兩個庫...

VS2010裡函式列舉

一 cout函式 說明 呼叫該函式必須申明標頭檔案 include 同時宣告後面必須使用 using namespace std 正確書寫為 include using namespace std 該函式表示輸出,功能和printf一樣,但cout不能用於c語言中 使用說明 1 必須配合 使用,如 ...

Crystal Report在VS2010中的使用

vs2010不在像vs2008及以前版本那樣支援crystal report了,不過sap公司還是很給勁的,隨即發布了cr for2010的免費開放版。雖然如此,但剛上手使用的朋友們可能還是很費周折。下簡述使用。上述只適用於執行他人編寫的有關報表的專案,做為開發者則還需進行其他工作。我們使用crys...