I have this idea for a simple game requiring some 3D graphics for my sons to play. It shouldn't be too demanding - render up to 5 (approx.) spheres on the screen at one time - but I would like to apply an image map to the spheres to make them look good. This game will need to run on a number of different PCs under Linux.

My first thought was Python + PyOpenGL. But after a couple of hours unsuccessfully trying to get the first tutorial on PyOpenGL site working, I'm ready to give up on Python.

So, does anyone have a recommendation for a language with an OpenGL binding that is relatively easy to use?

I'm familiar with Python (somewhat), Javascript/NodeJS (moderate), PHP (very comfortable), C/C++ (somewhat). I'd also be interested in learning Go, although I haven't tried it yet.

For what it's worth, I found the instructions in the PyOpenGL tutorial impossible to follow - not because the instructions themselves were incorrect, but because I kept running into problems with missing and unresolvable dependencies. And when I finally got all the dependencies resolved, I got an OpenGL error. I'm going to have to install & maintain this on multiple machines and I don't want the headache.


Since you already know some python why not use visual python it is cross platform and can readily do what you ask.

The texture_and_lighting example:

from __future__ import division
from visual import *
# Bruce Sherwood, August 2006
# Demonstration of transparency (opacity), materials, and local lights in Visual 5

# Create a texture to apply to a sphere to make a beach ball
bands = zeros([16,16,4], float)
for i in range(len(bands)):
    for j in range(len(bands[0])):
        op = 1
        if i % 2 == 0: # every other band is partially transparent
            op = 0.3
            col = color.cyan
            # choose a color for an opaque band of the beach ball:
            col = [color.blue, color.green, color.red,
                   color.yellow, color.cyan][i//2 % 5]
        bands[i][j] = (col[0], col[1], col[2], op)
stripes = materials.texture(data = bands,
                       mapping = "spherical",
                       interpolate = False)

scene.width = scene.height = 800
scene.forward = (-0.2,-0.2,-1)
width = 10 # of wood table
thick = 0.5 # thickness of wood
depth = 7 # of wood table
height = 2 # of side bars of table
xhit = height-thick # x distance of center of ball from side bar when it hits
R = 2 # radius of ball
H = 10 # height of underside of ceiling above floor
L = 5 # length of pendulum to center of hanging lamp
# top of floor is at y=0 for convenience

floor = box(pos=(0,-thick/2,0), size=(width,thick,depth),
            shininess=0, color=color.orange, material=materials.wood)
left = box(pos=(-(width/2+thick/2),height/2-thick,0), size=(thick,height,depth),
            shininess=0, color=color.orange, material=materials.wood)
right = box(pos=(width/2+thick/2,height/2-thick,0), size=(thick,height,depth),
            shininess=0, color=color.orange, material=materials.wood)
back = box(pos=(0,height/2-thick,-(depth/2+thick/2)), size=(width+2*thick,height,thick),
            shininess=0, color=color.orange, material=materials.wood)
ceiling = box(pos=(0,H+thick/2,0), size=(width/10,thick,width/10), color=color.orange, material=materials.wood)
pendulum = frame(pos=(0,H,0), axis=(0,-1,0))
wire = curve(frame=pendulum, pos=[(0,0,0),(L,0,0)])
lamp = sphere(frame=pendulum, pos=(L,0,0), radius=0.03*L, color=color.white, material=materials.emissive)
sphere(pos=(0.1*width,R/4,0.45*depth), radius=R/4, color=color.red, material=materials.marble)
sphere(pos=(0.15*width,R/4,0.3*depth), radius=R/4, color=color.yellow, material=
sphere(pos=(0.15*width,R/4,-0.3*depth), radius=R/4, color=color.green, material=materials.marble)
sphere(pos=(0.1*width,R/4,-0.45*depth), radius=R/4, color=color.cyan, material=materials.marble)
scene.lights = []
scene.ambient = color.gray(0.25)
l1 = distant_light(direction=(6,2,4), color=color.gray(0.3))
l2 = distant_light(direction=(-10,2,4), color=color.gray(0.2))
lamplight = local_light(frame=pendulum, pos=(L,0,0), color=color.gray(0.5))
scene.center = (0,0.4*H,0)

ball = sphere(pos=(width/4,R,0), radius=R, up=(0,1,1), material=stripes)
xlimit = 0.5*width-R*sin(acos(1-(height-thick)/R))
v = vector(-0.5,0,0)
dt = 0.03
t = 0

while True:
    ball.pos += v*dt
    ball.rotate(axis=(0,0,1), angle=-v.x*dt/R)
    if abs(ball.x) >= xlimit:
        v = -v
    angle = 0.02*cos(t)
    pendulum.rotate(axis=(1,0,0), angle=angle)
    t += dt

Results in: enter image description here

With the stripy ball rolling back and forth and the light swinging to and throw.

  • Thanks! I hadn't heard of visual python. I'll check it out. – Kryten Nov 30 '15 at 22:02

ECMA-335 (.NET/Mono) with OpenTK:

The Open Toolkit is an advanced, low-level C# library that wraps OpenGL, OpenCL and OpenAL. It is suitable for games, scientific applications and any other project that requires 3d graphics, audio or compute functionality. The Open Toolkit runs on many operating systems and can be used by every Mono/.Net language: C#, VB.Net, C++/CLI, F#, Boo and many more.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.