So I have a background line drawing, black and white. I want to be able to draw over this, keeping the black lines in there, and drawing only where it is white. I can do this by using
glBlendFunc(GL_DST_COLOR, GL_ONE_MINUS_SRC_ALPHA);
And the black stays black and white gets whatever color I want. However in the white areas, I want to be able to draw some color, pick to another color and then blend. However this doesn't work because the blend function is messed up.
So what I was thinking is having a linedrawing framebuffer, and a user-drawing framebuffer. The user draws into the userdrawing framebuffer, with a different blending, and then I switch blending options and draw into the linedrawing framebuffer. But i don't know enough OpenGL to say whether or not this will work or is a stupid idea.
Thanks a lot
If your drawing is transparent in the white regions, you can do this: Draw your colored areas first and then the line drawing over them, using the standard GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA blend.
Related
I have tried various blend modifications to no avail....
If you use a darker color in GLPaint sample this happens, link to image attached:
http://www.studionu.nu/files/GLPaint_dark_color.png
As you can see , the "M" stands out even after painting over the image.
Does anybody have a clue as to what is going on here and how to fix it?
Thanks
I am using glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); (premultiplied)
and I tried glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
EDIT: here is the file based on GLPaint for simplicity sake.
I have an example of the code which is a problem in a copy of GLPaint, apples basic drawing app. Here is the link..... Maybe you could look at it. I have overidden the color change function so that it starts with red and changes to dark red when you select any of the colors.....
http://www.studionu.net/files/GLPaint.zip
It's likely because of the blending mode selected, i can't remember the specifics, but it looks like your using multiply style of blending, where brighter colours shine through darker ones.
Choose a different Blending method so that the new colour is the newly applied colour, not a combination of two colours
Edit:
OpenGL Blending Options:
http://pyopengl.sourceforge.net/documentation/manual/glBlendFunc.3G.html
I currently have a texture serving a font, that is on the topmost (last) render in OpenGL for the iPhone. The texture is white glyph with a transparent surround. My aim is to have another color overlayed on the texture, effectively changing the font color.
Using the code below I can make a solid color on the texture, provided the alpha is set to 255. My aim is to have a progressive color fade out, so my aim is to display the color (0,0,255,127). This should be a partially transparent blue. However I have tried many times with glTexEnv() settings and cannot seem to make a non-solid color overlay.
glBlendFunct(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, fontTexture);
glColorub(0,0,255,255);
...
glDrawElements(...);
I have tried the suggestions at the OpenGL wiki page http://www.opengl.org/wiki/Texture_Combiners, under the title of "Example : Blend tex0 and tex1 based on alpha of tex0". Also I have tried the idea found here OpenGL ES 1.1: How to change texture color without losing luminance?.
If there any setup I can get to make the color (0,0,255,127) present, without losing the outline of the font/character?
PS. Another idea was to pass a pre-multiplied alpha color (such as (0,0,255*(127/256),127)) for the preceding example, but this seems not too elegant.
EDIT: Just to clarify, I intend for the character texture to retain full opacity, just to color overlay to change. Thus the example should change from full blue to full white.
I think you have to change glBlendFunc parameters (BTW there is a typo in glBlendFunct).
Take a look at this:
http://pyopengl.sourceforge.net/documentation/manual/glBlendFunc.3G.html
For me setting it to:
glEnable(GL_BLEND);
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
works.
Hope it helps...
I have a drawing function in my iOS 5 app that draws a map of textured hexagons. I'm trying to implement color picking to make the hexagon selection easier, so I built another drawing function that draws the hexagons in various solid colors. Each of these runs fine as long as I never call the alternate function.
The problem happens when I try and draw the solid color map at any point after I've drawn the textured hexagon map - even in different render loops. I am using
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
when drawing the solid color map, and
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
when drawing the textured map.
But it seems like the texture state is staying active and preventing the solid colors from drawing correctly. As far as I can tell, it's trying to draw the solid colors as textures, even though I've disabled that state. Without any bound texture, they show up blank.
Is there some other function I need to call to successfully switch between color and texture modes?
Ok, figured it out. I had to call
glDisable(GL_TEXTURE_2D);
in addition to
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
I asked this question on the Graphic Design site, but it includes a programming component that might be better answered here.
Specifically, I have a bunch of photographic crayon images. I would like to remove the color from one to produce a neutral image that I can load into an iPhone app that I'm writing and dynamically color. The crayon images have dark regions (shadows) and light regions (shine) which I would like to preserve. I will be dynamically coloring it with many different colors, ranging from white to rainbow colors to black.
My first inclination is to turn the image into a grayscale image and then somehow turn the color channel into an alpha channel, and change the color of all pixels to black. Then I could use it as a mask. However, this would only preserve the shadows, and I would lose all the highlights.
Any ideas?
Two options come to mind:
Make a grayscale version that could be tinted as you said, with the shadows and highlights simply white and gray.
Make an outline, i.e. an image with alpha that had 0% opacity in the colored parts, say 10% white over the highlights, 10% black on the shadows, and 100% black/dark gray for the lines/edges. The idea being that you could put any color under the outline and it would look right.
This is a follow-up of this question on here
http://iphonedevelopment.blogspot.com/2010/02/drawing-hud-display-in-opengl-es.html
It tackles on the HUD (heads up display) which is based on this tutorial >
OpenGL ES displaying HUD display has no color on top of textured 3D objects
I wanted to set the "Text" in color BLACK, but it is more complicated than what I thought.
Setting it to some other color other than black "glColor4f(0.0, 0.0, 0.0, 1.0);" is just fine.
I assume that the culprit must be in the Blending function "glBlendFunc (GL_ONE, GL_ONE);"
I experimented a lot of combinations with no luck. Has anyone experimented on this one on top of textured 3D in the backgrounds working?
The answer is here!
Change in the Texture2D classes and change stuff like Gray into RGB and the sizes of the allocations, plus a shawdow capability
http://majicjungle.com/blog/?p=191