小编Vic*_*tin的帖子

将 pygame 2d 水波纹转换为 pyOpenGL

我有一个 2d pygame 水模拟东西,我是按照教程制作的。我还找到了这个问题的答案来解决教程中的问题:Pygame water Physics not working as expected

从那以后,我一直在尝试将此程序转换为使用 pyopengl 来呈现内容。但是,我一直在努力: A:绘制水多边形 B:使用平铺纹理对水多边形进行纹理化

这是我(相当糟糕)将此代码转换为 pyopengl 的尝试。

import pygame, random
import math as m

from pygame import *
from OpenGL import *
from OpenGL.GLU import *
from OpenGL.GL import *

pygame.init()

WINDOW_SIZE = (854, 480)
 
screen = pygame.display.set_mode(WINDOW_SIZE,0,32,DOUBLEBUF|OPENGL) # initiate the window

clock = pygame.time.Clock()


def draw_polygon(polygon_points):
    glBegin(GL_POLYGON);
    for i in polygon_points:
        glVertex3fv(i)
    #glEnd()
    
class surface_water_particle():
    
    def __init__(self, x,y):
        self.x_pos = x
        self.y_pos = y
        self.target_y = y …
Run Code Online (Sandbox Code Playgroud)

python opengl pygame physics pyopengl

6
推荐指数
1
解决办法
133
查看次数

标签 统计

opengl ×1

physics ×1

pygame ×1

pyopengl ×1

python ×1