SunQuest
           Python Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPython Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
AT&T devCentral & BlackBerry(r) Webcast Series: BlackBerry and GPS -Build Location Awareness into your BlackBerry Applications, July 10th-1:00PM EST. Register Today!
  #1  
Old October 15th, 2003, 02:33 PM
jpjp jpjp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 11 jpjp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
newb quest: PIL image to texture in OpenGLContext

i am trying to display a PIL image in OpenGL using OpenGLContext. I cant seem to get OpenGLContext to take a PIL as an argument. im using the class imagetexture from the scenegraph package. anyone help plz?

Reply With Quote
  #2  
Old October 15th, 2003, 02:54 PM
irishtek irishtek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Tucson AZ
Posts: 29 irishtek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to irishtek Send a message via AIM to irishtek Send a message via Yahoo to irishtek
I've used PIL, and pyopengl/pygame - but never together.
Right now, I don't know why it wouldn't work though...

Do you have an error message, or some code I could look at, preferably both?

Last edited by irishtek : October 15th, 2003 at 02:56 PM.

Reply With Quote
  #3  
Old October 15th, 2003, 03:08 PM
jpjp jpjp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 11 jpjp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
def getData( self):
try:
fp1 =data1.rd3','rb')
except:
print 'error'
else:
s1 = fp1.read()
self.data1array = []
length1 = len(s1)
for i in range(1,length1,2):
num1 = ord(s1[i])
if num1 > 127:
num1 &= 127
else:
num1 += 128
self.data1array.append(chr(num1))
self.imagenew = string.join(self.data1array,'')
# print self.imagenew

self.im = Image.fromstring('L',(512,1235),self.imagenew)

# im = Image.fromstring("F", (512,1235), s, "raw", "F;16S", 0, 1)

Reply With Quote
  #4  
Old October 15th, 2003, 03:09 PM
jpjp jpjp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 11 jpjp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
it shold be a PIL at that last line. i need to convert that to a OpenGL texture

Reply With Quote
  #5  
Old October 15th, 2003, 03:32 PM
irishtek irishtek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Tucson AZ
Posts: 29 irishtek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to irishtek Send a message via AIM to irishtek Send a message via Yahoo to irishtek
Ah.. i found this online it might be helpful...



http://pyopengl.sourceforge.net/context/nehe6.html

This document discusses the NeHe6 tutorial by Jeff Molofee. It introduces texture mapping using PIL to load Images, and the use of the OnInit customisation point for Contexts.

Reply With Quote
  #6  
Old October 15th, 2003, 03:44 PM
jpjp jpjp is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 11 jpjp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
i've seen this, but thaks anyhow

Reply With Quote
  #7  
Old October 15th, 2003, 04:05 PM
irishtek irishtek is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Tucson AZ
Posts: 29 irishtek User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to irishtek Send a message via AIM to irishtek Send a message via Yahoo to irishtek
to take from the site...

im = open(imageName) <--- you've already got im defined....
try:
# get image meta-data (dimensions) and data
ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBA", 0, -1)
except SystemError:
# has no alpha channel, synthesize one, see the
# texture module for more realistic handling
ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBX", 0, -1)
# generate a texture ID
ID = glGenTextures(1)
# make it current
glBindTexture(GL_TEXTURE_2D, ID)
glPixelStorei(GL_UNPACK_ALIGNMENT,1)
# copy the texture into the current texture ID
glTexImage2D(GL_TEXTURE_2D, 0, 3, ix, iy, 0, GL_RGBA, GL_UNSIGNED_BYTE, image) <---- uses the image from im


So I guess if you've tried using this then what error do you have that it's not working?

Have you tried loading an image into pil instead of the fromstring option?

There's just not enough here for me to go on.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPython Programming > newb quest: PIL image to texture in OpenGLContext


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway