|
Mario Mastrodicasa
|
Set the dimension and position of a NativeWindowSurface
|
|
Mario Mastrodicasa
04/23/2009 3:35 AM
post27847
|
Set the dimension and position of a NativeWindowSurface
I have created this simple code in order to attach and detach a NativeWindowType. I use it in order to work with
OPENGLES in subframe of the main display surface. If the subframe change in dimension the code is used.
Since there is no parameter for the position to be passed to gf_3d_target_create, how I' unable to set the position.
Actually I use gf_draw_blit2 to blit the surface[0] to the main display surface.
My first question: is it possible to change the dimension of the surface without the overhead of destroy and recreate
all?
My second question: how to set the position of the NativeWindowType and leave OpenGL to make the work? (e.g.
eglSwapInterval)
gf_3d_target_t native;
int nsurface;
gf_surface_t *surface;
gf_surface_info_t *surface_info;
gf_context_t gf_context;
void detach_surface()
{
if (gf_context)
gf_context_unset_surface(gf_context);
if (native)
gf_3d_target_free(native);
if (surface)
{
for (int i = 0; i < nsurface; i++)
{
if (surface[i])
gf_surface_free(surface[i]);
}
delete[] surface;
}
if (surface_info)
delete[] surface_info;
if (gf_context)
gf_context_free(gf_context);
gf_context = 0;
native = 0;
}
bool attach_surface(int width, int height)
{
int err;
gf_layer_t layer = *GF_layer_t();
gf_dev_t dev = *GF_gf_dev_t();
gf_layer_info_t *layer_info = GF_layer_info_t();
surface = new gf_surface_t[nsurface];
surface_info = new gf_surface_info_t[nsurface];
for (int i = 0; i < nsurface; i++)
{
err = gf_surface_create(&surface[i], dev,\
width, height, layer_info->format,\
NULL, GF_SURFACE_CREATE_3D_ACCESSIBLE);
if (err != GF_ERR_OK)
{
return false;
}
gf_surface_get_info(surface[i], &surface_info[i]);
}
err = gf_3d_target_create(&native, layer,\
&surface[0], nsurface, width, height,\
layer_info->format);
if (err != GF_ERR_OK)
{
return false;
}
}
Thanks,
Mario
|
|
|
|
|