pyopengl

Why my texture is not showing PyOpenGL

情到浓时终转凉″ 提交于 2019-12-29 01:29:08
问题 I tried everything but still I don't get my error. I am trying to put a texture on my sphere object. """ Minimal texture on sphere demo This is demo for showing how to put image on sphere as texture in PyOpenGL. """ from OpenGL.GLUT import * from OpenGL.GLU import * from OpenGL.GL import * from PIL import Image import numpy def run_scene(): glutInit() glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH) glutCreateWindow("Minimal sphere OpenGL") lightning() glutDisplayFunc(draw_sphere)

QOpenGLWidget only updates when resized

柔情痞子 提交于 2019-12-25 14:42:26
问题 I've been given an opengl example demonstrating how to use a texture to display a 2d image. I've extended the example to render in a QOpenGLWidget . Now I want to use a QTimer to create an animation. The code below should draw a randomly generated 16x16 greyscale image to a texture every time paintGL() is called. A QTimer calls update() every 250ms but I am only seeing updates to the scene when I resize the window and I can't work out why. I have limited experience with opengl and don't fully

QOpenGLWidget only updates when resized

删除回忆录丶 提交于 2019-12-25 14:41:23
问题 I've been given an opengl example demonstrating how to use a texture to display a 2d image. I've extended the example to render in a QOpenGLWidget . Now I want to use a QTimer to create an animation. The code below should draw a randomly generated 16x16 greyscale image to a texture every time paintGL() is called. A QTimer calls update() every 250ms but I am only seeing updates to the scene when I resize the window and I can't work out why. I have limited experience with opengl and don't fully

Inconsistent skybox rendering using different textures in Pygame + PyOpenGL

岁酱吖の 提交于 2019-12-25 09:05:34
问题 Motivated by my incomplete answer to this question, I am implementing a simple skybox in PyOpenGL in accordance with this tutorial, making minor tweaks as needed for OpenGL 2.1/GLSL 120 and python2.7-isms. For the most part, it works successfully, but depending on what six images I pass to my cubemap, the images either end up swapped between a single pair of opposite faces or are randomly rotated ! Below is the main class of this demo: import pygame import sys import time import glob import

Pyopengl tessellating polygons

心已入冬 提交于 2019-12-25 07:17:11
问题 I have polygons in the form: [(1,2), (2,4), (3,4), (5,6)] I need tessellation to draw them, but glutess is too complicated. Opengl cannot handle convex polygons. I think I need something like: http://www.math.uiuc.edu/~gfrancis/illimath/windows/aszgard_mini/pylibs/OpenGLContext/scenegraph/polygontessellator.py But I don't understand how to use it. Can anyone give me a clear example? It have to use pyopengl as it has to integrate with another project (pygame etc won't work) Alternatively, is

How to initialize a buffer object's data store with data from PyGLM?

允我心安 提交于 2019-12-25 02:28:46
问题 I use PyGLM and PyOpenGL I have specified the following Shader Storage Buffer in the Vertex Shader: layout(std430, binding = 1) buffer MVP { mat4 u_proj; mat4 u_view; mat4 u_model; } mvp_data; I have initialized the model, view and projection matrix: model = glm.mat4(1) view = glm.lookAt(glm.vec3(0,-3,0), glm.vec3(0,0,0), glm.vec3(0,0,1)) proj = glm.perspective(glm.radians(90), self.__vp_size[0]/self.__vp_size[1], 0.1, 100) How can the buffer object's data store be created and initialized

Python: How to get cube to spin and move in OpenGL Superbible example

天涯浪子 提交于 2019-12-24 15:07:48
问题 For some reason, the cube does not move around the screen, though it spins. This is with the use of the functions m3dTranslateMatrix44 and m3dRotationMatrix44 though there seems a better way. Modified rotation_matrix(axis, theta) to produce a 4x4 matrix hopefully correctly. I think perhaps it may be to create a mv_matrix through the use of numpy multiplication. Done that. But still off a bit. Update - June 24, 2019: After some explanation and excellent code by Rabbid76 the program is now

When trying to install pygame on Anaconda Python 3.x is downgraded to Python 2.7

房东的猫 提交于 2019-12-24 07:24:02
问题 I'm working with Anaconda Python 3. I'm trying to install pyOpenGL, Vpython and pygame. Installing pyOpenGL and Vpython is fine using conda install . When I try to install Pygame, using conda install it shows: conda install -c https://conda.binstar.org/kne pygame #same for conda install pygame ... The following NEW packages will be INSTALLED: . . . The following packages will be REMOVED: backports.os-0.1.1-py37_0 importlib_metadata-0.8-py37_0 jeepney-0.4-py37_0 jupyterlab_server-0.2.0-py37_0

Pyglet OpenGL drawing anti-aliasing

流过昼夜 提交于 2019-12-23 07:08:43
问题 I've been looking around for a way to anti-alias lines in OpenGL, but none of them seem to work... here's some example code: import pyglet from pyglet.gl import * window = pyglet.window.Window(resizable=True) @window.event def on_draw(): window.clear() pyglet.gl.glColor4f(1.0,0,0,1.0) glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) glEnable (GL_BLEND) glEnable (GL_LINE_SMOOTH); glHint (GL_LINE_SMOOTH_HINT, GL_DONT_CARE) glLineWidth (3) pyglet.graphics.draw(2, pyglet.gl.GL_LINES, ('v2i',

openGL textures beginner question - 1D Texture creation?

雨燕双飞 提交于 2019-12-23 03:08:25
问题 EDIT Ok I added some changes to my texture rendering, and I'm now at a point that it doesn't look how I want it but before I try to change anything I just want to be sure I'm on the right path. The problem I'm trying to fix is: I have 180000 vertices. Each of them can be from one of 190 "classes". Each class can have a different color assigned at a different time. So I'm trying to create a texture with 190 colors, and for each of the 180000 vertexes have a textureCoord to the coresponding