import sys
import math
from PyQt5.QtWidgets import QApplication, QMainWindow, QOpenGLWidget
from PyQt5.QtCore import Qt
from OpenGL.GL import *
from OpenGL.GLU import *
from PyQt5.QtCore import QPoint
from PyQt5.QtGui import QMouseEvent
from OpenGL.GL import *
from OpenGL.GLU import *
class OpenGLWidget(QOpenGLWidget):
def __init__(self, parent=None):
super(OpenGLWidget, self).__init__(parent)
self.lastPos = QPoint()
self.translation = [0.0, 0.0, -5.0] # X, Y, and initial Z
self.zoom = 1.0
self.xRot = 0
self.yRot = 0
self.zRot = 0
def initializeGL(self):
glClearColor(0.8, 0.8, 0.8, 1.0)# 设置清屏颜色为灰色
glDisable(GL_LIGHTING) # 禁用光照
glEnable(GL_DEPTH_TEST) # 启用深度测试,以正确渲染3D空间中的对象
glEnable(GL_LIGHT0)
# glEnable(GL_LIGHTING)
glEnable(GL_COLOR_MATERIAL)
glColorMaterial(GL_FRONT_AND_BA
pyqt opengl 旋转平移缩放
最新推荐文章于 2024-06-04 02:56:38 发布