• 9
• 9
• 9
• 10
• 10
• ### Similar Content

• Good evening everyone!

I was wondering if there is something equivalent of  GL_NV_blend_equation_advanced for AMD?
Basically I'm trying to find more compatible version of it.

Thank you!

• Hello guys,

How do I know? Why does wavefront not show for me?
I already checked I have non errors yet.

And my download (mega.nz) should it is original but I tried no success...
- Add blend source and png file here I have tried tried,.....

PS: Why is our community not active? I wait very longer. Stop to lie me!
Thanks !

• I wasn't sure if this would be the right place for a topic like this so sorry if it isn't.
I'm currently working on a project for Uni using FreeGLUT to make a simple solar system simulation. I've got to the point where I've implemented all the planets and have used a Scene Graph to link them all together. The issue I'm having with now though is basically the planets and moons orbit correctly at their own orbit speeds.
I'm not really experienced with using matrices for stuff like this so It's likely why I can't figure out how exactly to get it working. This is where I'm applying the transformation matrices, as well as pushing and popping them. This is within the Render function that every planet including the sun and moons will have and run.
if (tag != "Sun") { glRotatef(orbitAngle, orbitRotation.X, orbitRotation.Y, orbitRotation.Z); } glPushMatrix(); glTranslatef(position.X, position.Y, position.Z); glRotatef(rotationAngle, rotation.X, rotation.Y, rotation.Z); glScalef(scale.X, scale.Y, scale.Z); glDrawElements(GL_TRIANGLES, mesh->indiceCount, GL_UNSIGNED_SHORT, mesh->indices); if (tag != "Sun") { glPopMatrix(); } The "If(tag != "Sun")" parts are my attempts are getting the planets to orbit correctly though it likely isn't the way I'm meant to be doing it. So I was wondering if someone would be able to help me? As I really don't have an idea on what I would do to get it working. Using the if statement is truthfully the closest I've got to it working but there are still weird effects like the planets orbiting faster then they should depending on the number of planets actually be updated/rendered.

• Hello everyone,
I have problem with texture

• Hello everyone
For @80bserver8 nice job - I have found Google search. How did you port from Javascript WebGL to C# OpenTK.?
I have been searched Google but it shows f***ing Unity 3D. I really want know how do I understand I want start with OpenTK But I want know where is porting of Javascript and C#?

Thanks!

# OpenGL Rendering Gui Or Hud In A Separate Framebuffer

This topic is 627 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hello, I have been trying to render the HUD for my game to a separate FrameBuffer so that I can apply my own shader effects to it that are separated from the 3D scene. So far it works fine with entirely opaque objects.

The problem is that I am having transparency issues. I use glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); with glClearColor(0.0f, 0.0f, 0.0f, 0.0f);, which creates a transparent black background for the HUD FrameBuffer before rendering the HUD.

Whenever I render a transparent HUD element to the FrameBuffer, the black gets mixed in with the original colors of the element, which is not what I want. It ends up making the HUD elements look darker than they are supposed to be.

I can change the color for glClearColor() and get different colored results, so I know that that is the root of the problem. I decided to use the blend function:

glBlendFuncSeparate(/*For color*/ GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
/*For alpha*/ GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

which was requested by someone who had a similar issue. Unfortunately it isn't working for me. I am afraid that I might need to do something involving stencil buffers and rendering the elements twice using two separate blend functions to get it to work, but I want to try to avoid that and find a simpler solution. Can anyone give me any pointers?

Here is the function I use for rendering GUI objects (some irrelevant code emitted):

void RenderingEngine::RenderGuiObjects()
{
GuiRenderTheme* pCurGuiRenderTheme;
ComponentMap* currentComponentMap = nullptr;
glm::vec4* uvOffsetAndScale;

glEnable(GL_DEPTH_TEST);

//Prepare the gui drawing frame buffer for gui rendering.
glBindFramebuffer(GL_FRAMEBUFFER,
mpDrawBufferGui->GetFrameBufferObject());

glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA,
GL_ONE, GL_ONE_MINUS_SRC_ALPHA);

//todo: render by layer.

for(unsigned int layer = 0; layer < 8; layer++)
{
for(unsigned int i = 0; i < mpGuiRenderingComponents->size(); i++)
{
mpActiveRenObjs->pCurRenComp = mpGuiRenderingComponents->at(i);

if(mpActiveRenObjs->pCurRenComp->GetPaintAlgorithmLayer() == layer)
{
pCurGuiRenderTheme = mpActiveRenObjs->pCurRenComp->GetGuiRenderTheme();

mpActiveRenObjs->pCurRenPosComp =
mpActiveRenObjs->pCurRenComp->GetTransformComponent();

glBindVertexArray(
*pCurGuiRenderTheme->pMesh->GetVertexArrayPtr());

uvOffsetAndScale =
mpActiveRenObjs->pCurRenComp->GetPointerToUVOffsets();

SendUniform(UNIFORM_MAT4F, "worldMatrix",
mpActiveRenObjs->pCurRenPosComp->GetRawPtrWorldMatrix());
SendUniform(UNIFORM_MAT4F, "viewMatrix",
&mpImportantMatrices->guiViewMatrix);
SendUniform(UNIFORM_MAT4F, "projectionMatrix",
&mpImportantMatrices->guiProjectionMatrix);
SendUniform(UNIFORM_VEC4F, "uv1OffsetAndScale",
uvOffsetAndScale);

SendUniform(UNIFORM_1F, "opacity",
mpActiveRenObjs->pCurRenComp->GetOpacity());
SendUniform(UNIFORM_1F, "hasTransparencyTexture", 0.0f);

SendUniform(UNIFORM_1I, "diffuse", 0);

ChangeTextureSlot(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D,
pCurGuiRenderTheme->pMaterial->GetTextures()->at(0)->
textureObject);

glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

glDrawArrays(GL_TRIANGLE_FAN, 0, 4);

}
}
}
}


Also this is made with OpenGL 4.2 with c++ and compiled with MinGW.

Edited by Solid_Spy

##### Share on other sites

Keyphrase is "associative alpha blending", with the keyword in the keyphrase being "associative".

##### Share on other sites

First of all you need to take a look into fragment shader (that one that draws your hud) you need to determine whenever fragment is transparent or not (and you write it as alpha value) after drawing that into fbo texture, you use single additive blending


glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

//bind fbo texture

glDisable(GL_BLEND);
glEnable(GL_DEPTH_TEST);



anyway i dont see that you define viewport assumming that your fbo size is the ogl window size that could not work, better to use power of two texture size and then trim the texture

Edited by WiredCat