Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # from PyQt5.QtWidgets import *
- # from PyQt5.QtGui import *
- # from PyQt5.QtCore import *
- # from PyQt5.uic import *
- #
- # from OpenGL.GL import *
- # from OpenGL.GLU import *
- # from OpenGL.GLUT import *
- # from OpenGL.GLUT.freeglut import *
- import OpenGL.GL as gl
- import OpenGL.GLU as glu
- import OpenGL.GLUT as glut
- from PyQt5 import QtWidgets as qWidget
- from PyQt5 import QtGui as qGui
- from PyQt5 import QtCore as qCore
- from PyQt5 import uic
- import sys
- import os
- class mainWindow(qWidget.QMainWindow):
- """Main window class."""
- def __init__(self, *args):
- """Init."""
- super(mainWindow, self).__init__(*args)
- ui = os.path.join(os.path.dirname(__file__), 'test.ui')
- uic.loadUi(ui, self)
- def setupUI(self):
- print("\033[1;101m SETU6P UI \033[0m")
- self.windowsHeight = self.openGLWidget.height()
- self.windowsWidth = self.openGLWidget.width()
- self.openGLWidget.initializeGL()
- self.openGLWidget.resizeGL(self.windowsWidth, self.windowsHeight)
- self.openGLWidget.paintGL = self.paintGL
- self.openGLWidget.initializeGL = self.initializeGL
- def paintGL(self):
- self.loadScene()
- glut.glutWireSphere(2, 13, 13)
- def initializeGL(self):
- print("\033[4;30;102m INITIALIZE GL \033[0m")
- gl.glEnable(gl.GL_BLEND)
- gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
- gl.glEnable(gl.GL_DEPTH_TEST)
- def loadScene(self):
- gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT)
- gl.glMatrixMode(gl.GL_PROJECTION)
- gl.glLoadIdentity()
- x, y, width, height = gl.glGetDoublev(gl.GL_VIEWPORT)
- glu.gluPerspective(
- 45, # field of view in degrees
- width / float(height or 1), # aspect ratio
- .25, # near clipping plane
- 200, # far clipping plane
- )
- gl.glMatrixMode(gl.GL_MODELVIEW)
- gl.glLoadIdentity()
- glu.gluLookAt(12, 12, 12, 0, 0, 0, 0, 1, 0)
- app = qWidget.QApplication(sys.argv)
- window = mainWindow()
- window.setupUI()
- window.show()
- sys.exit(app.exec_())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement