I am using pygame and pyopengl, and am trying to get glGenTextures(1,img) to return 1. I have checked that 'myPixelArt.bmp' has power-of-2 dimensions. My script starts with:
import pygame, OpenGL, math, numpy
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.WGL import *
from OpenGL.GLU import *
from PIL import Image
from ctypes import *
img = Image.open('myPixelArt.bmp')
glEnable(GL_TEXTURE_2D)
hdc=windll.user32.GetDC(1)
print hdc
hglrc=wglCreateContext(hdc)
wglMakeCurrent(hdc,hglrc)
im=glGenTextures(1,img)
print im
But this prints out 0 for hdc and 0 for im.
What argument should I use for windll.user32.GetDC to create a display context and hopefully get glGenTextures to return 1?
Try to first create a window!
import pygame, OpenGL, math, numpy
from pygame.locals import *
from OpenGL.GL import *
from OpenGL.WGL import *
from OpenGL.GLU import *
from PIL import Image
from ctypes import *
size=(800,600)
pygame.display.set_mode(size,pygame.OPENGL|pygame.DOUBLEBUF)
img = Image.open('myPixelArt.bmp')
glEnable(GL_TEXTURE_2D)
hdc=windll.user32.GetDC(1)
print hdc
hglrc=wglCreateContext(hdc)
wglMakeCurrent(hdc,hglrc)
im=glGenTextures(1,img)
print im
Becouse Pygame creates an OpenGL-context along with the window.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With