opengl-compat

How to test if a 2d point in pygame screen is part of a 3d object in PyOpenGL?

99封情书 提交于 2021-02-10 21:38:34
问题 I am making a game (RPG) in PyOpenGL which I have a crosshair. I want to check if a 3d object is in the crosshair (or detect if it is at a point), which is a 2d overlay. How can I do that? I tried to use screen.get_at() function, but it displays an error "Cannot call on OpenGL surfaces". Also, it is not good because it only detects a colour, not an object (although you can use the colour to determine an object, but what if there are several objects that have the same colour?). This is what I

How to test if a 2d point in pygame screen is part of a 3d object in PyOpenGL?

亡梦爱人 提交于 2021-02-10 21:38:06
问题 I am making a game (RPG) in PyOpenGL which I have a crosshair. I want to check if a 3d object is in the crosshair (or detect if it is at a point), which is a 2d overlay. How can I do that? I tried to use screen.get_at() function, but it displays an error "Cannot call on OpenGL surfaces". Also, it is not good because it only detects a colour, not an object (although you can use the colour to determine an object, but what if there are several objects that have the same colour?). This is what I

OpenGL overlapping ugly rendering

有些话、适合烂在心里 提交于 2021-02-08 15:18:37
问题 I'm trying to render a scene with OpenGL 2.1 but the borders on overlapping shapes are weird. I tested some OpenGL initialisations but without any change. I reduce my issue to a simple test application with 2 sphere with the same result. I tried several things about Gl_DEPTH_TEST, enable/disable smoothing without success. Here is my result with 2 gluSphere : We can see some sort of aliasing when a line will be enough to separate blue and red faces... I use SharpGL but I think that it's not

OpenGL overlapping ugly rendering

家住魔仙堡 提交于 2021-02-08 15:16:28
问题 I'm trying to render a scene with OpenGL 2.1 but the borders on overlapping shapes are weird. I tested some OpenGL initialisations but without any change. I reduce my issue to a simple test application with 2 sphere with the same result. I tried several things about Gl_DEPTH_TEST, enable/disable smoothing without success. Here is my result with 2 gluSphere : We can see some sort of aliasing when a line will be enough to separate blue and red faces... I use SharpGL but I think that it's not

How to rotate a 2D line in PyOpenGL?

社会主义新天地 提交于 2021-02-08 01:28:31
问题 I've written a code to draw a line. Here is the function: def drawLines(): r,g,b = 255,30,20 #drawing visible axis glClear(GL_COLOR_BUFFER_BIT) glColor3ub(r,g,b) glBegin(GL_LINES) #glRotate(10,500,-500,0) glVertex2f(0,500) glVertex2f(0,-500) glEnd() glFlush() Now I'm trying to rotate the line. I'm trying to follow this documentation but can't understand. According to the documentation the rotating function is defined as follows: def glRotate( angle , x , y , z ): I've no z-axis. So I'm

How to rotate a 2D line in PyOpenGL?

泄露秘密 提交于 2021-02-08 01:21:10
问题 I've written a code to draw a line. Here is the function: def drawLines(): r,g,b = 255,30,20 #drawing visible axis glClear(GL_COLOR_BUFFER_BIT) glColor3ub(r,g,b) glBegin(GL_LINES) #glRotate(10,500,-500,0) glVertex2f(0,500) glVertex2f(0,-500) glEnd() glFlush() Now I'm trying to rotate the line. I'm trying to follow this documentation but can't understand. According to the documentation the rotating function is defined as follows: def glRotate( angle , x , y , z ): I've no z-axis. So I'm

How to rotate a 2D line in PyOpenGL?

孤者浪人 提交于 2021-02-08 01:20:13
问题 I've written a code to draw a line. Here is the function: def drawLines(): r,g,b = 255,30,20 #drawing visible axis glClear(GL_COLOR_BUFFER_BIT) glColor3ub(r,g,b) glBegin(GL_LINES) #glRotate(10,500,-500,0) glVertex2f(0,500) glVertex2f(0,-500) glEnd() glFlush() Now I'm trying to rotate the line. I'm trying to follow this documentation but can't understand. According to the documentation the rotating function is defined as follows: def glRotate( angle , x , y , z ): I've no z-axis. So I'm

Why is my OpenGL program unable to load the GLUT bitmap fonts?

筅森魡賤 提交于 2021-02-05 08:43:07
问题 I want to display some simple text on the HUD of my 3D environment in OpenGL. All sources say that I should use the bitmap fonts included in GLUT, however, my program can't seem the find/load the fonts. I have included all of the correct libraries and have double checked that the fonts.py file is definitely in the ...\Python37\...\OpenGL\GLUT\ directory, but when I type GLUT_BITMAP_TIMES_ROMAN_24 (or any of the other bitmap fonts), it is highlighted as an error in my code. This is the

Why does my wired sphere turn into ellipsoid when translating and changing camera angle?

十年热恋 提交于 2021-02-05 07:58:27
问题 I need to translate my wired sphere along z-axis back and forth while also changing camera angle. Whenever my sphere gets translated, it slowly turns into ellipsoid. I really don't understand why. Here you can see pieces of code where I believe is a mistake. Also, shapes shouldn't be changed when resizing the window, only their size. void init() { glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST); } void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(

Why does my wired sphere turn into ellipsoid when translating and changing camera angle?

不想你离开。 提交于 2021-02-05 07:56:11
问题 I need to translate my wired sphere along z-axis back and forth while also changing camera angle. Whenever my sphere gets translated, it slowly turns into ellipsoid. I really don't understand why. Here you can see pieces of code where I believe is a mistake. Also, shapes shouldn't be changed when resizing the window, only their size. void init() { glClearColor(0.0, 0.0, 0.0, 0.0); glEnable(GL_DEPTH_TEST); } void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(