OpenGL buffers
Hi,
Does anybody know how to draw bitmaps offscreen(into VRAM) in OpenGL, then copy them at speed to the main screen without using the AUX buffers. Aux buffer implementation seems to be erratic at best,(what is the point if they don''t work on most G/Cards?) on my 128MB 5600 ultra, the glDrawBuffer(GL_AUX1) gets ignored, and glGetIntegerv(GL_AUX_BUFFERS, GLint) causes a crash. Is there any other way to do this from within OpenGL? If not OpenGL, how else can this be done? I''m having to copy a fairly large number of 24bit pixels from processor RAM to VRAM every frame, and it seems such a waste......
Russell K
What about PBuffer / Render-to-texture? What exacly do you need to do. If you tell more about it, we can maybe find another way around it.
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Thanks for your reply,
I''m writing a terrain based game, and the bitmap is a map / low rez overview of the the terrain(calculated once on init). At the moment I''m using glDrawPixels to draw the entire map, but I''m aware that this is quite inefficient compared to if I could hold the map in VRAM and use glCopyPixels or something like this. Also the terrain is about to expand to 8* the size, so I actually want to draw a portion of the map, and I haven''t been able to do this without pixel corruption unless I copy the portion to a smaller bitmap, then draw that. This means a RAM to RAM copy, then a RAM to VRAM copy every frame. The map gets altered gradually during the game, so I will need to be able to alter individual pixels while it is in VRAM.
GLubyte map[mapSize][mapSize][3];
void drawMap( short posX, short posY )
{
GLubyte smallMap[smallMapSize][smallMapSize][3];
for( short x=0; x for( short y=0; y for{ short n=0; n<3; n++ }{
smallMap[x][y][n]=
map[x+posX-offset][y+posY-offset][n]
}
}
}
glRasterPos2i( mapPosX, mapPosY );
glDrawPixels(smallMapSize,smallMapSize,GL_RGB,GL_UNSIGNED_BYTE, GL_RGB, GL_UNSIGNED_BYTE, smallMap );
}
This is roughly what I''ve got for displaying a portion of the map, you can see that this is not very efficient. The large map will be 512*512 pixels, and the displayed map is 128*128 pixels.
Russ
I''m writing a terrain based game, and the bitmap is a map / low rez overview of the the terrain(calculated once on init). At the moment I''m using glDrawPixels to draw the entire map, but I''m aware that this is quite inefficient compared to if I could hold the map in VRAM and use glCopyPixels or something like this. Also the terrain is about to expand to 8* the size, so I actually want to draw a portion of the map, and I haven''t been able to do this without pixel corruption unless I copy the portion to a smaller bitmap, then draw that. This means a RAM to RAM copy, then a RAM to VRAM copy every frame. The map gets altered gradually during the game, so I will need to be able to alter individual pixels while it is in VRAM.
GLubyte map[mapSize][mapSize][3];
void drawMap( short posX, short posY )
{
GLubyte smallMap[smallMapSize][smallMapSize][3];
for( short x=0; x for( short y=0; y for{ short n=0; n<3; n++ }{
smallMap[x][y][n]=
map[x+posX-offset][y+posY-offset][n]
}
}
}
glRasterPos2i( mapPosX, mapPosY );
glDrawPixels(smallMapSize,smallMapSize,GL_RGB,GL_UNSIGNED_BYTE, GL_RGB, GL_UNSIGNED_BYTE, smallMap );
}
This is roughly what I''ve got for displaying a portion of the map, you can see that this is not very efficient. The large map will be 512*512 pixels, and the displayed map is 128*128 pixels.
Russ
Just put your full map in texture then render a part of it as textured quad in ortho mode. I would stay away form glDrawPixels as it is way to slow for anything usefull. And if your map is higher than max supported texture size of graphic card (2048 is about standard max size now) then just chop it up in let''s say 512x512 chunks. And you have no more RAM-VRAM transfers
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement