Im wondering if it is possible to have transparency when you render to a texture. I.E You render a cube which is solid, but every other pixel would be transparent.
Registriert: Do Dez 05, 2002 10:35 Beiträge: 4234 Wohnort: Dortmund
Depends on what kind of render to texture you are using? If you are using FrameBufferObjects i think its no problem. With pBuffers or normal copy from framebuffer you have to create an context with alphachannel. And you should verify this. The drivers have the right to ignore your wish. But i prefer the use of FrameBufferObjects. If its possible. Else you have to set the Alpha Paramater of the PixelFormatDescription while your contextcreation (CreateRenderingContext in the dglOpenGL.pas). After you have choosen your pixelformat you have to call DescribePixelformat and read all values of the fomat. If there is an alphavalue you have an alphachannel. If there isn't an alphavalue the driver ignores you.
Registriert: Do Dez 05, 2002 10:35 Beiträge: 4234 Wohnort: Dortmund
Thats right. Because you have to attach real textures to the FBO. So OpenGL renders directly into textures and the workflow is much better for the asynchronous GPU.
But FBOs has higher requirement for OpenGL. The first version of OpenGL they support FBOs in core is 3.0. Before you have to use the Extension GL_EXT_framebuffer_object. This is so around OpenGL 2.0. I think on moderate hardware this shouldn't be an problem.
It would proberly be best if i implemented all 3 methods. My fathers ATI MOBILITY RADEON 7000 IGP (Which is the worst GFX card in my house) doesn't support FBO's but should support PBuffers. Intel cards iirc can't do pbuffers right even tho they have the extention. UFO Afterlight which iv helped maintain wouldn't work with intel cards due to the lack of WGL_ARB_pixel_format which iirc ment that a PBuffer couldn't be setup... Meh been months since i tryed to modify the code to allow Intel GFX cards to work(I don't have an Intel Card to test with).
Well and having a 4th method that would come into effect if alpha channel failed to be setup.
Note: Even if i wanted to use OpenGL 3 (Which i don't plan on doing until say 10 years down the line when all GFX Cards have OpenGL 3) my GFX Card is a Geforce 5900XT (You can all laugh now).
Registriert: Do Dez 05, 2002 10:35 Beiträge: 4234 Wohnort: Dortmund
I think it's not necessary to implement all three ways. It should be enough if you implement the classic copying from renderbuffer and the new version with FBOs. pBuffers are only a few better than copying from renderbuffer. But you have an seperate context and you need to activate him every time you wants to update the texture. So you have much more work and nearly no (or few) performance changes. And for copy from renderbuffer make sure you have activated the alphachannel and the driver listens to you.
PS: I also dont plan to support OpenGL 3.0 in the next few years. It's not necessary for the projects i do. 3.0 is really overpowered for this.
Iv implemented FBO (Yep took a while for me to get round to it). Im just posting to note some things which GameDev.Net's FBO Tutorial which i used missed out(Incase anyone falls into the same problems).
1. When it comes to begining the FBO render you need to set the glclearcolor to have 0 for the Alpha or you don't get any transparency. (Granted the tutorial wasn't about transparent ones, tho it does use GL_RGBA for the texture)
2. You also have to call glClear after the glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, &fbo) call or the FBO's Texture will always remain black.
Below is some code snipits from the texture class i made(It won't compile without modifications, like a header bit for the TTexture ):
Code:
function FBOStatusToStr(Status :Cardinal):String;
begin
case Status of
GL_FRAMEBUFFER_COMPLETE_EXT : Result :='GL_FRAMEBUFFER_COMPLETE_EXT';
GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT : Result :='GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT';
GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT : Result :='GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT';
GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT : Result :='GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT';
GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT : Result :='GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT';
GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT : Result :='GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT';
GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT : Result :='GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT';
GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT : Result :='GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT';
GL_FRAMEBUFFER_UNSUPPORTED_EXT : Result :='GL_FRAMEBUFFER_UNSUPPORTED_EXT';
GL_FRAMEBUFFER_STATUS_ERROR_EXT : Result :='GL_FRAMEBUFFER_STATUS_ERROR_EXT';
GL_FRAMEBUFFER_BINDING_EXT : Result :='GL_FRAMEBUFFER_BINDING_EXT';
GL_RENDERBUFFER_BINDING_EXT : Result :='GL_RENDERBUFFER_BINDING_EXT';
GL_MAX_COLOR_ATTACHMENTS_EXT : Result :='GL_MAX_COLOR_ATTACHMENTS_EXT';
GL_MAX_RENDERBUFFER_SIZE_EXT : Result :='GL_MAX_RENDERBUFFER_SIZE_EXT';
GL_INVALID_FRAMEBUFFER_OPERATION_EXT : Result :='GL_INVALID_FRAMEBUFFER_OPERATION_EXT';
Mitglieder in diesem Forum: 0 Mitglieder und 2 Gäste
Du darfst keine neuen Themen in diesem Forum erstellen. Du darfst keine Antworten zu Themen in diesem Forum erstellen. Du darfst deine Beiträge in diesem Forum nicht ändern. Du darfst deine Beiträge in diesem Forum nicht löschen. Du darfst keine Dateianhänge in diesem Forum erstellen.