Re: [PyOpenGL-Users] Odd framebuffer error
Brought to you by:
mcfletch
From: Alejandro S. <as...@gm...> - 2010-11-30 20:17:45
|
On Tue, Nov 30, 2010 at 5:40 PM, Derakon <de...@gm...> wrote: > I have a program that displays large numbers (thousands) of textures, > with the user able to pan and zoom about the collection. The sheer > texture count is causing slowdown, so I'm working on adding > framebuffers which collect many of the textures at low detail levels, > like taking a photo of a group of photos. Since the individual > textures never move relative to each other, I can just display the one > pre-rendered texture instead whenever the user is sufficiently > zoomed-out. > > I made a test program that works fine (on my OSX laptop), but I'm > running into an error when I try to adapt the code to the main program > (on a considerably more powerful Windows 7 box). Each small texture is > contained in a Tile class instance, and a single Tile can be placed > and oriented arbitrarily. Meanwhile, the entire working area is tiled > with MegaTile instances; Tiles are pre-rendered onto MegaTiles using > framebuffers as needed. However, I'm getting a 1286 error when I call > glEnd() after rendering a Tile. From what I can tell this means I > didn't set up the framebuffer properly, but it looks fine to me. I > must be missing something. > > Here's the prerendering code in MegaTile: > > glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, self.texture) > glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, > GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, > self.texture, 0) > > glViewport(0, 0, megaTilePixelSize, megaTilePixelSize) # > megaTilePixelSize is 512 > glMatrixMode(GL_PROJECTION) > glLoadIdentity() > glOrtho(-.375, viewer.m_w - .375, # m_w and m_h are the > width/height of the window > -.375, viewer.m_h - .375, > 1, -1) > glScalef(megaTileScaleFactor, megaTileScaleFactor, 1) # > megaTileScaleFactor is 1/21.0 > glTranslatef(-self.pos[0], -self.pos[1], 0) > glMatrixMode(GL_MODELVIEW) > > glEnable(GL_TEXTURE_2D) > for tile in newTiles: # Tile instances to render to MegaTile > tile.render(viewBox) > glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0) > > > Here's Tile.render(): > > def render(self, viewBox): > if not self.intersectsBox(viewBox): > return > > glColor3f(1, 1, 1) > > theta = N.pi/180 * self.rotation > c = N.cos(theta) > s = N.sin(theta) > (w,h) = self.size > cw = c*w > sw = s*w > ch = c*h > sh = s*h > > img = self.textureData > pic_ny, pic_nx = img.shape > tex_nx,tex_ny = getTexSize(pic_nx,pic_ny) > picTexRatio_x = float(pic_nx) / tex_nx > picTexRatio_y = float(pic_ny) / tex_ny > > (x,y) = self.pos > > glBindTexture(GL_TEXTURE_2D, self.texture) > glBegin(GL_QUADS) > glTexCoord2f(0, 0) > glVertex2f(x, y) > glTexCoord2f(picTexRatio_x, 0) > glVertex2f(x + cw, y + sw) > glTexCoord2f(picTexRatio_x, picTexRatio_y) > glVertex2f(x + cw - sh, y + sw + ch) > glTexCoord2f(0, picTexRatio_y) > glVertex2f(x - sh, y + ch) > glEnd() # This is where the error triggers > > > Any ideas what could be causing this? Suggestions on what I should be > researching to figure it out? > If I understand correctly, this code is working on your Mac. Have you checked the OpenGL version you have available on the Win7 machine? Mac OS X is stuck on OpenGL 2.1, so using Framebuffers as extensions is okay, but if the Win7 machine has OpenGL 3.0 or greater, you might want to look into using "native" Framebuffer support. Good luck! Alejandro.- -- Alejandro Segovia Azapian Director, Algorithmia: Visualization & Acceleration http://web.algorithmia.net |