opengl-compat

Pyopengl reading obj file

て烟熏妆下的殇ゞ 提交于 2021-01-29 01:58:45
问题 I tried to read obj file with pyopengl but error come from glGenList(1) I just want to read the file and display in opengl Pls can you help me with full code; Am tired of stack and error it took me 3hrd to post this from OpenGL.GL import * from tkinter import messagebox import sys filename = input('pls input file path: ') class OBJ: def __init__(self, filename, swapyz=False): """Loads a Wavefront OBJ file. """ self.vertices = [] self.normals = [] self.texcoords = [] self.faces = [] material =

I have a black texture

冷暖自知 提交于 2021-01-28 09:09:51
问题 This is my first time working with textures in OpenGL, although I've been studying it for 4 months now. And when I try to load a texture (Just an image with a square) I get just a black square.\ My texture load code: byte[] pixelData = new byte[0]; try { BufferedImage bi = ImageIO.read(getClass().getResource(TEXTURE_FILES)); ByteArrayOutputStream baos = new ByteArrayOutputStream(); ImageIO.write(bi, "png", baos); baos.flush(); pixelData = baos.toByteArray(); baos.close(); } catch (IOException

Why can't Pyglet draw a polygon correctly?

六眼飞鱼酱① 提交于 2021-01-28 07:30:44
问题 I'm randomly creating points to use to draw a polygon with Pyglet. But Pyglet doesn't do the job right most of the time. Well I tried drawing a polygon with another graphic module and actually it worked but if Pyglet was working alright it would make my job easier. I use this to draw polygon and points (to make it easy for you see). point_list = [18, 61, 59, 149, 328, 204, 305, 284, 3, 197, 25, 107] ec = int(len(point_list)/2) batch.add(ec, pyglet.gl.GL_POLYGON, None, ("v2i", point_list), (

Issues with animation - translation, projection OpenGL/C++

混江龙づ霸主 提交于 2021-01-28 05:34:18
问题 Recently I had this issue. Now that I've fixed that with given solution, I ran into some other issues. Here is a gif of the animation I have to achieve. Issues I have now are: the ball in my animation doesn't look like it's moving forwards and backwards like it is at the beginning of the .gif. I do believe this has something to do with Ortho but I don't know how to fix this. Also, at some point, when it's moving completely to the right, the moving ball and torus just get "swallowed", it's

why does my window doesn't work for on_draw?

♀尐吖头ヾ 提交于 2020-07-22 06:31:38
问题 I was watching a video about pyglet and I tried to create a triangle: import pyglet from pyglet.gl import * class mywindow(pyglet.window.Window): def __init__(self, *args,**kwargs): super().__init__(*args,**kwargs) self.set_minimum_size(300,300) window = mywindow(300,300,"deneme", True) def on_draw(): glBegin(GL_TRIANGLE) glColor3b(255,0,0) glVertex2f(-1,0) glColor3b(0,255,0) glVertex2f(1,0) glColor3b(0,0,255) glVertex2f(0,1) window.on_draw() pyglet.app.run() when I run this code; I get this

Adding coordinates of clicks with glut to a linked list of vectors

爱⌒轻易说出口 提交于 2020-05-15 08:00:52
问题 I want to create a linked list of vectors and with the help of GLUT library get the positions of the clicks and append them to the linked list. These are the structs i wrote. typedef struct vector{int x;int y;}Vector; typedef struct VectorList{Vector X; struct VectorList*next; }node_v; I globally defined a P vector and linked list of vectors prev. Vector P; node_v * prev=NULL; Inside the mouse callback function _mouse_CB everytime left mouse button is clicked, i want to update the P vector

How to correctly add a light to make object get a better view with pygame and pyopengl

不打扰是莪最后的温柔 提交于 2020-04-14 07:38:12
问题 I am following the tutorial available in https://pythonprogramming.net/opengl-pyopengl-python-pygame-tutorial/ where he teachs how to render a cube with pyOpenGL an pygame. When rendering the cube, the tutorial set color to all the vertices of the cubes and then dispays it. However, im my project, i load object from a .obj file using the code provided in https://www.pygame.org/wiki/OBJFileLoader and most of my objects is fully white. Conclusion: when i render it on screen, i only see full

How to correctly add a light to make object get a better view with pygame and pyopengl

与世无争的帅哥 提交于 2020-04-14 07:38:11
问题 I am following the tutorial available in https://pythonprogramming.net/opengl-pyopengl-python-pygame-tutorial/ where he teachs how to render a cube with pyOpenGL an pygame. When rendering the cube, the tutorial set color to all the vertices of the cubes and then dispays it. However, im my project, i load object from a .obj file using the code provided in https://www.pygame.org/wiki/OBJFileLoader and most of my objects is fully white. Conclusion: when i render it on screen, i only see full