Exemplo n.º 1
0
        private void SetupDefaultTexture()
        {
            if (default_texture == IntPtr.Zero)
            {
                if (DefaultSurface != null)
                {
                    Cogl.PixelFormat fm;
                    if (DefaultSurface.Format == Cairo.Format.ARGB32)
                    {
                        fm = PixelFormat.Argb8888Pre;
                    }
                    else //if (DefaultSurface.Format == Cairo.Format.RGB24)
                    {
                        fm = PixelFormat.Rgb888;
                    }

                    unsafe {
                        default_texture = ClutterHelper.cogl_texture_new_from_data((uint)DefaultSurface.Width, (uint)DefaultSurface.Height, Cogl.TextureFlags.None,
                                                                                   fm, Cogl.PixelFormat.Any, (uint)DefaultSurface.Stride, DefaultSurface.DataPtr);
                    }
                }
                else
                {
                    default_texture = Cogl.Texture.NewWithSize((uint)texture_size, (uint)texture_size,
                                                               Cogl.TextureFlags.None, Cogl.PixelFormat.Any);
                }
            }
        }
Exemplo n.º 2
0
        private void SetupShadeTexture()
        {
            if (shade_texture == IntPtr.Zero)
            {
                Gdk.Pixbuf finalPb = new Gdk.Pixbuf(Colorspace.Rgb, true, 8, texture_size, texture_size);

                unsafe {
                    int   dst_rowstride = finalPb.Rowstride;
                    int   dst_width     = finalPb.Width;
                    int   shd_width     = (int)((float)dst_width * 0.25f);
                    int   dst_height    = finalPb.Height;
                    byte *dst_byte      = (byte *)finalPb.Pixels;
                    byte *dst_base      = dst_byte;

                    for (int j = 0; j < dst_height; j++)
                    {
                        dst_byte = ((byte *)dst_base) + j * dst_rowstride;
                        for (int i = 0; i < dst_width; i++)
                        {
                            *dst_byte++ = 0x00;
                            *dst_byte++ = 0x00;
                            *dst_byte++ = 0x00;
                            if (i > shd_width)
                            {
                                *dst_byte++ = (byte)(255 * (float)(i - shd_width) / (float)(dst_width - shd_width));
                            }
                            else
                            {
                                *dst_byte++ = 0x00;
                            }
                        }
                    }

                    shade_texture = ClutterHelper.cogl_texture_new_from_data((uint)finalPb.Width, (uint)finalPb.Height, Cogl.TextureFlags.None,
                                                                             PixelFormat.Rgba8888, Cogl.PixelFormat.Any, (uint)finalPb.Rowstride, finalPb.Pixels);
                }
            }
        }