⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nehewidget.cpp

📁 qt教学例子1
💻 CPP
字号:
/*    Qt OpenGL Tutorial - Lesson 01    nehewidget.cpp    v 1.00    2002/12/05    Copyright (C) 2002 Cavendish                       cavendish@qiliang.net                       http://www.qiliang.net/nehe_qt    This program is free software; you can redistribute it and/or modify    it under the terms of the GNU General Public License as published by    the Free Software Foundation; either version 2 of the License, or    (at your option) any later version.*/#include "nehewidget.h"NeHeWidget::NeHeWidget( QWidget* parent, const char* name, bool fs )    : QGLWidget( parent, name ){  fullscreen = fs;  setGeometry( 0, 0, 640, 480 );  setCaption( "NeHe's OpenGL Framework" );  if ( fullscreen )    showFullScreen();}NeHeWidget::~NeHeWidget(){}void NeHeWidget::initializeGL(){  glShadeModel( GL_SMOOTH );  glClearColor( 0.0, 0.0, 0.0, 0.0 );  glClearDepth( 1.0 );  glEnable( GL_DEPTH_TEST );  glDepthFunc( GL_LEQUAL );  glHint( GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST );}void NeHeWidget::paintGL(){  glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );  glLoadIdentity();}void NeHeWidget::resizeGL( int width, int height ){  if ( height == 0 )  {    height = 1;  }  glViewport( 0, 0, (GLint)width, (GLint)height );  glMatrixMode( GL_PROJECTION );  glLoadIdentity();  gluPerspective( 45.0, (GLfloat)width/(GLfloat)height, 0.1, 100.0 );  glMatrixMode( GL_MODELVIEW );  glLoadIdentity();}void NeHeWidget::keyPressEvent( QKeyEvent *e ){  switch ( e->key() )  {  case Qt::Key_F2:    fullscreen = !fullscreen;    if ( fullscreen )    {      showFullScreen();    }    else    {      showNormal();      setGeometry( 0, 0, 640, 480 );    }    updateGL();    break;  case Qt::Key_Escape:    close();  }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -