so I have a problem with the alpha value in my texture. Basically the pixmap is set all black then I drew a filled circle with the alpha value set to 0 in order for the area of the circle it to be transparent (yes I set blending to none), then I created the texture out of the pixmap like this:
Texture myTexture = new Pixmap(TransparentCirclePixmap); // this constructor takes a pixmap
if I draw this texture the circle is not transparent it has a color that is not the background in my game.
so basically what i want is to draw a transparent circle in my pixmap and create a texture from that pixmap and when I draw the texture to the screen the interior of the circle displays whatever was in the background of my game.
Related
I want to use openGL to draw a hollow sphere. The material properties of sphere is different for front and back surfaces. Now I want to mask the sphere with a text, so that the inner surface becomes visible from the text area. I am not able to understand how to achieve it.
Draw the sphere twice:
glCullFace(GL_FRONT), then draw sphere. This will put all back-facing triangles in the depth and color buffers.
glCullFace(GL_BACK), bind text texture, enable alpha test, draw sphere. Where the alpha test fails the color buffer won't be updated and you'll be able to "see through" to the inside of the sphere.
Is there any way to get drawed pixel color (from backbuffer, not current drawing pixel)?
For example:
I'm drawing a rectangle with texture and then drawing a circle (in blue color) on this rectangle. If I use pixel shader on a circle, is there any way to get current pixel color from backbuffer (pixel from rectangle)?
I think you want to get the color of the pixel from the frame buffer for that use glReadPixels() which will return the pixel data from the frame buffer.
https://www.opengl.org/sdk/docs/man2/xhtml/glReadPixels.xml
I am using opengl and c++ doing image processing. The idea is simple, I will load an image, draw a polygon by clicking and then apply an effect (desaturation for instance) only to the pixels in the interior of the polygon shape just created.
Can anyone give me any direction on how to limit the effect to the pixels within the interior of the polygon? Loading the image and drawing the polygon is not a problem
Supposing the following situation :
The picture on which you want to apply the effect takes the whole screen
The picture is rendered using opengl , probably through a simple shader, with the picture passed as a texture
You can do the following approach :
consider the screen as being a big texture
you draw a polygon, which will be rendered on top of the rendered texture
inside the polygon's vertices insert the uv's coresponding to the 2D coordinates on the screen (so from screen space to uv space (0 , 1 ) )
draw the picture normaly
on top of the picture draw your polygon using the same picture as texture, but with a different shader
So instead of trying to desaturate a specific region from your picture, create a polygon on top of that region with the same picture, and desaturate that new polygon.
This would help you in avoiding the stencil buffer.
Another approach would be to create the polygon, but draw it only on the stencil buffer, before the picture is drawn.
So in openGL when I call glClearColor() is there a way to set the background color to a texture instead of setting it just to a static color? Or is there another method which can do that besides glClearColor()?
You cannot clear the screen to a texture. You can:
Draw a textured quad the size of the screen.
Blit a texture from an FBO onto the screen.
Either one will work.
I need to plot a real time graph keeping the background an image. Let's say I am plotting the graph with a red color.
But the logic I use for plotting is drawing small lines using painter.drawline, where painter is a pixmap painter. Then I am constantly drawing this pixmap using a painter to parent widget on a timer timeout() event. So it appears the updated Image (which is the graph) gets plotted in the Gui.
The pixmap is black in background and plotting pen color is red, So when it reaches the end of screen width, I have to start drawing the graph from position 0, but from the second cycle onwards I have to fill the previously drawn pixels (not the entire pixmap, just a rect of width few pixels and height, height of pixmap) with black color.
But now I need to keep a background image, and draw a graph over it. So the fillling with black color doesn't do, as I have to keep a background an image. So how can I plot a graph over an image like aforementioned?
Is there any way to blend two images such that the pixels only having a particular color (red) in source image is blended/replaced with corresponding pixels in destination image?
Keep previously drawed Ys in memory than fill exactly the same pixels by corresponding background. It's faster and much more reliable.