Jump to content

Using OpenGL commands to write to buffers


Pixel Perfect
 Share

Recommended Posts

I've seen code in the past (from Masterxilo I seem to recollect) which allowed the use of openGL commands to write to 2D and 3D space but from recollection this appeared to be writing to the backbuffer and normally took place after all the Leadwerks rendering had taken place. Is it possible to write to any buffer using openGLcommands?

 

What I'm looking to do ideally is write a texture created in memory to the background world and create a series of textured triangles to be rendered over it at this stage. Basically integrate in an already existing openGL sky rendering system. So I need access to Leadwerks framewerk buffers via openGL.

 

Any advice/help would be appreciated.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Are you using any kind of framework that handles drawing to the back-buffer? If so, then you can probably locate the part of the code where it clears the back-buffer and insert a call to your own openGL functions.

 

Using SetBuffer() will work for openGL commands, you might need to do a bit of housekeeping, like inserting

 

SetBuffer(outputBufferMadeWithLE) ;
glDisable(GL_BLEND); // OR SetBlend(0);
glPushMatrix() ;
glOrtho(0, 512, 512, 0, 1, 10); // set for a 512x512 buffer
glMatrixMode(GL_PROJECTION) ;
glLoadIdentity();

CallMySkyCodeHere();

glPopMatrix();

 

So there shouldn't be much to do. It can get a little upset if you change OpenGL states and don't put them back the way LE is expecting. So you might want to bookend your custom part with the state push/pop commands.

 

Other than that you should be fine to do what you want to do.

6600 2.4G / GTX 460 280.26 / 4GB Windows 7

Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT

Tricubic Studios Ltd. ~ Combat Helo

Link to comment
Share on other sites

Are you using any kind of framework that handles drawing to the back-buffer?

Yes, I'm using a slightly modified version of the original C++ Framewerk code.

 

 

 

Using SetBuffer() will work for openGL commands, you might need to do a bit of housekeeping

Excellent, that's really good news. Thanks for your advice, I'll have a play with this.

Intel Core i5 2.66 GHz, Asus P7P55D, 8Gb DDR3 RAM, GTX460 1Gb DDR5, Windows 7 (x64), LE Editor, GMax, 3DWS, UU3D Pro, Texture Maker Pro, Shader Map Pro. Development language: C/C++

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...