OpenGL ES clarifying question regarding FBOs -- sorry can't find this info anywhere else? - iphone

If I instantiate an FBO without binding a rendering buffer or a texture to it, what happens when I draw to it, nothing?
Do I need to associate a rendering target (renderbuffer or texture) to have an FBO do anything? What I'm trying to do is precache some buffers and then merge them later, but that doesn't seem to work at all.
Ideally I'd like to do something like
glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo1);
// Draw some stuff to fbo1
glBindFramebufferOES(GL_FRAMEBUFFER_OES, fbo2);
// Draw some stuff to fbo2
// ...
// ...
// glRenderFbo(fbo1); -- Not a func
// Set blending, etc. etc.
// glRenderFbo(fbo2); -- Not a func

Yes, the answer is nothing. I'd like you to read my response to your other question.
How to merge two FBOs?

Related

SimpleITK getDirection() explained

Could someone explain the output of SimpleITK.GetDirection() and how is related to DICOM standard Image Orientation (Patient) header and NIFTI? Eventually, I would like to get the right Image Orientation (Patient) given a cut e.g. axial, sagittal, coronal.
I am aware of the example, https://simpleitk.readthedocs.io/en/next/Examples/DicomSeriesFromArray/Documentation.html. However, why Image Orientation (Patient) is set the way is set, it's not clear to me.
In the Xdrt library that I use they deal with it like this to write a dicom:
direction = sitk_image.GetDirection()
_direction = (direction[0], direction[3], direction[6], direction[1], direction[4], direction[7])
...
image_slice.SetMetaData("0020|0037", "\\".join(map(str, _direction))), # Image Orientation
You can watch their whole code here https://github.com/NKI-AI/xdrt/blob/ca3e83459dd76521bac597465c815cf6a3da35ad/xdrt/cli/utils.py#L157
May it can help you

tex2D(s,t,ddx,ddy) not working in fullscreen in unity

i'm trying to make full screen custom post effect.
with script added to main cam, with one line: blit(src,dst,mat) in void OnRenderImage(src,dst). I wrote the shader with _MainTex so it'll work in "Blit". I done it(many times) all correctlly like in tuts. if i assign this shader to any object (with texture) it works well, but the problem is when i assign that shader(in material) to script (blit(,,mat)) it ignores the ddx,ddy part,it works like tex2D(tex,uv). WHY? how can I fix it?
here is the fragment code.
fixed3 frag(vout v):sv_target
{
fixed3 c;
float2 cddx=float2(
pow(abs(0.5-v.uv.x),1.6)*_xy,
-pow(abs(0.5-v.uv.y),1.6)*_xy);
float2 cddy=float2(
-pow(abs(0.5-v.uv.x),1.6)*_xy,
pow(abs(0.5-v.uv.y),1.6)*_xy);
c=tex2D(_MainTex,v.uv,cddx,cddy);
return c*0.5;
}
I found an answer. tex2D(sampler2D,uv,ddx,ddy) and tex2Dgrad(...) methods use mipmaps. when i tried to pass "screen" texture to the shader in blit(src,dst,mat) I noticed that src has no mipmaps, only the original texture. so, I thought that I'll simply add mipmaps with src.GenerateMips() and it'll work. but there is a catch: if i try to do that the editor throws me exceptions that the rendertexture is created, that generating mips is unsuported in created rendertexture and other stuff... finally i found the recipy:
one time
create another temp renderTexture
turn off auto generate mipmaps
useMips=true
every frame (OnRenderImage(...))
blit src to temp
generate mipmaps in temp
blit(temp,dst,mat)
it generates mipmaps on new render texture and passes it to the shader without any errors.
one last thing, if someone knows how to specify mipmap count that i want to generate, tell me please.
I hope it'll be helpful to newbies in shaders like me.

QQuick + OpenSceneGraph flickering

