Community
Arnold General Rendering Forum
abbrechen
Suchergebnisse werden angezeigt für 
Anzeigen  nur  | Stattdessen suchen nach 
Meintest du: 

Arnold OpenGL for IPR

2 ANTWORTEN 2
Antworten
Nachricht 1 von 3
Anonymous
1067 Aufrufe, 2 Antworten

Arnold OpenGL for IPR

Currently, using OpenGL I am able to get Arnold to render interactively within a viewport. The issue is that this renders black on Linux and Mac but works perfectly fine on windows, I used the display callback driver you have provided on the website and compiled. Would you be able to share the correct OpenGL types for both Linux and Mac respectively?

I'm aware that glDrawPixels is deprecated, I will be using glTexImage2D in production, but regardless, I will need the appropriate OpenGL types to work with this.


Here is the OpenGL code that works fine on Windows:

(width, height), rect = ipr.update(width, height, data)
v = bgl.Buffer(bgl.GL_FLOAT, 4)
bgl.glGetFloatv(bgl.GL_VIEWPORT, v)
vw = v[2]
vh = v[3]
bgl.glRasterPos2f(0, vh - 1.0)
bgl.glPixelZoom(vw / width, -vh / height)
bgl.glDrawPixels(width, height, bgl.GL_RGBA, bgl.GL_UNSIGNED_BYTE,
                 bgl.Buffer(bgl.GL_BYTE, len(rect), rect))
bgl.glPixelZoom(1.0, 1.0)
bgl.glRasterPos2f(0, 0)

And here is the callback function:

def _callback(x, y, width, height, buffer, data):
            #print("+++ _callback:", x, y, width, height, ctypes.cast(buffer, ctypes.c_void_p))
            if buffer:
                try:
                    if new_data.poll():
                        arnold.AiRenderInterrupt()
                    else:
                        #print("+++ _callback: tile", x, y, width, height)
                        _buffer = ctypes.cast(buffer, ctypes.POINTER(ctypes.c_ubyte))
                        a = numpy.ctypeslib.as_array(_buffer, shape=(height, width, 4))
                        rect[y : y + height, x : x + width] = a
                        redraw_event.set()
                    return
                finally:
                    arnold.AiFree(buffer)
            elif not new_data.poll():
                return
            arnold.AiRenderAbort()
            print("+++ _callback: abort")

And here is how I call the callback function:

cb = arnold.AtDisplayCallBack(_callback)
arnold.AiNodeSetPtr(driver, "callback", cb)
Tags (2)
Beschriftungen (2)
2 ANTWORTEN 2
Nachricht 2 von 3
svenakelian
als Antwort auf: Anonymous

Hi

I'm trying to create a standalone IPR (kindof like kick) using Qt C++.

I can't find any reliable informations on how to implement the callback properly.

Here is the render() slot (qt_driver is just the provided display_driver sample):

AiBegin(AI_SESSION_INTERACTIVE);
AtNode* options = AiUniverseGetOptions();

AtNode *filter = AiNode("gaussian_filter");
AiNodeSetStr(filter, "name", "gauss_filter");


AtNode *qtdriver = AiNode("qt_driver");
AiNodeSetStr(qtdriver, "name", "qt_driver");
AtRenderUpdateCallback cb = AtRenderUpdateCallback(qtIPR);
AiNodeSetPtr(qtdriver, "callback_data", &cb);

AtArray *outputs_array = AiArrayAllocate(1, 1, AI_TYPE_STRING);
AiArraySetStr(outputs_array, 0, "RGBA RGBA gauss_filter qt_driver");
AiNodeSetArray(options, "outputs", outputs_array);

AiRenderBegin(AI_RENDER_MODE_CAMERA);

I don't know how to properly use and link the callback:

void qtIPR(uint32_t x, uint32_t y, uint32_t width, uint32_t height, uint8_t* buffer, void* data)
{
    qDebug() << "Status:\t" << AiRenderGetStatus();
    if (buffer != nullptr)
    {
        try{
        qDebug() << "Used Memory:\t" << AiMsgUtilGetUsedMemory() / 1048576;
        qDebug() << "X:\t" << x;
        qDebug() << "Y:\t" << y;
        qDebug() << "Width:\t" << width;
        qDebug() << "Height:\t" << height;


        //qDebug() << "Buffer:\t" << buffer;
        //qDebug() << "Data:\t" << data;
    }
        catch(...){
            AiFree(buffer);
        }
    }
    else{
        qDebug() << "Width:\t" << width;
    }


}
Nachricht 3 von 3
Anonymous
als Antwort auf: Anonymous

Hmm, do you mind cleaning up the code a bit so I can see what you're looking at? Thanks.

Sie finden nicht, was Sie suchen? Fragen Sie die Community oder teilen Sie Ihr Wissen mit anderen.

In Foren veröffentlichen  

Autodesk Design & Make Report