Problem using eglCreatePixmapSurface

Hi all

I am using the reference implementation of khronos OpenVG
[http://www.khronos.org/files/openvg_1_0_ri](http://www.khronos.org/files/openvg_1_0_ri)

I am trying to get a Native Pixmap Surface, and the below is a brief of what I am doing

My native pixmap is of type NativePixmapType defined in egl.h
I have allocated the memory for the data pointer to the following
Height = 320, Width = 240, RGBA bytes per pixel = 4
nativepix->data = malloc(3202404);
The memory address allocated to me is 0x402d9008

I now do the following VG operations to draw a texture (curves)

<code>

NativePixmapType natpix = (NativePixmapType)malloc (sizeof (NativePixmap));
		
natpix-&gt;width = 240;
natpix-&gt;height = 320;
natpix-&gt;format = VG_sRGBX_8888;
natpix-&gt;stride = 0;
natpix-&gt;data = malloc (320*240*4);
EGLint numconfigs;

    //initialize EGL
eglBindAPI(EGL_OPENVG_API);

egldisplay = eglGetDisplay(EGL_DEFAULT_DISPLAY);

eglInitialize(egldisplay, NULL, NULL);

eglChooseConfig(egldisplay, s_pixconfig, &eglPixMapConfig, 1, &numconfigs);

    eglPixMapSurface = eglCreatePixmapSurface(egldisplay, eglPixMapConfig, natpix, NULL);

eglPixMapContext = eglCreateContext(egldisplay, eglPixMapConfig, EGL_NO_CONTEXT, NULL);


eglMakeCurrent(egldisplay, eglPixMapSurface, eglPixMapSurface, eglPixMapContext);

//Start VG operations.
vgSeti(VG_MATRIX_MODE, VG_MATRIX_PATH_USER_TO_SURFACE);
vgLoadIdentity();
vgScale((float)240, (float)320);

vgPathHandle = vgCreatePath(VG_PATH_FORMAT_STANDARD,
                          VG_PATH_DATATYPE_F,
                          1.0f,
                          0.0f,
                          4,
                          3,
                          (unsigned int)VG_PATH_CAPABILITY_APPEND_TO);

    VGubyte aui8PathSegments[] = {
    VG_MOVE_TO_ABS, VG_LINE_TO_ABS,
    VG_MOVE_TO_ABS, VG_HLINE_TO_ABS,
    VG_MOVE_TO_ABS, VG_VLINE_TO_ABS,
    VG_MOVE_TO_ABS, VG_QUAD_TO_ABS,
    VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS,
    VG_MOVE_TO_ABS, VG_QUAD_TO_ABS, VG_SQUAD_TO_ABS,
    VG_MOVE_TO_ABS, VG_CUBIC_TO_ABS, VG_SCUBIC_TO_ABS,
    VG_MOVE_TO_ABS, VG_SCWARC_TO_ABS,
    VG_MOVE_TO_ABS, VG_SCCWARC_TO_ABS,
    VG_MOVE_TO_ABS, VG_LCWARC_TO_ABS,
    VG_MOVE_TO_ABS, VG_LCCWARC_TO_ABS

/*
*/
};

    VGfloat afPoints[] = {
    0.1f, 0.2f, 0.9f, 0.8f,
    0.1f, 0.5f, 0.9f,
    0.5f, 0.2f, 0.8f,
    0.1f, 0.8f, 0.5f, 0.0f, 0.9f, 0.7f,
    0.1f, 0.8f, 0.4f, 0.1f, 0.6f, 0.9f, 0.9f, 0.2f,
    0.1f, 0.4f, 0.3f, 0.3f, 0.5f, 0.5f, 0.9f, 0.5f,
    0.1f, 0.5f, 0.2f, 0.3f, 0.4f, 0.7f, 0.5f, 0.5f, 0.8f, 0.9f, 0.9f, 0.5f,
    0.4f, 0.3f, 0.3f, 0.25f, 0.1f, 0.6f, 0.7f,

/*
*/
};

vgAppendPathData(vgPathHandle,
                 (sizeof(aui8PathSegments) / sizeof(aui8PathSegments[0])),
                 aui8PathSegments,
                 afPoints);

vgRemovePathCapabilities(vgPathHandle, VG_PATH_CAPABILITY_APPEND_TO);

vgPaintObject = vgCreatePaint();
vgSetParameteri(vgPaintObject, VG_PAINT_TYPE, VG_PAINT_TYPE_COLOR);
vgSetColor(vgPaintObject, 0xFFFFAAFF);
VGfloat afClearColor[4];
afClearColor[0] = 0.6f;
afClearColor[1] = 0.8f;
afClearColor[2] = 1.0f;
afClearColor[3] = 1.0f;

vgSetfv(VG_CLEAR_COLOR, 4, afClearColor);

// Clear the whole surface with the clear color

vgClear(0,0,240,320);

vgSetPaint(vgPaintObject, VG_FILL_PATH);

// Draw the path

vgDrawPath(vgPathHandle, VG_FILL_PATH);

vgDestroyPath(vgPathHandle);
vgDestroyPaint(vgPaintObject);
vgFinish();

</code>

Now if I try to get the pixmap in to a .rgba file with the following code snippet

<code>
{
FILE fptr_vg_data = NULL ;
fptr_vg_data=fopen(“nativedata.rgba”,“wb”);
fwrite(natpix->data, (320
240*4), 1, fptr_vg_data);
fclose(fptr_vg_data);
}
</code>

I get a blank image.

But if I check the m_data value at the destructor of the class Image in riImage.cpp
the memory pointer is actually different (0x40380008) and I see some intended color but not the intended
texture.

Could any body explain what is happening? Am I doing something wrong?

Regards,
Syed

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.