Exemple #1
0
        public void on_glTexImage2D(int level, int internalformat,
                                    int width, int height, int border, uint format, uint type, byte[] pixels, int offset)
        {
            Mipmap mip = m_pMipmaps[level];

            mip.reset();

            mip.IsCompressed = 0;

            mip.Format = (int)format;
            mip.Width  = width;
            mip.Height = height;

            mip.Type = type;

            int imageSize = mip.calculateSize();

            if (imageSize > 0)
            {
                mip.Pixels = new byte[imageSize];
                Utils.memcpy(mip.Pixels, 0, pixels, offset, imageSize);
            }

            mip.HasData = true;
        }
Exemple #2
0
        public override void fromMessage(Message msg)
        {
            clearData();

            MyBinStream stream = new MyBinStream(msg.Data);

            m_id      = stream.readUInt();
            m_texType = (KPTextureType)stream.readInt();

            int mipmapCount = stream.readInt();

            for (int i = 0; i < mipmapCount; i++)
            {
                int level = stream.readInt();
                Utils.assert(level >= 0 && level < MAX_MIPMAP_LEVEL_NUMBER);
                Mipmap mip = m_pMipmaps[level];

                mip.reset();

                mip.Width        = stream.readInt();
                mip.Height       = stream.readInt();
                mip.IsCompressed = stream.readByte();
                mip.Format       = stream.readInt();
                mip.Type         = stream.readUInt();

                byte hasPixel = stream.readByte();
                if (hasPixel == 1)
                {
                    int mipSize = mip.calculateSize();
                    if (mipSize > 0)
                    {
                        mip.Pixels = new byte[mipSize];
                        stream.readBytes(mip.Pixels, 0, mipSize);
                    }
                }

                mip.HasData = true;
            }

            stream.close();
        }
Exemple #3
0
        public void on_glCompressedTexImage2D(int level, uint internalformat, int width, int height,
                                              int border, int imageSize, byte[] data, int offset)
        {
            Mipmap mip = m_pMipmaps[level];

            mip.reset();

            mip.IsCompressed = 1;

            mip.Format = (int)internalformat;
            mip.Width  = width;
            mip.Height = height;

            mip.Type = (uint)imageSize;

            if (imageSize > 0)
            {
                mip.Pixels = new byte[imageSize];
                Utils.memcpy(mip.Pixels, 0, data, offset, imageSize);
            }

            mip.HasData = true;
        }