pyopengl-users Mailing List for PyOpenGL (Page 33)
Brought to you by:
mcfletch
You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(81) |
Oct
(41) |
Nov
(55) |
Dec
(14) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2002 |
Jan
(34) |
Feb
(3) |
Mar
(16) |
Apr
(5) |
May
(10) |
Jun
(13) |
Jul
(24) |
Aug
(14) |
Sep
(14) |
Oct
(9) |
Nov
(10) |
Dec
(16) |
2003 |
Jan
(25) |
Feb
(59) |
Mar
(9) |
Apr
(21) |
May
(54) |
Jun
(4) |
Jul
(16) |
Aug
(19) |
Sep
(19) |
Oct
(15) |
Nov
(13) |
Dec
(22) |
2004 |
Jan
(19) |
Feb
(8) |
Mar
(20) |
Apr
(16) |
May
(13) |
Jun
(18) |
Jul
(18) |
Aug
(14) |
Sep
(24) |
Oct
(47) |
Nov
(20) |
Dec
(10) |
2005 |
Jan
(23) |
Feb
(31) |
Mar
(11) |
Apr
(29) |
May
(18) |
Jun
(7) |
Jul
(11) |
Aug
(12) |
Sep
(8) |
Oct
(4) |
Nov
(11) |
Dec
(7) |
2006 |
Jan
(7) |
Feb
(8) |
Mar
(15) |
Apr
(3) |
May
(8) |
Jun
(25) |
Jul
(19) |
Aug
(3) |
Sep
(17) |
Oct
(27) |
Nov
(24) |
Dec
(9) |
2007 |
Jan
(6) |
Feb
(43) |
Mar
(33) |
Apr
(8) |
May
(20) |
Jun
(11) |
Jul
(7) |
Aug
(8) |
Sep
(11) |
Oct
(22) |
Nov
(15) |
Dec
(18) |
2008 |
Jan
(14) |
Feb
(6) |
Mar
(6) |
Apr
(37) |
May
(13) |
Jun
(17) |
Jul
(22) |
Aug
(16) |
Sep
(14) |
Oct
(16) |
Nov
(29) |
Dec
(13) |
2009 |
Jan
(7) |
Feb
(25) |
Mar
(38) |
Apr
(57) |
May
(12) |
Jun
(32) |
Jul
(32) |
Aug
(35) |
Sep
(10) |
Oct
(28) |
Nov
(16) |
Dec
(49) |
2010 |
Jan
(57) |
Feb
(37) |
Mar
(22) |
Apr
(15) |
May
(45) |
Jun
(25) |
Jul
(32) |
Aug
(7) |
Sep
(13) |
Oct
(2) |
Nov
(11) |
Dec
(28) |
2011 |
Jan
(35) |
Feb
(39) |
Mar
|
Apr
(25) |
May
(32) |
Jun
(17) |
Jul
(29) |
Aug
(10) |
Sep
(26) |
Oct
(9) |
Nov
(28) |
Dec
(4) |
2012 |
Jan
(24) |
Feb
(47) |
Mar
(4) |
Apr
(8) |
May
(9) |
Jun
(6) |
Jul
(4) |
Aug
(1) |
Sep
(4) |
Oct
(28) |
Nov
(2) |
Dec
(2) |
2013 |
Jan
(11) |
Feb
(3) |
Mar
(4) |
Apr
(38) |
May
(15) |
Jun
(11) |
Jul
(15) |
Aug
(2) |
Sep
(2) |
Oct
(4) |
Nov
(3) |
Dec
(14) |
2014 |
Jan
(24) |
Feb
(31) |
Mar
(28) |
Apr
(16) |
May
(7) |
Jun
(6) |
Jul
(1) |
Aug
(10) |
Sep
(10) |
Oct
(2) |
Nov
|
Dec
|
2015 |
Jan
(6) |
Feb
(5) |
Mar
(2) |
Apr
(1) |
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(2) |
Oct
(1) |
Nov
(19) |
Dec
|
2016 |
Jan
(6) |
Feb
(1) |
Mar
(7) |
Apr
|
May
(6) |
Jun
|
Jul
(3) |
Aug
(7) |
Sep
|
Oct
(2) |
Nov
(2) |
Dec
|
2017 |
Jan
|
Feb
(6) |
Mar
(8) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(4) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
|
2018 |
Jan
(9) |
Feb
(1) |
Mar
|
Apr
|
May
(1) |
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2019 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
(6) |
Jun
(1) |
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2020 |
Jan
|
Feb
|
Mar
|
Apr
(7) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2021 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
(2) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2024 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
|
Dec
|
From: Jonathan H. <ta...@ta...> - 2010-11-12 07:55:21
|
There's an interesting question on StackOverflow today that I suspect a lot of people would like to see an optimal answer to: ----- What is the fastest way in python to build a c array from a list of tuples of floats? The context: my Python code pass arrays of 2D vertices to OpenGL. I tested 2 approaches, one with ctypes, the other with struct, the latter being more than twice faster. from random import random points = [(random(), random()) for _ in xrange(1000)] from ctypes import c_float def array_ctypes(points): n = len(points) return n, (c_float*(2*n))(*[u for point in points for u in point]) from struct import pack def array_struct(points): n = len(points) return n, pack("f"*2*n, *[u for point in points for u in point]) Any other alternatives? ----- http://stackoverflow.com/q/4156872/10176 He's already chosen one answer, but I think that was premature, and some of you folks might have substantially better ideas. I'm thinking of a fully static-typed Cython function, but I apparently lack the smarts to get it working over breakfast, and now I have to go to work. Jonathan -- Jonathan Hartley Made of meat. http://tartley.com ta...@ta... +44 7737 062 225 twitter/skype: tartley |
From: G. E. D. <ge...@ho...> - 2010-11-04 21:05:25
|
Here are some changes to provide selection of freeglut.dll or glut32.dll for PyOpenGL on Win32 platforms. 1) Put both dlls in site-packages\OpenGL\DLLS. 2) Add USE_FREEGLUT to site-packages\OpenGL\__init__.py as follows: FROM: ---- UNSIGNED_BYTE_IMAGES_AS_STRING = True # Declarations of plugins provided by PyOpenGL itself TO: --- UNSIGNED_BYTE_IMAGES_AS_STRING = True USE_FREEGLUT = False # Declarations of plugins provided by PyOpenGL itself 3) Make following changes to site-packages\OpenGL\platforms\win32.py. FROM: ----- """Windows-specific platform features""" import ctypes from OpenGL.platform import ctypesloader, baseplatform class Win32Platform( baseplatform.BasePlatform ): """Win32-specific platform implementation""" GLUT_GUARD_CALLBACKS = True GL = OpenGL = ctypesloader.loadLibrary( ctypes.windll, \ 'opengl32', mode = ctypes.RTLD_GLOBAL ) GLU = ctypesloader.loadLibrary( ctypes.windll, \ 'glu32', mode = ctypes.RTLD_GLOBAL ) try : GLUT = ctypesloader.loadLibrary( ctypes.windll, \ 'glut32', mode = ctypes.RTLD_GLOBAL ) except WindowsError, err: GLUT = None GLE = None TO: --- """Windows-specific platform features""" import ctypes from OpenGL import USE_FREEGLUT from OpenGL.platform import ctypesloader, baseplatform class Win32Platform( baseplatform.BasePlatform ): """Win32-specific platform implementation""" GLUT_GUARD_CALLBACKS = True GL = OpenGL = ctypesloader.loadLibrary( ctypes.windll, \ 'opengl32', mode = ctypes.RTLD_GLOBAL ) GLU = ctypesloader.loadLibrary( ctypes.windll, \ 'glu32', mode = ctypes.RTLD_GLOBAL ) if USE_FREEGLUT : try : GLUT = ctypesloader.loadLibrary( ctypes.windll, \ 'freeglut', mode = ctypes.RTLD_GLOBAL ) except WindowsError, err: GLUT = None else : try : GLUT = ctypesloader.loadLibrary( ctypes.windll, \ 'glut32', mode = ctypes.RTLD_GLOBAL ) except WindowsError, err: GLUT = None GLE = None 4. Make following changes to site-packages\OpenGL\GLUT\__init__.py. FROM: ----- try: from OpenGL.GLUT.freeglut import * HAVE_FREEGLUT = False except ImportError, err: HAVE_FREEGLUT = True TO: --- try: from OpenGL.GLUT.freeglut import * if bool(glutMainLoopEvent) : HAVE_FREEGLUT = True else : HAVE_FREEGLUT = False except ImportError, err: HAVE_FREEGLUT = False 5. Import PyOpenGL GL, GLE, and GLUT modules using freeglut like this: import OpenGL OpenGL.USE_FREEGLUT = True from OpenGL.GL import * from OpenGL.GLU import * from OpenGL.GLUT import * |
From: Mike C. F. <mcf...@vr...> - 2010-10-18 13:20:17
|
On 10-10-14 09:41 AM, Alejandro Segovia wrote: > Hello List, > > I'm using PyOpenGL for conducting a Computer Graphics course at the > University where I work. > > One of my students is working on an Intel-based card (on W/Vista) that > reports OpenGL version 1.5, however, when trying to create VBO's, he > was getting an error from deep inside the wrapper. I figured this was > probably because of the function wrapper existing, but not being > actually linked to anything, which would imply VBO's are not supported > by his driver. Is the error a "null function error"? Or something more exotic? Null function error is basically just PyOpenGL saying "that doesn't exist" when you go to call the function. If the function evaluates to true (i.e. bool( fun ) == True), then we may have an error in the wrappers. > > The solution was to use the vertex_buffer_object ARB extension, which > had to be imported using something akin to: > > >>from OpenGL.raw.GL.ARB.vertex_buffer_object import * Normally you wouldn't use the raw version, but rather the OpenGL.GL.ARB.vertex_buffer_object version. VBOs, in particular, are actually provided as a wrapper (OpenGL.arrays.vbo), but this is the general pattern of use. > I was wondering, is this the recommended way to import and use > extensions in PyOpenGL? and, is it possible that although the Intel > driver reports OpenGL version 1.5, it does not provide VBO's? I > thought VBO's were promoted to Core in version 1.5. I seem to recall them being core in 1.5, yes. Good luck, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |
From: Alejandro S. <as...@gm...> - 2010-10-14 13:41:24
|
Hello List, I'm using PyOpenGL for conducting a Computer Graphics course at the University where I work. One of my students is working on an Intel-based card (on W/Vista) that reports OpenGL version 1.5, however, when trying to create VBO's, he was getting an error from deep inside the wrapper. I figured this was probably because of the function wrapper existing, but not being actually linked to anything, which would imply VBO's are not supported by his driver. The solution was to use the vertex_buffer_object ARB extension, which had to be imported using something akin to: >>from OpenGL.raw.GL.ARB.vertex_buffer_object import * I was wondering, is this the recommended way to import and use extensions in PyOpenGL? and, is it possible that although the Intel driver reports OpenGL version 1.5, it does not provide VBO's? I thought VBO's were promoted to Core in version 1.5. Thanks in advance, Alejandro.- |
From: Almar K. <alm...@gm...> - 2010-09-17 09:01:22
|
On 17 September 2010 00:26, Greg Ewing <gre...@ca...> wrote: > Almar Klein wrote: > > Well, what *should* work 100% is checking the opengl > > version (with glGetString(GL_VERSION)). > > No, this won't work 100%. It's better to test for the presence > of a specific extension, in this case "ARB_texture_non_power_of_two". > Testing only the version *does* make sure that the system supports non-power-of two textures. By testing also for the extension, you could detect that the system supports non-power-of-two, even if the version is smaller than 2.0. The latter is obviously a nicer solution, indeed. Almar |
From: Greg E. <gre...@ca...> - 2010-09-16 22:26:40
|
Almar Klein wrote: > Well, what *should* work 100% is checking the opengl > version (with glGetString(GL_VERSION)). No, this won't work 100%. It's better to test for the presence of a specific extension, in this case "ARB_texture_non_power_of_two". -- Greg |
From: Ian M. <geo...@gm...> - 2010-09-16 15:55:51
|
On Thu, Sep 16, 2010 at 12:39 AM, Almar Klein <alm...@gm...> wrote: > I'm not sure if I understand your question correctly. Are you asking for > the best way to detect whether power-of-two textures are required on a > particular system? Well, what *should* work 100% is checking the opengl > version (with glGetString(GL_VERSION)). But since this is not always enough > for ATI, and maybe also for Intel, I check after creating a texture, whether > the texture is valid (with glIsTexture), and try making it a power-of-two if > its not. > Originally, I was trying to track down the problem, and it turned out to be that the textures weren't powers of two. The real solution is to habitually use textures that are sized to a power of two to ensure compatibility. > Cheers, > Almar > Ian |
From: Almar K. <alm...@gm...> - 2010-09-16 06:39:52
|
On 16 September 2010 02:47, Ian Mallett <geo...@gm...> wrote: > On Tue, Sep 14, 2010 at 1:59 PM, Almar Klein <alm...@gm...>wrote: > >> The pretties way of doing this is checking the openGl version and if its < >> 2.0, you need power-of-two textures. However, I recently encountered a >> system with an ATI card, that did have OpenGl >=2.0, but did NOT support >> non-power-of-two textures. So my current implementation just tries resizing >> the texture if it fails to initialize, or if OpenGl <2.0. >> > I've simply added a global flag to my library that automatically resizes > all textures to a power of two (either automatically up, or to the nearest > level), and then made a note to favor power-of-two textures. It's pretty > lame that Intel does this. > > I don't suppose there's a more useful error that could be thrown here--does > the GL return something helpful in this regard? > I'm not sure if I understand your question correctly. Are you asking for the best way to detect whether power-of-two textures are required on a particular system? Well, what *should* work 100% is checking the opengl version (with glGetString(GL_VERSION)). But since this is not always enough for ATI, and maybe also for Intel, I check after creating a texture, whether the texture is valid (with glIsTexture), and try making it a power-of-two if its not. Cheers, Almar |
From: Ian M. <geo...@gm...> - 2010-09-16 00:47:59
|
On Tue, Sep 14, 2010 at 1:59 PM, Almar Klein <alm...@gm...> wrote: > The pretties way of doing this is checking the openGl version and if its < > 2.0, you need power-of-two textures. However, I recently encountered a > system with an ATI card, that did have OpenGl >=2.0, but did NOT support > non-power-of-two textures. So my current implementation just tries resizing > the texture if it fails to initialize, or if OpenGl <2.0. > I've simply added a global flag to my library that automatically resizes all textures to a power of two (either automatically up, or to the nearest level), and then made a note to favor power-of-two textures. It's pretty lame that Intel does this. I don't suppose there's a more useful error that could be thrown here--does the GL return something helpful in this regard? > Cheers, > Almar > Ian |
From: Almar K. <alm...@gm...> - 2010-09-14 19:59:28
|
On 1 August 2010 02:06, Ian Mallett <geo...@gm...> wrote: > On Sat, Jul 31, 2010 at 3:05 PM, Dirk Reiners <dir...@gm...>wrote: > >> All of that looks pretty straightforward. The only thing I can think of, >> but >> that should give a different error, is textures that are not power-of-two >> size. >> What are the sizes of your textures? >> > I hadn't even thought of that! > > And after some testing, it seems that's the problem. My test code can be > found here: > > http://download577.mediafire.com/jnza7ybur4qg/ievqu4buekair6k/test_texture.zip > > I'm surprised at how ubiquitous using power-of-two textures must be. > Basically no other applications seemed to have problems. I never had > problems, so I guess I assumed it was irrelevant. > > Uggggh I assume I'll have to rewrite my texture code so that it can take an > argument to scale surfaces to the nearest factor of two. Any other way? I > know of ARB_texture_rectangle, but that sounds horrible. Blech. I hate > Intel. > The pretties way of doing this is checking the openGl version and if its < 2.0, you need power-of-two textures. However, I recently encountered a system with an ATI card, that did have OpenGl >=2.0, but did NOT support non-power-of-two textures. So my current implementation just tries resizing the texture if it fails to initialize, or if OpenGl <2.0. Cheers, Almar |
From: Jeff M. <sk...@sk...> - 2010-09-11 01:15:32
|
Hey guys, I hope I'm not asking something thats been asked a million times before, but didn't turn up much in the search, and the hits across Google are few (and mostly regarding Maemo, which may or may not be of value.) Certainly, nothing very _concrete_ to the uniniated :) (I'm an experience developer and movile developer, but gles isn't something I've done a lot of; mostly in C++ and not python, for sure :) Short version: Is PyOpenGl at useful solution for doing python based opengl es 2.0 (or 1.1?) code right now? Or is it in the "we're still working towards it" phase? (I'm specifically targetting linux ARM handheld devices, but also want to support desktops and such .. I think its going to be a real PITA :) Think Beagleboard for instance. Longer: I'm looking at building a game UI in python using gles2.0; it is an interesting idea to do it in QT with gles2 (and even using pyqt), but the idea of forking out more $$$ to someone (not even trolltech) for pyqt hurts me too much (I paid way too much for QT in the past, before its curent more palatable license.) But really, I just want to play more with python, and this will be a fun project :) So I'm thinking it would be awesome to use cpython (2.6.4) + pyopengl. Is it doable? Or is it a world of trouble for now? Any tips? Any documentation or other folks notes who've done this before? jeff -- If everyone would put barbecue sauce on their food, there would be no war. |
From: Ian M. <geo...@gm...> - 2010-09-09 15:29:46
|
Hi, >From the docs, I found that: gluBuild2DMipmaps( GLenum(target), GLint(internalFormat), GLsizei(width), GLsizei(height), GLenum(format), GLenum(type), c_void_p(data) ) -> GLint But trying: c_void_p(data) Results in a: TypeError: cannot be converted to pointer. The solution: data.ctypes.data Thanks for all the help, everyone . . . Ian |
From: Ian M. <geo...@gm...> - 2010-09-09 02:09:12
|
Hi, So, I've run into a problem where I need to create a mipmapped float32 texture. My mipmapping code works fine for normal, 8 bit textures, but not for 32 bit textures. My code: #data = numpy.ndarray, float32, and 500x500x3 gluBuild2DMipmaps(GL_TEXTURE_2D,GL_RGB,500,500,GL_RGB,GL_FLOAT,data) ...complains that the the 7th argument ("data") is the wrong type. So . . . what type should it be? What to do? Thanks, Ian |
From: Mark R. <mar...@gm...> - 2010-09-07 20:51:37
|
Ask here as it sounds like a wxpython issue: http://groups.google.com/group/wxpython-users Mark On Tue, Sep 7, 2010 at 11:18 PM, Jason Hayes <Jas...@vo...> wrote: > Has anyone been able to get at least two different OpenGL views to work in a > wxPython app at the same time? I’ve created a basic class using > glcanvas.GLCanvas and am using that to put into a wx.Panel. Well, I need to > have two of these up at the same time, so I put another one into a different > wx.Panel and display them both in a splitter window. However, only the > first one that gets created receives its onPaint message properly. The > second one is visible, but only repaints whenever the wx.Frame is moved. > > > > -Jason > > ________________________________ > This message, including any attachments, may contain privileged and/or > confidential information. Any distribution or use of this email by anyone > other than the intended recipient(s) is strictly prohibited. If you are not > the intended recipient, please notify the sender immediately and delete all > copies. Thank you. > > ------------------------------------------------------------------------------ > This SF.net Dev2Dev email is sponsored by: > > Show off your parallel programming skills. > Enter the Intel(R) Threading Challenge 2010. > http://p.sf.net/sfu/intel-thread-sfd > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > > |
From: Jason H. <Jas...@vo...> - 2010-09-07 15:32:16
|
Has anyone been able to get at least two different OpenGL views to work in a wxPython app at the same time? I've created a basic class using glcanvas.GLCanvas and am using that to put into a wx.Panel. Well, I need to have two of these up at the same time, so I put another one into a different wx.Panel and display them both in a splitter window. However, only the first one that gets created receives its onPaint message properly. The second one is visible, but only repaints whenever the wx.Frame is moved. -Jason ________________________________ This message, including any attachments, may contain privileged and/or confidential information. Any distribution or use of this email by anyone other than the intended recipient(s) is strictly prohibited. If you are not the intended recipient, please notify the sender immediately and delete all copies. Thank you. |
From: <tin...@li...> - 2010-08-27 16:34:27
|
Dear list, I'm moving my project from win to mac platform. I made use of openGL with wxpython. I found some differences in the way the rendering is handled in the two platform. The simple example below will run good on win, but will not run properly on mac. It is a panel were dots can be printed with leftclicks; each panel can be viewed full screen with rightclicks. This functionality is hindert in mac. Could anyone tell me what I'm doing wring?Thanks import wx try: from wx import glcanvas haveGLCanvas = True except ImportError: haveGLCanvas = False try: from OpenGL.GL import * from OpenGL.GLUT import * from OpenGL.GLU import * haveOpenGL = True except ImportError: haveOpenGL = False import numpy as np ##--------------------------------------- class MySplash(wx.Frame): def __init__(self, element, parent, showFLAG=False, id = wx.ID_ANY, title = wx.EmptyString): wx.Frame.__init__(self, parent, id, title, wx.DefaultPosition, wx. DefaultSize)#, wx.CAPTION|wx.CLOSE_BOX|wx.SYSTEM_MENU|wx.CLIP_CHILDREN)#|wx. MAXIMIZE) self.m_parentWindow = element.GetParent() self.m_parentFrame = parent self.m_oldPos = self.m_parentWindow.GetPosition() self.m_oldSize = self.m_parentWindow.GetClientSize() self.splashedelement = element self.outer_sizer = wx.BoxSizer(wx.VERTICAL) self.SetBackgroundColour(wx.Colour( 0, 0, 0 ) ) self.outer_sizer.Add(element, 1, wx.ALIGN_CENTER|wx.EXPAND|wx.SHAPED, 5) self.SetSizer(self.outer_sizer) self.outer_sizer.Fit(self) self.Layout() self.Maximize() self.Show(showFLAG) self.Bind(wx.EVT_CLOSE, self.onClose) def setOldSize(self,size): self.m_oldSize = size def setOldPos(self,pos): #print "passed pos",pos self.m_oldPos = pos def getOldSize(self): return self.m_oldSize def getOldPos(self): return self.m_oldPos def onClose(self, event): self.splashedelement.Reparent(self.m_parentWindow) self.Show(False) self.splashedelement.SetClientSize(self.m_oldSize) self.splashedelement.SetPosition(self.m_oldPos) self.m_parentFrame.SendSizeEvent() ##--------------------------------------- class GLPanePixelSel(glcanvas.GLCanvas): def __init__(self, parent, ID = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.DefaultSize, style = 0, name = wx.EmptyString, gl_attr = None): glcanvas.GLCanvas.__init__(self, parent, ID, pos, size, style = wx. FULL_REPAINT_ON_RESIZE, name = wx.EmptyString, attribList = None) self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) self.Bind(wx.EVT_SIZE, self.OnSize) self.Bind(wx.EVT_PAINT, self.OnPaint) self.init_fl = False self.m_imgHight = size[1] self.m_imgWidth = size[0] self.m_panHight = 0 self.m_panWidth = 0 self.m_zoomH = 1 self.m_zoomW = 1 self.Bind(wx.EVT_LEFT_UP, self.OnLeftDown) self.zoomed=[] self.real=[] self.contDot=0 self.radius = 10 self.sinR=self.radius*np.sin(np.linspace(0,2*np.pi,20)) self.cosR=self.radius*np.cos(np.linspace(0,2*np.pi,20)) self.splashFrame = MySplash(self, wx.GetTopLevelParent(self)) self.Bind(wx.EVT_RIGHT_DOWN, self.mouseRightClick) def mouseRightClick(self, event): self.splashFrame.setOldSize(self.GetClientSize()) self.splashFrame.setOldPos(self.GetPosition()) self.Reparent(self.splashFrame) self.splashFrame.Show(True) self.onDraw() def OnLeftDown(self, event): pt = event.GetPosition() # position tuple realpt = (round(pt[0]/self.m_zoomW),round(pt[1]/self.m_zoomH)) self.real.append(realpt) print pt self.zoomed.append(pt) self.contDot+=1 self.Refresh() def initGL(self): ##openGL required!! glClearColor(0, 0, 0, 0) glShadeModel(GL_FLAT) glPixelStorei(GL_UNPACK_ALIGNMENT,1) self.init_fl = True def onDraw(self): glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) glPushMatrix() glPopMatrix() glPointSize(10.0) glColor3f(0.5, 1.0, 0.5) glLineWidth(2.0) glEnable(GL_LINE_SMOOTH) for dot in self.zoomed: glBegin(GL_LINE_LOOP) for s,c in zip(self.sinR,self.cosR): glVertex2f( dot[0]+s, dot[1]+c) glEnd() glFlush() self.SwapBuffers() def OnPaint(self, event): dc = wx.PaintDC(self) if not self.GetContext(): print "No Context!!!" return if not self.init_fl: self.initGL() self.SetCurrent() self.onDraw() def OnSize(self, event): size = self.GetClientSize() self.m_panWidth,self.m_panHight = size.width, size.height self.m_zoomH = (1.0*self.m_panHight)/self.m_imgHight self.m_zoomW = (1.0*self.m_panWidth)/self.m_imgWidth cont = 0 while cont<self.contDot: self.zoomed[cont]=(self.real[cont][0]*self.m_zoomW,self.real[cont] [1]*self.m_zoomH) cont+=1 if self.GetContext(): self.SetCurrent() glViewport(0, 0, self.m_panWidth,self.m_panHight) glMatrixMode (GL_PROJECTION) glLoadIdentity () gluOrtho2D (0.0, self.m_panWidth, self.m_panHight, 0.0) def OnEraseBackground(self, event): pass ##-------------------------------- class MyFrame(wx.Frame): def __init__(self, parent): wx.Frame.__init__(self, parent, -1, "Click for mouseposition", size= (400,300), style=wx.DEFAULT_FRAME_STYLE |wx. NO_FULL_REPAINT_ON_RESIZE) self.panel1=wx.Panel(self,-1) self.panel1.SetBackgroundColour('Goldenrod') self.bitmap1=GLPanePixelSel(self.panel1, size=(200,100)) self.bitmap2=GLPanePixelSel(self.panel1, size=(200,100)) sizer1=wx.BoxSizer(wx.HORIZONTAL) sizer2=wx.BoxSizer(wx.HORIZONTAL) sizer2.Add(self.bitmap1, 1, wx.ALL|wx.EXPAND|wx.SHAPED|wx. ALIGN_CENTER, 5) sizer2.Add(self.bitmap2, 1, wx.ALL|wx.EXPAND|wx.SHAPED|wx. ALIGN_CENTER, 5) self.panel1.SetSizer(sizer2) sizer1.Add(self.panel1,1,wx.EXPAND, 0) self.SetSizer(sizer1) sizer1.Fit(self) self.Layout() self.Maximize(False) ##-------------------------------- app = wx.PySimpleApp() frame = MyFrame(None) frame.Show(True) app.MainLoop() |
From: Roland E. <r.e...@gm...> - 2010-08-05 17:58:59
|
Mike, By reading the code you linked in your answer I am puzzle, and I don't really see how to integrate that concept into my own code without shamelessly copying some of your methods directly into my code and and adapt it :( So, have you any book recommendation that discuss such matter for someone that have not played with stuff like matrices for 15 years and never heard of quaternions until learning OpenGL? There is so much books on math for computer graphics, game development, physics, ai, ... that I don't know which one to choose. I should have maybe precised that self.thrust and self.tick are float, so I don't see how that will interact with self.orientation that is a quaternion if I have understand correctly. Thanks, Roland. Le 08/03/10 22:34, Roland Everaert a écrit : > Thanks for the example and the explanation, I will have a look at it asap. > > Roland. > > > Le 08/03/10 17:01, Mike C. Fletcher a écrit : >> On 10-08-02 04:57 PM, Roland Everaert wrote: >>> Hi, >>> >>> I am currently writing a third person view space shooter where the >>> player can freely fly in the "map". I want to define an arcade flying >>> model like in most space shooter or spaceship simulation, but I face the >>> problem of specifying the transformation right. >>> >>> For the moment, my scene contains the player space ship pointing toward >>> the negative z axis, with the camera a little bit behind it. In front of >>> the ship there are 2 objects. When I apply some thrust to the player >>> spaceship it goes forward, but if I turn the ship, it is not changing >>> direction, while the ship and the camera are turning. >>> >>> My questions are the following: >>> >>> 1. Given the code below, why have I to call the method >>> self.__chasingView() after rendering the player's ship? >>> >>> 2. How to change the direction of the ship? Am I missing some glRotate() >>> functions somewhere in the code or should I change the code of method >>> setNewPosition() in such a way that the position of the ship is computed >>> on all 3 axis? >>> >> The problem you are facing is that you want to make the motion of the >> ship (x,y,z) modify by currentrotation * motionvector. You *could* >> do that with an ever-increasing set of glRotate/glTranslate calls >> (you'd need one for every change in direction), but what you really >> want to do is to track your position in "world" space and change that >> position by currentrotationmatrix * motionvector. >> >> I normally do that with a wrapped Quaternion class in OpenGLContext. >> See OpenGLContext/move/viewplatform.py for the code that wraps it >> (particularly the relativePosition() method, on which all of the >> various forward/sideways/up/down movements are built. >> >> http://bazaar.launchpad.net/~mcfletch/openglcontext/trunk/annotate/head:/OpenGLContext/move/viewplatform.py >> <http://bazaar.launchpad.net/%7Emcfletch/openglcontext/trunk/annotate/head:/OpenGLContext/move/viewplatform.py> >>> def setNewPosition(self): >>> self.addToPosition(z=-(self.thrust * self.tick)) >>> >> that should be something like self.addToPosition( self.thrust * >> self.tick * self.orientation ) >> >> HTH, >> Mike >> -- >> ________________________________________________ >> Mike C. Fletcher >> Designer, VR Plumber, Coder >> http://www.vrplumber.com >> http://blog.vrplumber.com >> >> >> >> ------------------------------------------------------------------------------ >> The Palm PDK Hot Apps Program offers developers who use the >> Plug-In Development Kit to bring their C/C++ apps to Palm for a share >> of $1 Million in cash or HP Products. Visit us here for more details: >> http://p.sf.net/sfu/dev2dev-palm >> >> >> _______________________________________________ >> PyOpenGL Homepage >> http://pyopengl.sourceforge.net >> _______________________________________________ >> PyOpenGL-Users mailing list >> PyO...@li... >> https://lists.sourceforge.net/lists/listinfo/pyopengl-users >> |
From: Roland E. <r.e...@gm...> - 2010-08-03 20:35:10
|
Thanks for the example and the explanation, I will have a look at it asap. Roland. Le 08/03/10 17:01, Mike C. Fletcher a écrit : > On 10-08-02 04:57 PM, Roland Everaert wrote: >> Hi, >> >> I am currently writing a third person view space shooter where the >> player can freely fly in the "map". I want to define an arcade flying >> model like in most space shooter or spaceship simulation, but I face the >> problem of specifying the transformation right. >> >> For the moment, my scene contains the player space ship pointing toward >> the negative z axis, with the camera a little bit behind it. In front of >> the ship there are 2 objects. When I apply some thrust to the player >> spaceship it goes forward, but if I turn the ship, it is not changing >> direction, while the ship and the camera are turning. >> >> My questions are the following: >> >> 1. Given the code below, why have I to call the method >> self.__chasingView() after rendering the player's ship? >> >> 2. How to change the direction of the ship? Am I missing some glRotate() >> functions somewhere in the code or should I change the code of method >> setNewPosition() in such a way that the position of the ship is computed >> on all 3 axis? >> > The problem you are facing is that you want to make the motion of the > ship (x,y,z) modify by currentrotation * motionvector. You *could* do > that with an ever-increasing set of glRotate/glTranslate calls (you'd > need one for every change in direction), but what you really want to > do is to track your position in "world" space and change that position > by currentrotationmatrix * motionvector. > > I normally do that with a wrapped Quaternion class in OpenGLContext. > See OpenGLContext/move/viewplatform.py for the code that wraps it > (particularly the relativePosition() method, on which all of the > various forward/sideways/up/down movements are built. > > http://bazaar.launchpad.net/~mcfletch/openglcontext/trunk/annotate/head:/OpenGLContext/move/viewplatform.py > <http://bazaar.launchpad.net/%7Emcfletch/openglcontext/trunk/annotate/head:/OpenGLContext/move/viewplatform.py> >> def setNewPosition(self): >> self.addToPosition(z=-(self.thrust * self.tick)) >> > that should be something like self.addToPosition( self.thrust * > self.tick * self.orientation ) > > HTH, > Mike > -- > ________________________________________________ > Mike C. Fletcher > Designer, VR Plumber, Coder > http://www.vrplumber.com > http://blog.vrplumber.com > > > > ------------------------------------------------------------------------------ > The Palm PDK Hot Apps Program offers developers who use the > Plug-In Development Kit to bring their C/C++ apps to Palm for a share > of $1 Million in cash or HP Products. Visit us here for more details: > http://p.sf.net/sfu/dev2dev-palm > > > _______________________________________________ > PyOpenGL Homepage > http://pyopengl.sourceforge.net > _______________________________________________ > PyOpenGL-Users mailing list > PyO...@li... > https://lists.sourceforge.net/lists/listinfo/pyopengl-users > |
From: Mike C. F. <mcf...@vr...> - 2010-08-03 15:25:14
|
On 10-08-02 04:57 PM, Roland Everaert wrote: > Hi, > > I am currently writing a third person view space shooter where the > player can freely fly in the "map". I want to define an arcade flying > model like in most space shooter or spaceship simulation, but I face the > problem of specifying the transformation right. > > For the moment, my scene contains the player space ship pointing toward > the negative z axis, with the camera a little bit behind it. In front of > the ship there are 2 objects. When I apply some thrust to the player > spaceship it goes forward, but if I turn the ship, it is not changing > direction, while the ship and the camera are turning. > > My questions are the following: > > 1. Given the code below, why have I to call the method > self.__chasingView() after rendering the player's ship? > > 2. How to change the direction of the ship? Am I missing some glRotate() > functions somewhere in the code or should I change the code of method > setNewPosition() in such a way that the position of the ship is computed > on all 3 axis? > The problem you are facing is that you want to make the motion of the ship (x,y,z) modify by currentrotation * motionvector. You *could* do that with an ever-increasing set of glRotate/glTranslate calls (you'd need one for every change in direction), but what you really want to do is to track your position in "world" space and change that position by currentrotationmatrix * motionvector. I normally do that with a wrapped Quaternion class in OpenGLContext. See OpenGLContext/move/viewplatform.py for the code that wraps it (particularly the relativePosition() method, on which all of the various forward/sideways/up/down movements are built. http://bazaar.launchpad.net/~mcfletch/openglcontext/trunk/annotate/head:/OpenGLContext/move/viewplatform.py <http://bazaar.launchpad.net/%7Emcfletch/openglcontext/trunk/annotate/head:/OpenGLContext/move/viewplatform.py> > def setNewPosition(self): > self.addToPosition(z=-(self.thrust * self.tick)) > that should be something like self.addToPosition( self.thrust * self.tick * self.orientation ) HTH, Mike -- ________________________________________________ Mike C. Fletcher Designer, VR Plumber, Coder http://www.vrplumber.com http://blog.vrplumber.com |
From: Roland E. <r.e...@gm...> - 2010-08-02 20:57:51
|
Hi, I am currently writing a third person view space shooter where the player can freely fly in the "map". I want to define an arcade flying model like in most space shooter or spaceship simulation, but I face the problem of specifying the transformation right. For the moment, my scene contains the player space ship pointing toward the negative z axis, with the camera a little bit behind it. In front of the ship there are 2 objects. When I apply some thrust to the player spaceship it goes forward, but if I turn the ship, it is not changing direction, while the ship and the camera are turning. My questions are the following: 1. Given the code below, why have I to call the method self.__chasingView() after rendering the player's ship? 2. How to change the direction of the ship? Am I missing some glRotate() functions somewhere in the code or should I change the code of method setNewPosition() in such a way that the position of the ship is computed on all 3 axis? Below is the main code rendering the scene: glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); # /* clear the matrix */ playerShipPos = self.__player.getPosition() x, y, z = self.__player.getAngle() self.__lightVP.switchOn() glTranslate(0.0, -3.0, -20.0) glRotate(10.0, 1.0, 0.0, 0.0) self.__player.render() self.__chasingView(playerShipPos[0], playerShipPos[1], playerShipPos[2], x, y, z) for entity in self.__entities: self.__updateRadar(entity) glPushMatrix() entity.render() glPopMatrix() glFlush () - Method render() for both self.__player and entity is: glPolygonMode(GL_FRONT_AND_BACK, GL_FILL) #Load vertex List and Normals List self.vbo_vert.bind() glEnableClientState(GL_VERTEX_ARRAY) glVertexPointerf(self.vbo_vert) # Specify the vertex list to be used to draw the model self.vbo_vert.unbind() self.vbo_norm.bind() glEnableClientState(GL_NORMAL_ARRAY) glNormalPointerf(self.vbo_norm) # Specify the normal list to be used to draw the model self.vbo_norm.unbind() # Activate face culling glEnable(GL_CULL_FACE) glCullFace(GL_BACK) # Apply transformation if not(self.isPlayer): glTranslate(*self.position) glRotatef (self.x_angle, 1.0, 0.0, 0.0); glRotatef (self.y_angle, 0.0, 1.0, 0.0); glRotatef (self.z_angle, 0.0, 0.0, 1.0); start_pos = 0 # In For .. Loop for obj in self.modelData: # Set Object Material glMaterialfv(GL_FRONT, GL_SPECULAR, obj.matdata.specular) glMaterialfv(GL_FRONT, GL_SHININESS, obj.matdata.specularCoeff) glMaterialfv(GL_FRONT, GL_AMBIENT, obj.matdata.ambient) glMaterialfv(GL_FRONT, GL_DIFFUSE, obj.matdata.diffuse) # Draw object glDrawArrays(GL_TRIANGLES, start_pos, obj.nbrVertices) start_pos += obj.nbrVertices glDisableClientState(GL_VERTEX_ARRAY) glDisableClientState(GL_NORMAL_ARRAY) # vbo class usage The function I use to set the new location of the ship based on the current thrust is: def setNewPosition(self): self.addToPosition(z=-(self.thrust * self.tick)) The above method is called in the main loop before the rendering of the scene. The self.__chasingView() method is: def __chasingView(self, planex, planey, planez, pitch, heading, roll): glRotatef(roll, 0.0, 0.0, 1.0) glRotatef(heading, 0.0, 1.0, 0.0) glRotatef(pitch, 1.0, 0.0, 0.0) glTranslate(-planex, -planey, -planez) That code comes from the opengl programmer's guide with a few changes to adapt to the fact that the player's ship is looking down the negative Z axis. Hope this lengthy email doesn't break any rules of this mailing list. Thanks for your help, Roland. |
From: Ian M. <geo...@gm...> - 2010-08-01 00:06:28
|
On Sat, Jul 31, 2010 at 3:05 PM, Dirk Reiners <dir...@gm...>wrote: > All of that looks pretty straightforward. The only thing I can think of, > but > that should give a different error, is textures that are not power-of-two > size. > What are the sizes of your textures? > I hadn't even thought of that! And after some testing, it seems that's the problem. My test code can be found here: http://download577.mediafire.com/jnza7ybur4qg/ievqu4buekair6k/test_texture.zip I'm surprised at how ubiquitous using power-of-two textures must be. Basically no other applications seemed to have problems. I never had problems, so I guess I assumed it was irrelevant. Uggggh I assume I'll have to rewrite my texture code so that it can take an argument to scale surfaces to the nearest factor of two. Any other way? I know of ARB_texture_rectangle, but that sounds horrible. Blech. I hate Intel. Ian |
From: Ian M. <geo...@gm...> - 2010-08-01 00:06:06
|
On Sat, Jul 31, 2010 at 3:05 PM, Dirk Reiners <dir...@gm...>wrote: > All of that looks pretty straightforward. The only thing I can think of, > but > that should give a different error, is textures that are not power-of-two > size. > What are the sizes of your textures? > I hadn't even thought of that! And after some testing, it seems that's the problem. My test code can be found here: http://download577.mediafire.com/jnza7ybur4qg/ievqu4buekair6k/test_texture.zip I'm surprised at how ubiquitous using power-of-two textures must be. Basically no other applications seemed to have problems. I never had problems, so I guess I assumed it was irrelevant. Uggggh I assume I'll have to rewrite my texture code so that it can take an argument to scale surfaces to the nearest factor of two. Any other way? I know of ARB_texture_rectangle, but that sounds horrible. Blech. I hate Intel. Ian |
From: Dirk R. <dir...@gm...> - 2010-07-31 22:05:57
|
Hi Ian, On 07/31/2010 11:06 AM, Ian Mallett wrote: >> > Yes, although programs without extensions were crashing. OK. > Of the errors, the only one that seems even possible is: > GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound > to the GL_PIXEL_UNPACK_BUFFER target and the data would be unpacked from the > buffer object such that the memory reads required would exceed the data > store size. > It seems strange, though, because other programs don't seem to have a > problem. Here's the graphics "card" he has: > http://www.notebookcheck.net/Intel-Graphics-Media-Accelerator-950.2177.0.html That is a pretty unusual error, so that doesn't sound very probable, yes. > My gut feeling would guess you're using a texture format that the card >> doesn't know, try using the generic GL_RGB/GL_RGBA instead of the >> bit-specific ones. >> > I am. OK. >> We might be able to help you better if we could see your actual code. >> > I was trying to avoid it, as it is a general class of functions that are > failing. Some of my newer code is also too flexible to be immediately > readable. Here's some really old code that fails: > def Texture(surface,filters): > data = pygame.image.tostring(surface,"RGBA",True) > width,height = surface.get_size() ... > > glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,data) > return texture All of that looks pretty straightforward. The only thing I can think of, but that should give a different error, is textures that are not power-of-two size. What are the sizes of your textures? Dirk |
From: Ian M. <geo...@gm...> - 2010-07-31 16:06:58
|
On Fri, Jul 30, 2010 at 11:16 PM, Dirk Reiners <dir...@gm...>wrote: > As a first start I'd look at the manpages (e.g. > http://www.opengl.org/sdk/docs/man/xhtml/glTexImage2D.xml). At the end it > lists all the possible reasons for error codes, see if one of those is true > for you. Unfortunately those manpages don't cover extensions... > Yes, although programs without extensions were crashing. Of the errors, the only one that seems even possible is: GL_INVALID_OPERATION is generated if a non-zero buffer object name is bound to the GL_PIXEL_UNPACK_BUFFER target and the data would be unpacked from the buffer object such that the memory reads required would exceed the data store size. It seems strange, though, because other programs don't seem to have a problem. Here's the graphics "card" he has: http://www.notebookcheck.net/Intel-Graphics-Media-Accelerator-950.2177.0.html My gut feeling would guess you're using a texture format that the card > doesn't know, try using the generic GL_RGB/GL_RGBA instead of the > bit-specific ones. > I am. > We might be able to help you better if we could see your actual code. > I was trying to avoid it, as it is a general class of functions that are failing. Some of my newer code is also too flexible to be immediately readable. Here's some really old code that fails: def Texture(surface,filters): data = pygame.image.tostring(surface,"RGBA",True) width,height = surface.get_size() texture = glGenTextures(1) glBindTexture(GL_TEXTURE_2D,texture) if filters == None: filters = [] if "filter" in filters: glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR) else: glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) if "mipmap" in filters: if "mip filter 0" in filters: glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_NEAREST) elif "mip filter 1" in filters: glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST) elif "mip filter 2" in filters: glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST_MIPMAP_LINEAR) elif "mip filter 3" in filters: glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR) glPixelStoref(GL_UNPACK_ALIGNMENT,1) gluBuild2DMipmaps(GL_TEXTURE_2D,3,width,height,GL_RGBA,GL_UNSIGNED_BYTE,data) else: if "filter" in filters: glTexParameterf(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR) else: glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,width,height,0,GL_RGBA,GL_UNSIGNED_BYTE,data) return texture Thanks, Ian |
From: Ian M. <geo...@gm...> - 2010-07-31 06:07:00
|
Hi, So, my laptop has got a decent graphics card, processor, RAM, etc. Using it, I developed several programs using textures, shaders, etc. My brother, with a netbook, wants to run some of these programs. The computer, which is available <a href=" http://www.msimobile.com/level3_productpage.aspx?cid=3&id=127">here</a>, has an Intel integrated graphics chipset. I understood that such graphics cards have poor support for GLSL, but upon running the (shader-less) code on his Intel hardware, all of my texturing code failed (on the glTexImage2D(...) call, with invalid operation), whereas it works perfectly on my computer, and on several others, Mac, PC, and Linux, and NVidia and ATI. The code is written in Python, and for my test program, I wasn't doing anything fancy, just setting up a standard OpenGL 2D texture. Through games that work on his computer, I'm pretty sure that (DirectX?) texturing works (Motocross Madness) and that OpenGL texturing works (Tux Racer). I'm setting up the texture with standard OpenGL routines (and after I've set up a context, etc.). The glTexImage2D() calls give invalid operations no matter what. I'm passing them string buffers with GL_UNSIGNED_BYTE: pygame.image.tostring(data,"RGB",True) So . . . I don't think it's any particular setup; all the texturing code is failing. Do PyOpenGL textures work on Intel cards? Or is this something I don't know about? Or what? Ian |