I am using QQuickControls 2 (SwipeView) with OpenSceneGraph for the 3d rendering. Using QQuickFramebufferObject for the integration.
Since I have introduced a SwipeView, I observe some flickering of my GUI.
I have looked for ages in the doc (it probably sums literally up to weeks) and have absolutely no idea why I have this flickering.
Here is a video of the faulty behavior (flickering starts at ~20s).
And here is my rendering code:
class OsgRenderer : public QQuickFramebufferObject::Renderer
{
public:
explicit OsgRenderer();
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) LC_OVERRIDE;
void synchronize(QQuickFramebufferObject* item) LC_OVERRIDE;
void render() LC_OVERRIDE;
protected:
friend class OsgWindow;
OsgItem* m_osgItem;
};
void OsgRenderer::render()
{
assert(m_osgItem);
if ( !m_osgItem->getViewer() )
return;
// Without this line the model is not displayed in the second
// and subsequent frames.
QOpenGLContext::currentContext()->functions()->glUseProgram(0);
// Ask OSG to render.
m_osgItem->getViewer()->frame(); // WARNING: non-blocking (executed in a thread of its own - in a thread-safe way).
// Reset OpenGl state for QtQuick.
m_osgItem->window()->resetOpenGLState();
}
Any idea of where that can come from?
In general it's not a good idea to have QtQuick and OSG both render to the same OpenGL context.
OSG it's keeping its GL state internally between frames, but Qt might modify it from "outside" without notifying osg, and this might cause rendering issues.
A more solid approach is have them use separate (and shared) GL context, and copy the context of the fbo osg redners to in a texture used by Qt.
I've successfully implemented this approach here: https://github.com/rickyviking/qmlosg
but haven't tested it with recent versions of QtQuick.
A more up-to-date integration can be found here: https://github.com/podsvirov/osgqtquick

QQuickFramebufferObject: where is the custom FBO used ? How can this cause flickering?

I am currently integrating a custom OpenGL viewport within QML via QQuickFramebufferObject. I observe some flickering of the whole app window (not only of the QQuickFramebufferObject window) and I am wondering why.
My custom QQuickFramebufferObject::Renderer does create a separate FPO:
QOpenGLFramebufferObject* OsgRenderer::createFramebufferObject(const QSize &size)
{
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
return new QOpenGLFramebufferObject(size, format);
}
So I understand that Qt defines its own FBO type (QOpenGLFramebufferObject) so it can later use the FBO to mix it with its own GL rendering, is that right?
I then do all my rendering
void OsgRenderer::render()
{
assert(m_osgItem);
if ( !m_osgItem->getViewer() )
return;
// Without this line the model is not displayed in the second
// and subsequent frames.
QOpenGLContext::currentContext()->functions()->glUseProgram(0);
// Ask OSG to render.
m_osgItem->getViewer()->frame(); // WARNING: non-blocking (executed in a thread of its own - in a thread-safe way).
// Reset OpenGl state for QtQuick.
m_osgItem->window()->resetOpenGLState();
}
I expect QtQuick to actually gather my custom rendered FBO with its own rendering of the window after the call to render(), is that right?
My rendering is actually achieved in a separate context. In this context, how can it cause flickering? Any idea?

Turning on anti-aliasing in SWT

I've called gc.setAntialias(SWT.ON); and it does nothing. According to that method, it should work.
The Javadoc states:
Sets the receiver's anti-aliasing
value to the parameter, which must be
one of SWT.DEFAULT, SWT.OFF or SWT.ON.
It's not working for me, and I'm painting on a simple Canvas.
The following worked for me in an app I built and my guesses at when/how you have to do this.
So I created a new GC, set the Antialias as you did and then drew what I needed to with that gc object. The key is attaching it to the shell you will draw in.
GC gc = new GC(shell);
gc.setAntialias(SWT.ON);
//then I attach to LightweightSystem for testing.
LightweightSystem lws = new LightweightSystem(shell);
Other than that make sure you do this before you draw anything. If you have to call it afterwards maybe try calling a repaint or redraw of the entire space.
Sorry without more information I am not sure exactly what is wrong.
Following derBiggi's answer, you ca also force the advanced option to true.
gc.setAdvanced(true)
Also, if you're drawing labels, make sure you use gc.setTextAntialias( SWT.ON );
You can also check if gc.getAdvanced() returns true, it should after setAntialias() or setTextAntialias was set.
Besides from that it's pretty straight forward.