亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? render.cpp

?? wince 3d tutorial, it has various examples
?? CPP
字號(hào):
#include <stdio.h>
#include "render.h" //We need the defines and prototypes of there

EGLDisplay glesDisplay;  // EGL display
EGLSurface glesSurface;	 // EGL rendering surface
EGLContext glesContext;	 // EGL rendering context

//Texture handles
GLuint texture1 = 0; 
GLuint texture2 = 0;

FixedMesh *mesh = NULL;

//Variables declared in main.cpp, but used here too
extern HWND hWnd; // A handle to the window we will create
extern HDC hDC;   // A handle to the device context of the window. Needed to 

bool InitOGLES()
{  
  EGLConfig configs[10];
  EGLint matchingConfigs;	

  /*configAttribs is a integers list that holds the desired format of 
   our framebuffer. We will ask for a framebuffer with 24 bits of 
   color and 16 bits of z-buffer. We also ask for a window buffer, not 
   a pbuffer or pixmap buffer*/	
  const EGLint configAttribs[] =
  {
      EGL_RED_SIZE,       8,
      EGL_GREEN_SIZE,     8,
      EGL_BLUE_SIZE,      8,
      EGL_ALPHA_SIZE,     EGL_DONT_CARE,
      EGL_DEPTH_SIZE,     16,
      EGL_STENCIL_SIZE,   EGL_DONT_CARE,
      EGL_SURFACE_TYPE,   EGL_WINDOW_BIT,
      EGL_NONE,           EGL_NONE
  };
  
  hDC = GetWindowDC(hWnd);
  glesDisplay = eglGetDisplay(hDC);	 //Ask for an available display

  //Display initialization (we don't care about the OGLES version numbers)
  if(!eglInitialize(glesDisplay, NULL, NULL)) 
    return false;
	
  /*Ask for the framebuffer confiburation that best fits our 
  parameters. At most, we want 10 configurations*/
  if(!eglChooseConfig(glesDisplay, configAttribs, &configs[0], 10,  &matchingConfigs)) 
   return false;
	
  //If there isn't any configuration enough good
  if (matchingConfigs < 1)  return false;	  

  /*eglCreateWindowSurface creates an onscreen EGLSurface and returns 
  a handle  to it. Any EGL rendering context created with a 
  compatible EGLConfig can be used to render into this surface.*/
  glesSurface = eglCreateWindowSurface(glesDisplay, configs[0], hWnd, configAttribs);	
  if(!glesSurface) return false;
  
  // Let's create our rendering context
  glesContext=eglCreateContext(glesDisplay,configs[0],0,configAttribs);

  if(!glesContext) return false;

  //Now we will activate the context for rendering	
  eglMakeCurrent(glesDisplay, glesSurface, glesSurface, glesContext); 
    
  /*Remember: because we are programming for a mobile device, we cant 
  use any of the OpenGL ES functions that finish in 'f', we must use 
  the fixed point version (they finish in 'x'*/
  glClearColorx(FixedFromFloat(0.5f), FixedFromFloat(0.5f), FixedFromFloat(0.5f), ONE);
  //Do not want to see smoothed colors, only a plain color for face
  glShadeModel(GL_SMOOTH);  
  //Enable the depth test in order to see the cube correctly
  glEnable(GL_DEPTH_TEST);
  
  /*Taking care of specifying correctly the winding order of the 
  vertices (counter clock wise order), we can cull all back faces.
  This is probably one of the best optimizations we could do,
  because, by this way, we avoid a lot of computations that wont be 
  reflected in the screen. Use  glEnable(GL_CULL_FACE) to do the work*/
  glEnable(GL_CULL_FACE);

  /*In order to set a viewport that fits entirely our window, we need 
  to know the window dimensions. They could be obtained through the   
  WinCE call GetWindowRect, using our window handle*/
  RECT r;
  GetWindowRect(hWnd, &r);  
  glViewport(r.left, r.top, r.right - r.left, r.bottom - r.top);		  
  SetPerspective();
  
  //Light Settings
  //Set a 50% grey diffuse component
  GLfixed diffuse[] = {FixedFromFloat(0.5f),FixedFromFloat(0.5f),FixedFromFloat(0.5f),ONE};
  glLightxv(GL_LIGHT0, GL_DIFFUSE, diffuse);	
  //Enable lighting computations
  glEnable(GL_LIGHTING);
  //Enable Light0 (switch on it)
  glEnable(GL_LIGHT0);


  //Fog settings
  //50% green fog
  GLfixed fogColor[] = { 0, FixedFromFloat(0.5f), 0, 0 }; 
	glFogxv(GL_FOG_COLOR, fogColor);
  /*We chosen a linear mode for fog. Fog will begin to show its effects at 20 units
    of distance from the camera, all the highest fog density will be reached at 50 units*/
	glFogx(GL_FOG_MODE, GL_LINEAR);
	glFogx(GL_FOG_START, FixedFromInt(20));
  glFogx(GL_FOG_END,   FixedFromInt(50));
    
  //Load our scene file
  mesh = LoadMeshFromFile("./resources/scene.gsd");
  return mesh?true:false;
  
}
//----------------------------------------------------------------------------
void Render()
{
  
  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);  

  glLoadIdentity();
    
  static int rotation = 0;
  /*"camera" setup to have a good point of view of the scene, also we will perform a rotation
     on the mesh*/
  glTranslatex(0, FixedFromInt(-5), FixedFromInt(-40));  
  glRotatex(FixedFromInt(20),ONE,0,0);
  glRotatex(FixedFromInt(rotation++),0,ONE,0);
    
  
  //With x and z we compute the points of a circle, with a radius = 30, and the velocity = LightRotation
  static float LightRotation = 0;    
  float x = 0,z = 0;
  LightRotation +=0.2f;  
  x = 30 * (float)sin(LightRotation); //we have to use floats, because we do not 
  z = 30 * (float)cos(LightRotation); //have a fixed point version of sin and cos
  GLfixed lightPosition[] = { 0, FixedFromInt(10), 0, FixedFromInt(1) };
  lightPosition[0] = FixedFromFloat(x);  lightPosition[2] = FixedFromFloat(z); 
  //Setup of Light0 position
	glLightxv(GL_LIGHT0, GL_POSITION, lightPosition);

  glEnableClientState(GL_VERTEX_ARRAY);
  glVertexPointer(3, GL_FIXED, 0, mesh->Geometry);
  
  //Normals are needed for the lighting computations
  glEnableClientState(GL_NORMAL_ARRAY);
  glNormalPointer(GL_FIXED, 0, mesh->Normals);
   
  glDrawElements(GL_TRIANGLES,mesh->indexCounter,GL_UNSIGNED_SHORT,mesh->Indices);
     
  glDisableClientState(GL_VERTEX_ARRAY);   	
  glDisableClientState(GL_NORMAL_ARRAY);   	
  
  eglSwapBuffers(glesDisplay, glesSurface);
}
//----------------------------------------------------------------------------
FixedMesh *LoadMeshFromFile(const char *filename)
{
  GSDHeader header;
  FILE *meshFile = fopen(filename,"rb");
  if(!meshFile)
    return NULL;

  /*The header holds a brief description of the file, the version number, and the number of meshes
    that are stored in the file. This type of files are thought for static meshes only*/
  fread(&header,sizeof(GSDHeader),1,meshFile); 

  //Check if there is at least one object
  if(header.numberOfSubObjects < 1)
    return NULL;

  GenericObjectData o;
  FixedMesh *mesh = new FixedMesh;

  // we only will use the first object, so we won't iterate over the others, if they exist
  fread(o.Name,sizeof(char)*128,1,meshFile); //read the object name
  fread(o.ParentName,sizeof(char)*128,1,meshFile); //Read the name of the parent object (useful for hierarchies)
  fread(&o.iC,sizeof(unsigned long),1,meshFile); //read the number of vertex indices
  fread(&o.vC,sizeof(unsigned long),1,meshFile); //read the number of vertices

  //allocate enough space for the indices and the GLshort version of them
  o.Indices = new unsigned int[o.iC];
  mesh->Indices = new GLshort[o.iC];
  fread(o.Indices,sizeof(unsigned int) * o.iC,1,meshFile); // read all indices

  //allocate enough space for the vertices and the GLfixed version of them
  o.Geometry = new float[o.vC * 3]; 
  mesh->Geometry = new GLfixed[o.vC * 3];
  fread(o.Geometry,o.vC * 3 * sizeof(float),1,meshFile); //read all vertices (1 vertex = 3 floats)

  //allocate enough space for the texture coordinates and the GLfixed version of them
  o.TexCoord = new float[o.vC * 2];
  mesh->TexCoord = new GLfixed[o.vC * 2];
  fread(o.TexCoord,o.vC * 2 * sizeof(float),1,meshFile);//read all texcoords (1 tex coord = 2 floats)
  
  //allocate enough space for the normals and the GLfixed version of them
  o.Normals= new float[o.vC * 3];
  mesh->Normals = new GLfixed[o.vC * 3];
  fread(o.Normals,o.vC * 3* sizeof(float),1,meshFile);//read all normals (1 normal = 3 floats)
  fclose(meshFile); //Do not need the file opened anymore

  // Convert data to optimized data types for OpenGL ES (GLfixed and GLshort)
  for(unsigned int i=0;i<o.vC * 3;i++)
  {
    mesh->Geometry[i]= FixedFromFloat(o.Geometry[i]);
    mesh->Normals[i] = FixedFromFloat(o.Normals[i]);
  }

  for(i=0;i<o.vC * 2;i++)
    mesh->TexCoord[i] = FixedFromFloat(o.TexCoord[i]);
  
  for(i=0;i<o.iC;i++)
    mesh->Indices[i] = (GLshort)o.Indices[i];

  mesh->indexCounter = (GLshort)o.iC;
  mesh->vertexCounter= (GLshort)o.vC;

  //delete original values, we will use only the optimized ones
  delete [] o.Indices;
  delete [] o.Geometry;
  delete [] o.Normals;
  delete [] o.TexCoord;
  
  return mesh;
}
//----------------------------------------------------------------------------
void Perspective (GLfloat fovy, GLfloat aspect, GLfloat zNear,  GLfloat zFar)
{
  GLfixed xmin, xmax, ymin, ymax, aspectFixed, znearFixed;     
  
  aspectFixed = FixedFromFloat(aspect);
  znearFixed = FixedFromFloat(zNear);

  ymax = MultiplyFixed(znearFixed, FixedFromFloat((GLfloat)tan(fovy * 3.1415962f / 360.0f)));  
  ymin = -ymax;

  xmin = MultiplyFixed(ymin, aspectFixed);
  xmax = MultiplyFixed(ymax, aspectFixed);  
  glFrustumx(xmin, xmax, ymin, ymax, znearFixed, FixedFromFloat(zFar));
}
//----------------------------------------------------------------------------
void SetPerspective()
{
  RECT r;
  GetWindowRect(hWnd, &r);    
  float ratio = (float)(r.right - r.left)/(r.bottom - r.top);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();        
  Perspective(45.0f,ratio,1.0f, 100.0f);
  glMatrixMode(GL_MODELVIEW);
}
//----------------------------------------------------------------------------
void Clean()
{
  if(glesDisplay)
  {
    eglMakeCurrent(glesDisplay, NULL, NULL, NULL);  
    if(glesContext) eglDestroyContext(glesDisplay, glesContext);
    if(glesSurface) eglDestroySurface(glesDisplay, glesSurface);
    eglTerminate(glesDisplay);
  }  

  //delete mesh data
  delete [] mesh->Geometry;
  delete [] mesh->Indices;
  delete [] mesh->Normals;
  delete [] mesh->TexCoord;
  delete mesh;
}
//----------------------------------------------------------------------------
//Functions called by WndProc when the user clicks the touch screen
void EnableFog()
{
  glEnable(GL_FOG);
}
//----------------------------------------------------------------------------
void DisableFog()
{
  glDisable(GL_FOG);
}

