Window = glfwCreateWindow(1920, 1080, "OpenGL is an ******", NULL, NULL) įprintf(stderr, "Failed to open GLFW window. GlfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE) GlfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 4) GlfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4) Here is (what i think would be) the relevant code:įprintf( stderr, "Failed to initialize glfw\n") I should note as well that if I change the Fragment shader color value to vec4 (it's currently set to a vec3) and include an alpha color (set to anything between 0.1 and 1) the glBLendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA) will display the sprite, but (perhaps predictably) the entire sprite is semi-transparent, though the transparent layer of the sprite appears to be black(just slightly transparent) and, thus, not set correctly. The one thing I can't seem to successfully code is having the sprite display without the background and not be semi-transparent itself. I've tried calling the glEnable and glBlendFunc in various places. Either nothing is displayed at all, the transparent layer is displayed as completely black, or this state, where it is semi-transparent. I've attempted to display the sprite using GL_DECAL, as well as trying to set the alpha_state and have ended up with similar results. Things actually appear to display correctly, however, while the transparent layer is completely transparent, the rest of the sprite appears semi-transparent as well. GlBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) I'm using c++, codeblocks, Ubuntu 14.04, glfw3, freeImage (and a little loader found on this forum for png files, included in the code below), nvidia 560 ti, To the best of my knowledge, the png file(created in gimp) does contain the alpha layer and was saved correctly.Īm I failing to set the OpenGL Alpha layer correctly, or perhaps calling the BlendFunc in the wrong location? Perhaps I'm misunderstanding the BlendFunc. If you are making a font or some other very vector like or 8bit pixel like art you probably want to use PNG. You want an alpha channel on top of your RGB colors. Simple color textures are great for JPEG. Any help would be genuinely and greatly appreciated As I'm uncertain where I'm going wrong, I'm uncertain what information you may need, but I'll try to include the essentials, an image of the semi-transparent sprite is included. In general you should probably use JPEGs where you can because you can make them very small. I've searched this forum rather thoroughly, but every solution I've found has seemed not to work for me. I have spent the better part of a week attempting to properly load a png image,bind it to a texture, set it to an object and have the transparent layer stay transparent while rendering the rest of the sprite(like a decal would appear, or a billboarded sprite). This is my first post here (so go easy on me.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |