What is the purpose of border in texImage2D? - webgl

The docs for texImage2D() state this about border:
A GLint specifying the width of the border. Must be 0.
If the border must be 0... what's the purpose of this parameter?

as visibleman mentioned, it's mostly left over from old deprecated OpenGL. It's deprecated in modern OpenGL
from the OpenGL 4.5 spec section 8.5.3
An INVALID_VALUE error is generated if border is non-zero.

Related

What's the default value of BlendEquation?

I'm reading source code of a WebGL app and found it doesn't use blendEquation. But it has enabled BLEND and set blendFunc. And blending is working.
Does blendEquation have a default setting or value? What is it?
See original OpenGL ES 2.0 specification or reference pages it is clearly says that
Initially, both the RGB blend equation and the alpha blend equation
are set to GL_FUNC_ADD.

Update part of the screen with Direct2D

I have a viewport with some shapes that I draw by using Direct2D. At the moment when I change somehting, for example I set a Rectangle fill from red to green, I first clear the render target and then I draw again all the shapes with the new properties.
Since I know the position and the area of the rectangle I modified, is there a way to clear and re-draw only the area that has been updated insted of re-draw all the thousand shapes I have?
The documentation for:
IDXGISwapChain1::Present1(
UINT SyncInterval,
UINT PresentFlags,
[in] const DXGI_PRESENT_PARAMETERS *pPresentParameters);
states that
An app can use Present1 to optimize presentation by specifying scroll and dirty rectangles.
This information about the modified rectangles is supplied via the *pPresentParameters parameter. For details see:
DXGI_PRESENT_PARAMETERS structure

Changing background with OpenGl and GLPaint example

I am using Apple's provided example of OpenGl GLPaint, I did brush width, colors select, without big problems, but can't find any way how I could change background color to image. Any suggestions?
Try to define a clear color using glClearColor in your initGL method.

GLPaint based OpenGL ES Blending Issue

I'm working on an app based on Apple's GLPaint sample code. I've changed the clear color to transparent black and have added an opacity slider, however when I mix colors together with a low opacity setting they don't mix the way I'm expecting. They seem to mix the way light mixes, not the way paint mixes. Here is an example of what I mean:
The "Desired Result" was obtained by using glReadPixels to render each color separately and merge it with the previous rendered image (i.e. using apple's default blending).
However, mixing each frame with the previous is too time consuming to be done on the fly, how can I get OpenGL to blend the colors properly? I've been researching online for quite a while and have yet to find a solution that works for me, please let me know if you need any other info to help!
From the looks of it, with your current setup, there is no easy solution. For what you are trying to do, you need custom shaders. Which is not possible using just GLKit.
Luckily you can mix GLKit and OpenGL ES.
My recommendation would be to:
Stop using GLKit for everything except setting up your rendering
surface with GLKView (which is tedious without GLKit).
Use an OpenGl program with custom shaders to draw to a texture that is backing an FBO.
Use a second program with custom shaders that does post processing (after drawing above texture to a quad which is then rendered to the screen).
A good starting point would be to load up the OpenGl template that comes with Xcode. And start modifying it. Be warned: If you don't understand shaders, the code here will make little sense. It draws 2 cubes, one using GLKit, and one without - using custom shaders.
References to start learning:
Intro to shaders
Rendering to a Texture
Shader Toy - This should help you experiment with your post processing frag shader.
GLEssentials example - This shows how to render to texture using OpenGL ( a bit outdated.)
Finally, if you are really serious about using OpenGL ES to it's full potential, you really should invest the time to read through OpenGL ES 2.0 programming guide. Even though it is 6 years old, it is still relevant and the only book I've found that explains all the concepts correctly.
Your "Current Result" is additive color, which is how OpenGL is supposed to work. To work like mixing paint would be substractive color. You don't have control over this with OpenGL ES 1.1, but you could write a custom fragment shader for OpenGL ES 2.0 that would do substractive color. If you are blending textures images from iOS, you need to know if the image data has been premultiplied by alpha or not, in order to do blending. OpenGL ES expects the non-premultiplied format.
You need to write that code in the function which is called on color change.
and each time you need to set BlendFunc.
CGFloat red , green, blue;
// set red, green ,blue with desire color combination
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
glColor4f(red* kBrushOpacity,
green * kBrushOpacity,
blue* kBrushOpacity,
kBrushOpacity);
To do more things by using BlendFunc use this link
Please specify if it works or not. It work for me.

Cocos2D 2.0 - Changing color of a CCParticle

So after messing around with my game, there's a thing that I wanted to share with you that I discovered about CCParticle.
How do I change the color of the particles in a CCParticleSystem?
When I was on cocos 1.x, I could change it with startColor, endColor, but in 2.0, whenever I do it, it stays black. Why?
A:In Cocos2D 2.0, it stays the same, but unlike in 1.x, you must first make sure that the particle texture is white, because otherwise it will not blend with the color you want! Make sure too that the texture is correctly added, because if not, it will show big black pixels and that's probably not the result you want!

Resources