?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩日日摸| 久久在线观看免费| 蜜臀av性久久久久av蜜臀妖精| 欧美一二三区精品| 国产一区在线不卡| 中文字幕不卡在线| 欧美伊人久久久久久久久影院| 日韩高清欧美激情| 精品国产乱码久久久久久免费| 国产高清一区日本| 亚洲免费观看在线视频| 欧美日韩精品一区二区在线播放| 婷婷久久综合九色综合伊人色| 精品久久国产老人久久综合| 成人亚洲一区二区一| 悠悠色在线精品| 91精品国产一区二区人妖| 国产一区二区在线看| 亚洲欧洲精品一区二区三区不卡| 欧美性猛交xxxx乱大交退制版| 青青草91视频| 中文字幕第一区综合| 欧美日韩中文另类| 国产一区二区在线观看免费 | 欧美三级视频在线| 欧美激情自拍偷拍| 在线观看av不卡| 免费高清不卡av| 亚洲国产精品精华液2区45| 色综合久久88色综合天天6 | 午夜欧美视频在线观看| 久久久综合视频| 色94色欧美sute亚洲线路一久| 日韩精品一级二级 | 欧美三区在线观看| 国产在线精品一区在线观看麻豆| 中文字幕一区二区不卡| 欧美一级搡bbbb搡bbbb| 成人一区二区三区在线观看| 香蕉乱码成人久久天堂爱免费| 欧美精品一区二区久久婷婷| 91视频一区二区三区| 美女mm1313爽爽久久久蜜臀| 亚洲三级小视频| 欧美精品一区二区精品网| 91麻豆文化传媒在线观看| 美腿丝袜在线亚洲一区| 亚洲精品视频在线观看免费| 亚洲精品一区二区三区福利 | 综合自拍亚洲综合图不卡区| 日韩精品一区二区三区老鸭窝| 99re这里只有精品视频首页| 久久黄色级2电影| 伊人夜夜躁av伊人久久| 国产亚洲人成网站| 宅男噜噜噜66一区二区66| av成人免费在线| 国产一区二区三区四区在线观看| 一区二区三区欧美视频| 欧美激情一区不卡| 欧美大尺度电影在线| 欧美在线观看一二区| 成人美女在线观看| 韩国v欧美v日本v亚洲v| 日韩电影在线看| 亚洲综合一区在线| 中文字幕高清不卡| 精品国产91亚洲一区二区三区婷婷| 欧美中文字幕一区二区三区亚洲| 国产精品911| 极品少妇xxxx精品少妇偷拍| 天天影视色香欲综合网老头| 亚洲日本青草视频在线怡红院 | www日韩大片| 欧美一区二区成人| 99久久综合精品| 午夜精品福利久久久| 亚洲欧美区自拍先锋| 国产亚洲成av人在线观看导航 | 精品理论电影在线| 91精品蜜臀在线一区尤物| 日本大香伊一区二区三区| 成人app在线| 高清成人在线观看| 国产尤物一区二区在线| 久久精品国产久精国产爱| 日韩专区在线视频| 婷婷夜色潮精品综合在线| 亚洲国产成人精品视频| 亚洲国产日韩精品| 一区二区三区在线观看视频| 亚洲柠檬福利资源导航| 日韩美女久久久| 亚洲视频一区二区在线| 国产精品伦一区二区三级视频| 久久精品免视看| 久久久久9999亚洲精品| 久久久久免费观看| 久久久精品2019中文字幕之3| 精品电影一区二区三区| 亚洲精品一区二区精华| 精品国产sm最大网站| 精品对白一区国产伦| 精品国产乱码久久久久久1区2区 | 久久久久久夜精品精品免费| 欧美va在线播放| 日韩免费观看高清完整版 | 91久久精品网| 欧美系列在线观看| 欧美亚洲国产一区在线观看网站 | 7777精品伊人久久久大香线蕉超级流畅| 91久久一区二区| 欧美日韩中文国产| 777午夜精品免费视频| 7777精品伊人久久久大香线蕉 | 日本最新不卡在线| 亚洲日本va在线观看| 亚洲品质自拍视频| 一区二区欧美在线观看| 一区二区成人在线| 午夜av一区二区| 蜜桃一区二区三区在线| 韩国视频一区二区| 国产成人av影院| 91丨九色丨蝌蚪丨老版| 色吊一区二区三区| 欧美精品三级在线观看| 欧美mv日韩mv亚洲| 中文字幕乱码亚洲精品一区 | 午夜精品一区二区三区免费视频| 亚洲成人av一区二区三区| 日韩国产高清影视| 黄一区二区三区| 成人免费高清在线| 在线亚洲+欧美+日本专区| 欧美精品 日韩| 久久久久97国产精华液好用吗| 国产精品久久久久四虎| 亚洲在线观看免费视频| 蜜臀久久久99精品久久久久久| 韩国精品久久久| 91啦中文在线观看| 欧美一级理论片| 国产精品网站在线观看| 亚洲综合在线视频| 看片网站欧美日韩| 成人晚上爱看视频| 欧美日韩一二三区| 久久综合久色欧美综合狠狠| 中文字幕在线不卡| 日韩中文字幕亚洲一区二区va在线| 久久99精品一区二区三区三区| 99久久国产综合精品色伊| 欧美猛男超大videosgay| 久久综合久久综合亚洲| 一区二区三区中文字幕| 男人的天堂亚洲一区| 成人黄色一级视频| 91精品国产综合久久福利| 国产精品情趣视频| 日韩高清一级片| 99久久精品费精品国产一区二区| 欧美高清视频一二三区 | 午夜精品免费在线观看| 国产在线观看一区二区| 91精品福利在线| 欧美成人精精品一区二区频| 欧美成人伊人久久综合网| 最新久久zyz资源站| 日本aⅴ精品一区二区三区| 成人av免费观看| 欧美一区二区日韩一区二区| 国产精品国产三级国产a | 久久不见久久见中文字幕免费| 97久久超碰国产精品| 日韩精品最新网址| 亚洲啪啪综合av一区二区三区| 乱一区二区av| 欧美综合色免费| 国产欧美日韩三区| 调教+趴+乳夹+国产+精品| 99在线精品观看| 欧美大片日本大片免费观看| 一区二区在线免费| 国产盗摄一区二区三区| 91麻豆精品久久久久蜜臀| 国产精品久久久久毛片软件| 美女看a上一区| 欧美亚洲精品一区| 国产精品久久久久aaaa| 精品亚洲免费视频| 8x福利精品第一导航| 亚洲精品老司机| 国产不卡一区视频| 日韩久久久久久| 日韩综合在线视频| 欧美午夜一区二区| 亚洲视频在线一区观看| 国产乱淫av一区二区三区| 日韩一级完整毛片|