网站导航免费论文 原创论文 论文搜索 原创论文 网学软件 学术大家 资料中心 会员中心 问题解答 原创论文 论文素材 设计下载 最新论文 下载排行 论文上传 在线投稿 联系我们
返回网学首页
网学联系
最新论文 推荐专题 热门论文 素材专题
当前位置: 网学 > 编程文档 > VC++ > 正文
制作一个基于MFC对话框的OpenGL类
来源:Http://myeducs.cn 联系QQ:点击这里给我发消息 作者: 用户投稿 来源: 网络 发布时间: 12/10/15
下载{$ArticleTitle}原创论文样式
ed,CDS_RESET); // change it to the saved settings
   } else {
    ChangeDisplaySettings(NULL,CDS_RESET);
   }

   ShowCursor(TRUE); // Show Mouse Pointer
  }

  if ( m_hRC ) { // Do We Have A Rendering Context?
   if ( !wglMakeCurrent ( NULL, NULL ) ) { // Are We Able To Release The DC And RC Contexts?
    TRACE ( "Release Of DC And RC Failed." );
   }

   if ( !wglDeleteContext ( m_hRC ) ) { // Are We Able To Delete The RC?
    TRACE ( "Release Rendering Context Failed." );
   }
   m_hRC = NULL; // Set RC To NULL
  }

  if ( m_hDC && !::ReleaseDC ( m_hWnd, m_hDC ) ) { // Are We Able To Release The DC
   TRACE ( "Release Device Context Failed." );
   m_hDC = NULL; // Set DC To NULL
  }

  if ( m_hWnd && !::DestroyWindow ( m_hWnd ) ) { // Are We Able To Destroy The Window?
   TRACE( "Could Not Release m_hWnd." );
   m_hWnd = NULL; // Set m_hWnd To NULL
  }
 }

 int COpenGL::InitGL()
 {
  glShadeModel(GL_SMOOTH); // Enable Smooth Shading
  glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
  glClearDepth(1.0f); // Depth Buffer Setup
  glEnable(GL_DEPTH_TEST); // Enables Depth Testing
  glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
  glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
  glEnable(GL_TEXTURE_2D); // Enable Texture Mapping

  return TRUE; // Initialization Went OK
 }

 void COpenGL::RenderGLScene()
 {
  if(!m_bInit) return;

  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
  glLoadIdentity();

  // EXAMPLE OPENGL CODE START ////////////////////////////////////////////////////////
  //////////////////////////////////////////////////////////////////////////////
  static GLfloat xrot; // X Rotation
  static GLfloat yrot; // Y Rotation
  static GLfloat zrot; // Z Rotation

  glPushMatrix(); // Push Matrix Onto Stack (Copy The Current Matrix)
  glLoadIdentity(); // Reset The Current Modelview Matrix
  glTranslatef(0.0f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0

  glRotatef(xrot,1.0f,0.0f,0.0f);
  glRotatef(yrot,0.0f,1.0f,0.0f);
  glRotatef(zrot,0.0f,0.0f,1.0f);

  glBegin(GL_QUADS);
  // Front Face
  glColor3f(1.0f,0.0f,0.0f);glVertex3f(-1.0f, -1.0f, 1.0f);
  glColor3f(0.0f,1.0f,0.0f);glVertex3f( 1.0f, -1.0f, 1.0f);
  glColor3f(0.0f,1.0f,0.0f);glVertex3f( 1.0f, 1.0f, 1.0f);
  glColor3f(0.0f,0.0f,1.0f);glVertex3f(-1.0f, 1.0f, 1.0f);
  // Back Face
  glColor3f(1.0f,0.0f,0.0f);glVertex3f(-1.0f, -1.0f, -1.0f);
  glColor3f(0.0f,1.0f,0.0f);glVertex3f(-1.0f, 1.0f, -1.0f);
  glColor3f(0.0f,1.0f,0.0f);glVertex3f( 1.0f, 1.0f, -1.0f);
  glColor3f(0.0f,0.0f,1.0f);glVertex3f( 1.0f, -1.0f, -1.0f);
  // Top Face
  glColor3f(0.0f,1.0f,0.0f);glVertex3f(-1.0f, 1.0f, -1.0f);
  glColor3f(0.0f,0.0f,1.0f);glVertex3f(-1.0f, 1.0f, 1.0f);
  glColor3f(0.0f,1.0f,0.0f);glVertex3f( 1.0f, 1.0f, 1.0f);
  glColor3f(0.0f,1.0f,0.0f);glV

网学推荐

免费论文

原创论文

浏览:
设为首页 | 加入收藏 | 论文首页 | 论文专题 | 设计下载 | 网学软件 | 论文模板 | 论文资源 | 程序设计 | 关于网学 | 站内搜索 | 网学留言 | 友情链接 | 资料中心
版权所有 QQ:3710167 邮箱:3710167@qq.com 网学网 [Myeducs.cn] 您电脑的分辨率是 像素
Copyright 2008-2015 myeducs.Cn www.myeducs.Cn All Rights Reserved
湘ICP备09003080号