当前位置:首页 > Windows程序 > 正文

opengl 在winCE系统的使用

2021-03-16 Windows程序

WINCE系统上开发OpenGL程序需具备以下条件:

1. 处理器的支持,嵌入式处理器需支持3D加速渲染(测试使用的是Telichips 8901);

2. WINCE内核的支持,定制内核时需添加OpenGL ES相关组件。

以下是具体的参考代码:

[cpp]  

/******************************************************************** 

filename:   WinceOpenGLDemo.cpp 

created:    2011-01-05 

author:     firehood 

purpose:    利用OpenGL ES实现了绘制立方体和纹理效果 

*********************************************************************/  

  

// WinceOpenGLDemo.cpp : 定义应用程序的入口点。  

//  

  

#include "stdafx.h"  

#include "WinceOpenGLDemo.h"  

#include <windows.h>  

#include <commctrl.h>  

#include "ImgLoader.h"  

// OpenGL ES Includes     

#include <GLES/gl.h>  

#include <GLES/glext.h>  

#include <EGL/egl.h>  

#include <EGL/eglext.h>  

  

// OpenGL lib  

#pragma comment(lib, "OpenGlLib\\libGLESv1_CM.lib")     

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

  

// 全局变量:  

HINSTANCE   g_hInst;            // 当前实例  

TCHAR       szAppName[] = L"OpenGLES";        /*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};    

  

// 立方体定点坐标  

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  

};    

  

// 各个面纹理坐标  

GLshort texCoords[] = {    

    0,0,1,0,1,1,0,1,        

    0,0,1,0,1,1,0,1,       

    0,0,1,0,1,1,0,1,       

    0,0,1,0,1,1,0,1,       

    0,0,1,0,1,1,0,1,       

    0,0,1,0,1,1,0,1,       

};    

  

// 三角形索引数据  

GLbyte indices1[] = {    

    0,1,3,2,    

    0,0,0,0,    

    0,0,0,0,    

    0,0,0,0,    

    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,    

    0,0,0,0,    

    0,0,0,0   

};   

GLbyte indices3[] = {    

    0,0,0,0,    

    0,0,0,0,    

    8,9,11,10,    

    0,0,0,0,    

    0,0,0,0,    

    0,0,0,0   

};    

GLbyte indices4[] = {    

    0,0,0,0,    

    0,0,0,0,    

    0,0,0,0,    

    12,13,15,14,    

    0,0,0,0,    

    0,0,0,0  

};    

GLbyte indices5[] = {    

    0,0,0,0,    

    0,0,0,0,    

    0,0,0,0,    

    0,0,0,0,    

    16,17,19,18,    

    0,0,0,0  

};    

GLbyte indices6[] = {    

    0,0,0,0,    

    0,0,0,0,    

    0,0,0,0,    

    0,0,0,0,    

    0,0,0,0,    

    20,21,23,22  

};  

  

// 此代码模块中包含的函数的前向声明:  

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/61881.html