Hi,

This issue is driving me mad so I'm reaching out the pyglet community
to see if they can help me :-)

The code below draw a 10 x 10 grid of squares 64px in size, and it all
works except the texture mapping part. All I get is grey squares, or
white when the mouse moves over them. These colors are set on the line
where the mouse position is tested, and are meant to alter the blend
color of the texture. Can anyone see why the texture isn't mapping ?

I've tried loading different images and formats, and also loaded the
same image as a sprite and displayed that (see below) just to make
sure the image is being loaded okay and that works so I'm really
starting to pull my hair out ...

import pyglet

from pyglet.gl         import *
from dotmic.pyglet  import extensions

window  = pyglet.window.Window(width=1024, height=768,
caption='Atomino', visible=False)
mouse   = extensions.Mouse()

glEnable(GL_TEXTURE_2D)
glEnable(GL_COLOR_MATERIAL)

glShadeModel(GL_SMOOTH)

grid = glGenLists(1)
glNewList(grid, GL_COMPILE)
glBegin(GL_TRIANGLE_STRIP)
glTexCoord2f(1.0, 1.0); glVertex2f(64.0, 64.0)
glTexCoord2f(0.0, 1.0); glVertex2f(0.0, 64.0)
glTexCoord2f(1.0, 0.0); glVertex2f(64.0, 0.0)
glTexCoord2f(0.0, 0.0); glVertex2f(0.0, 0.0)
glEnd()
glEndList()

image   = pyglet.image.load('grid.png')
sprite  = pyglet.sprite.Sprite(image, 0, 640)
texture = image.get_texture()
glBindTexture(GL_TEXTURE_2D, texture.id)

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)

def draw_grid():
    glBindTexture(GL_TEXTURE_2D, texture.id)
    for rows in range(10):
        for columns in range(10):
            glPushMatrix()
            x, y = rows * 64.0, columns * 64.0
            glTranslatef(x, y, 0)
            if(mouse.x > x) and (mouse.x < x + 64.0) and (mouse.y > y)
and (mouse.y < y + 64.0):
                glColor3f(0.75, 0.75, 0.75)
            else:
                glColor3f(0.5, 0.5, 0.5)
            glCallList(grid)
            glPopMatrix()

@window.event
def on_mouse_motion(x, y, dx, dy):
    mouse.x, mouse.y = x, y

@window.event
def on_draw():
    glClear(GL_COLOR_BUFFER_BIT)
    glLoadIdentity()

    draw_grid()
    sprite.draw()

    cue.draw()
    fps.draw()

fps = pyglet.clock.ClockDisplay()
cue = extensions.CueMark(window)
window.set_visible()
pyglet.app.run()

Any help getting the texture to map would be greatly appreciated.

Thanks

-Mic
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pyglet-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/pyglet-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to