<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>

新聞中心

EEPW首頁(yè) > 嵌入式系統 > 設計應用 > WinCE OpenGL繪制立方體和紋理貼圖

WinCE OpenGL繪制立方體和紋理貼圖

作者: 時(shí)間:2016-10-08 來(lái)源:網(wǎng)絡(luò ) 收藏

最近工作之余,開(kāi)始學(xué)習OpenGL, 想到WINCE也是支持OpenGL的,只不過(guò)是嵌入式的OpenGL ES.于是嘗試寫(xiě)了一個(gè)WINCE下的OpenGL測試程序,實(shí)現了繪制立方體和紋理。效果圖如下:

本文引用地址:http://dyxdggzs.com/article/201610/305941.htm

需要注意的是,WINCE系統上開(kāi)發(fā)OpenGL程序需具備以下條件:

1. 處理器的支持,嵌入式處理器需支持3D加速渲染。

2. WINCE內核的支持,定制內核時(shí)需添加OpenGL ES相關(guān)組件。

以下是具體的參考代碼:

view plain /******************************************************************** filename: WinceOpenGLDemo.cpp created: 2011-01-05 author: firehood purpose: 利用OpenGL ES實(shí)現了繪制立方體和紋理效果*********************************************************************/

// WinceOpenGLDemo.cpp : 定義應用程序的入口點(diǎn)。

//

#include stdafx.h #include WinceOpenGLDemo.h #include #include #include ImgLoader.h // OpenGL ES Includes #include #include #include #include

// OpenGL lib #pragma comment(lib, OpenGlLib\libGLESv1_CM.lib)

#pragma comment(lib, OpenGlLib\libEGL.lib)

// 全局變量:HINSTANCE g_hInst; // 當前實(shí)例TCHAR szAppName[] = LOpenGLES; /*The application name and the window caption*/ CImgLoader g_Image;// OpenGL variables EGLDisplay glesDisplay; // EGL display EGLSurface glesSurface; // EGL rendering surface EGLContext glesContext; // EGL rendering context

GLuint texture[6] = {0};

// 立方體定點(diǎn)坐標GLshort vertices[] = { -1,-1,1,1,-1,1,1,1,1,-1,1,1,

-1,-1,-1,-1,1,-1,1,1,-1,1,-1,-1,

-1,1,-1,-1,1,1,1,1,1,1,1,-1,

-1,-1,-1,1,-1,-1,1,-1,1,-1,-1,1,

1,-1,-1,1,1,-1,1,1,1,1,-1,1,

-1,-1,-1,-1,-1,1,-1,1,1,-1,1,-1 };

// 各個(gè)面紋理坐標GLshort texCoords[] = { 0,0,1,0,1,1,0,1,};

// 三角形索引數據GLbyte indices1[] = { 0,1,3,2,0,0,0,0,0,0,0,0 };GLbyte indices2[] = { 0,0,0,0,4,5,7,6,0,0,0,0,0,0,0,0 };GLbyte indices3[] = { 0,0,0,0,8,9,11,10,0,0,0,0,0,0,0,0 };GLbyte indices4[] = { 0,0,0,0,12,13,15,14,0,0,0,0,0,0,0,0 };GLbyte indices5[] = { 0,0,0,0,16,17,19,18,0,0,0,0 };GLbyte indices6[] = { 0,0,0,0,20,21,23,22 };

// 此代碼模塊中包含的函數的前向聲明:ATOM MyRegisterClass(HINSTANCE, LPTSTR);BOOL InitInstance(HINSTANCE, int);LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

BOOL InitOGLES(HWND hWnd);void CreateSurface();BOOL LoadTexture(LPCTSTR lpFileName,GLuint *id);void Render();void Clean();

int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPTSTR lpCmdLine,int nCmdShow)

{ MSG msg;

// 執行應用程序初始化:if (!InitInstance(hInstance, nCmdShow))

{ return FALSE;}

BOOL done = FALSE;// 主消息循環(huán):while(!done)

{ if(PeekMessage(msg,NULL,0,0,PM_REMOVE))

{ if(msg.message==WM_QUIT)

done = TRUE;else { TranslateMessage(msg);DispatchMessage(msg);} else { Render();};}

return (int) msg.wParam;}

// // 函數: MyRegisterClass()

// // 目的: 注冊窗口類(lèi)。

// // 注釋?zhuān)?/ ATOM MyRegisterClass(HINSTANCE hInstance, LPTSTR szWindowClass)

{ WNDCLASS wc;

wc.style = CS_HREDRAW | CS_VREDRAW;wc.lpfnWndProc = WndProc;wc.cbClsExtra = 0;wc.cbWndExtra = 0;wc.hInstance = hInstance;wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WINCEOPENGLDEMO));wc.hCursor = 0;wc.hbrBackground = (HBRUSH) GetStockObject(NULL_BRUSH);wc.lpszMenuName = 0;wc.lpszClassName = szWindowClass;

return RegisterClass(wc);}

// // 函數: InitInstance(HINSTANCE, int)

// // 目的: 保存實(shí)例句柄并創(chuàng )建主窗口// // 注釋?zhuān)?/ // 在此函數中,我們在全局變量中保存實(shí)例句柄并// 創(chuàng )建和顯示主程序窗口。

// BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)

{ HWND hWnd;

g_hInst = hInstance; // 將實(shí)例句柄存儲在全局變量中

if (!MyRegisterClass(hInstance, szAppName))

{ return FALSE;}

hWnd = CreateWindow(szAppName,WS_VISIBLE,0,::GetSystemMetrics(SM_CXSCREEN),::GetSystemMetrics(SM_CYSCREEN),NULL,hInstance,NULL);

if (!hWnd)

{ return FALSE;}

if(!InitOGLES(hWnd))

{ printf(InitOGLES failedn);return FALSE;} CreateSurface();

ShowWindow(hWnd, SW_SHOW);UpdateWindow(hWnd);

return TRUE;}

// // 函數: WndProc(HWND, UINT, WPARAM, LPARAM)

// // 目的: 處理主窗口的消息。

// // WM_COMMAND - 處理應用程序菜單// WM_PAINT - 繪制主窗口// WM_DESTROY - 發(fā)送退出消息并返回// LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)


上一頁(yè) 1 2 3 下一頁(yè)

關(guān)鍵詞:

評論


相關(guān)推薦

技術(shù)專(zhuān)區

關(guān)閉
国产精品自在自线亚洲|国产精品无圣光一区二区|国产日产欧洲无码视频|久久久一本精品99久久K精品66|欧美人与动牲交片免费播放
<dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><small id="yhprb"></small><dfn id="yhprb"></dfn><small id="yhprb"><delect id="yhprb"></delect></small><small id="yhprb"></small><small id="yhprb"></small> <delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"></dfn><dfn id="yhprb"></dfn><s id="yhprb"><noframes id="yhprb"><small id="yhprb"><dfn id="yhprb"></dfn></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><small id="yhprb"></small><dfn id="yhprb"><delect id="yhprb"></delect></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn> <small id="yhprb"></small><delect id="yhprb"><strike id="yhprb"></strike></delect><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn><dfn id="yhprb"><s id="yhprb"><strike id="yhprb"></strike></s></dfn><dfn id="yhprb"><s id="yhprb"></s></dfn>