GetServerTextureId() private method

private GetServerTextureId ( ) : int
return int
示例#1
0
 void UploadGradientLookupTable(GLBitmap bmp)
 {
     //load before use with RenderSubImage
     //-------------------------------------------------------------------------------------
     // Bind the texture...
     GL.ActiveTexture(TextureUnit.Texture0);
     GL.BindTexture(TextureTarget.Texture2D, bmp.GetServerTextureId());
     // Set the texture sampler to texture unit to 0
     s_texture.SetValue(0);
 }
        public void RenderSubImage(GLBitmap bmp, float[] srcDestList, float scale)
        {
            SetCurrent();
            CheckViewMatrix();
            //-------------------------------------------------------------------------------------
            // Bind the texture...
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, bmp.GetServerTextureId());
            // Set the texture sampler to texture unit to 0
            s_texture.SetValue(0);
            OnSetVarsBeforeRenderer();

            int j = srcDestList.Length;

            for (int i = 0; i < j;)
            {
                float srcLeft    = srcDestList[i];
                float srcTop     = srcDestList[i + 1];
                float srcW       = srcDestList[i + 2];
                float srcH       = srcDestList[i + 3];
                float targetLeft = srcDestList[i + 4];
                float targetTop  = srcDestList[i + 5];

                i += 6;
                //-------------------------------
                float srcBottom = srcTop - srcH;
                float srcRight  = srcLeft + srcW;
                float orgBmpW   = bmp.Width;
                float orgBmpH   = bmp.Height;
                unsafe
                {
                    float *imgVertices = stackalloc float[5 * 4];
                    {
                        imgVertices[0] = targetLeft; imgVertices[1] = targetTop; imgVertices[2] = 0; //coord 0
                        imgVertices[3] = srcLeft / orgBmpW; imgVertices[4] = srcBottom / orgBmpH;    //texture coord 0

                        //---------------------
                        imgVertices[5] = targetLeft; imgVertices[6] = targetTop - (srcH * scale); imgVertices[7] = 0; //coord 1
                        imgVertices[8] = srcLeft / orgBmpW; imgVertices[9] = srcTop / orgBmpH;                        //texture coord 1

                        //---------------------
                        imgVertices[10] = targetLeft + (srcW * scale); imgVertices[11] = targetTop; imgVertices[12] = 0; //coord 2
                        imgVertices[13] = srcRight / orgBmpW; imgVertices[14] = srcBottom / orgBmpH;                     //texture coord 2

                        //---------------------
                        imgVertices[15] = targetLeft + (srcW * scale); imgVertices[16] = targetTop - (srcH * scale); imgVertices[17] = 0; //coord 3
                        imgVertices[18] = srcRight / orgBmpW; imgVertices[19] = srcTop / orgBmpH;                                         //texture coord 3
                    };
                    a_position.UnsafeLoadMixedV3f(imgVertices, 5);
                    a_texCoord.UnsafeLoadMixedV2f(imgVertices + 3, 5);
                }
                GL.DrawElements(BeginMode.TriangleStrip, 4, DrawElementsType.UnsignedShort, indices);
            }
        }
示例#3
0
        public void MakeActive()
        {
            //if (_owner.CurrentActiveTextureContainer != this)
            //{
            _owner.CurrentActiveTextureContainer = this;
            GL.ActiveTexture(_textureUnit);
            GL.BindTexture(TextureTarget.Texture2D, _currentGLBitmap.GetServerTextureId());
            //}
            //else
            //{

            //}
        }
        public void Render(GLBitmap bmp,
                           float left_top_x, float left_top_y,
                           float right_top_x, float right_top_y,
                           float right_bottom_x, float right_bottom_y,
                           float left_bottom_x, float left_bottom_y, bool flipY = false)

        {
            Render(bmp.GetServerTextureId(),
                   left_top_x, left_top_y,
                   right_top_x, right_top_y,
                   right_bottom_x, right_bottom_y,
                   left_bottom_x, left_bottom_y, flipY);
        }
 /// <summary>
 /// load glbmp before draw
 /// </summary>
 /// <param name="bmp"></param>
 public void LoadGLBitmap(GLBitmap bmp)
 {
     //load before use with RenderSubImage
     SetCurrent();
     CheckViewMatrix();
     //-------------------------------------------------------------------------------------
     // Bind the texture...
     GL.ActiveTexture(TextureUnit.Texture0);
     GL.BindTexture(TextureTarget.Texture2D, bmp.GetServerTextureId());
     // Set the texture sampler to texture unit to 0
     s_texture.SetValue(0);
     _latestBmpW        = bmp.Width;
     _latestBmpH        = bmp.Height;
     _latestBmpYFlipped = bmp.IsYFlipped;
 }
示例#6
0
        void InitFrameBuffer()
        {
            GL.GenFramebuffers(1, out _frameBufferId);
            //switch to this (custom) framebuffer
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, _frameBufferId);

            //---------
            //render buffer
            GL.GenRenderbuffers(1, out _renderBufferId);
            GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, _renderBufferId);
            GL.RenderbufferStorage(RenderbufferTarget.Renderbuffer, RenderbufferInternalFormat.DepthComponent16, _width, _height);
            GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferSlot.ColorAttachment0, TextureTarget.Texture2D, _glBmp.GetServerTextureId(), 0);
            GL.FramebufferRenderbuffer(FramebufferTarget.Framebuffer, FramebufferSlot.DepthAttachment, RenderbufferTarget.Renderbuffer, _renderBufferId);
            //switch back to default framebuffer (system provider framebuffer)

            GL.BindTexture(TextureTarget.Texture2D, 0);              //unbind
            GL.BindRenderbuffer(RenderbufferTarget.Renderbuffer, 0); //unbind => default framebuffer
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);    //unbind
        }
        public void Render(GLBitmap bmp, float left, float top, float w, float h)
        {
            unsafe
            {
                float* imgVertices = stackalloc float[5 * 4];
                {
                    imgVertices[0] = left; imgVertices[1] = top; imgVertices[2] = 0; //coord 0
                    imgVertices[3] = 0; imgVertices[4] = 0; //texture coord 0 

                    //---------------------
                    imgVertices[5] = left; imgVertices[6] = top - h; imgVertices[7] = 0; //coord 1
                    imgVertices[8] = 0; imgVertices[9] = 1; //texture coord 1 

                    //---------------------
                    imgVertices[10] = left + w; imgVertices[11] = top; imgVertices[12] = 0; //coord 2
                    imgVertices[13] = 1; imgVertices[14] = 0; //texture coord 2 

                    //---------------------
                    imgVertices[15] = left + w; imgVertices[16] = top - h; imgVertices[17] = 0; //coord 3
                    imgVertices[18] = 1; imgVertices[19] = 1; //texture coord 3 
                };
                a_position.UnsafeLoadMixedV3f(imgVertices, 5);
                a_texCoord.UnsafeLoadMixedV2f(imgVertices + 3, 5);
            }

            SetCurrent();
            CheckViewMatrix();
            //-------------------------------------------------------------------------------------
            // Bind the texture...
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, bmp.GetServerTextureId());
            // Set the texture sampler to texture unit to 0     
            s_texture.SetValue(0);
            OnSetVarsBeforeRenderer();
            GL.DrawElements(BeginMode.TriangleStrip, 4, DrawElementsType.UnsignedShort, indices);
        }
        public void RenderSubImage(GLBitmap bmp, float[] srcDestList, float scale)
        {
            SetCurrent();
            CheckViewMatrix();
            //-------------------------------------------------------------------------------------
            // Bind the texture...
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, bmp.GetServerTextureId());
            // Set the texture sampler to texture unit to 0     
            s_texture.SetValue(0);
            OnSetVarsBeforeRenderer();

            int j = srcDestList.Length;
            for (int i = 0; i < j; )
            {

                float srcLeft = srcDestList[i];
                float srcTop = srcDestList[i + 1];
                float srcW = srcDestList[i + 2];
                float srcH = srcDestList[i + 3];
                float targetLeft = srcDestList[i + 4];
                float targetTop = srcDestList[i + 5];

                i += 6;
                //-------------------------------
                float srcBottom = srcTop - srcH;
                float srcRight = srcLeft + srcW;
                float orgBmpW = bmp.Width;
                float orgBmpH = bmp.Height;
                unsafe
                {
                    float* imgVertices = stackalloc float[5 * 4];
                    {
                        imgVertices[0] = targetLeft; imgVertices[1] = targetTop; imgVertices[2] = 0; //coord 0
                        imgVertices[3] = srcLeft / orgBmpW; imgVertices[4] = srcBottom / orgBmpH; //texture coord 0 

                        //---------------------
                        imgVertices[5] = targetLeft; imgVertices[6] = targetTop - (srcH * scale); imgVertices[7] = 0; //coord 1
                        imgVertices[8] = srcLeft / orgBmpW; imgVertices[9] = srcTop / orgBmpH; //texture coord 1 

                        //---------------------
                        imgVertices[10] = targetLeft + (srcW * scale); imgVertices[11] = targetTop; imgVertices[12] = 0; //coord 2
                        imgVertices[13] = srcRight / orgBmpW; imgVertices[14] = srcBottom / orgBmpH; //texture coord 2 

                        //---------------------
                        imgVertices[15] = targetLeft + (srcW * scale); imgVertices[16] = targetTop - (srcH * scale); imgVertices[17] = 0; //coord 3
                        imgVertices[18] = srcRight / orgBmpW; imgVertices[19] = srcTop / orgBmpH; //texture coord 3 
                    };
                    a_position.UnsafeLoadMixedV3f(imgVertices, 5);
                    a_texCoord.UnsafeLoadMixedV2f(imgVertices + 3, 5);
                }
                GL.DrawElements(BeginMode.TriangleStrip, 4, DrawElementsType.UnsignedShort, indices);
            }

        }
 public void Render(GLBitmap bmp, float left, float top, float w, float h)
 {
     Render(bmp.GetServerTextureId(), left, top, w, h, bmp.IsYFlipped);
 }
        public void Render(GLBitmap bmp, float left, float top, float w, float h)
        {
            unsafe
            {
                if (bmp.IsInvert)
                {
                    float *imgVertices = stackalloc float[5 * 4];
                    {
                        imgVertices[0] = left; imgVertices[1] = top; imgVertices[2] = 0; //coord 0 (left,top)
                        imgVertices[3] = 0; imgVertices[4] = 0;                          //texture coord 0 (left,bottom)
                        //imgVertices[3] = srcLeft / orgBmpW; imgVertices[4] = srcBottom / orgBmpH; //texture coord 0  (left,bottom)

                        //---------------------
                        imgVertices[5] = left; imgVertices[6] = top - h; imgVertices[7] = 0; //coord 1 (left,bottom)
                        imgVertices[8] = 0; imgVertices[9] = 1;                              //texture coord 1  (left,top)

                        //---------------------
                        imgVertices[10] = left + w; imgVertices[11] = top; imgVertices[12] = 0; //coord 2 (right,top)
                        imgVertices[13] = 1; imgVertices[14] = 0;                               //texture coord 2  (right,bottom)

                        //---------------------
                        imgVertices[15] = left + w; imgVertices[16] = top - h; imgVertices[17] = 0; //coord 3 (right, bottom)
                        imgVertices[18] = 1; imgVertices[19] = 1;                                   //texture coord 3 (right,top)
                    }
                    a_position.UnsafeLoadMixedV3f(imgVertices, 5);
                    a_texCoord.UnsafeLoadMixedV2f(imgVertices + 3, 5);
                }
                else
                {
                    float *imgVertices = stackalloc float[5 * 4];
                    {
                        imgVertices[0] = left; imgVertices[1] = top; imgVertices[2] = 0; //coord 0 (left,top)
                        imgVertices[3] = 0; imgVertices[4] = 1;                          //texture coord 0 (left,top)

                        //---------------------
                        imgVertices[5] = left; imgVertices[6] = top - h; imgVertices[7] = 0; //coord 1 (left,bottom)
                        imgVertices[8] = 0; imgVertices[9] = 0;                              //texture coord 1 (left,bottom)

                        //---------------------
                        imgVertices[10] = left + w; imgVertices[11] = top; imgVertices[12] = 0; //coord 2 (right,top)
                        imgVertices[13] = 1; imgVertices[14] = 1;                               //texture coord 2 (right,top)

                        //---------------------
                        imgVertices[15] = left + w; imgVertices[16] = top - h; imgVertices[17] = 0; //coord 3 (right, bottom)
                        imgVertices[18] = 1; imgVertices[19] = 0;                                   //texture coord 3  (right,bottom)
                    }
                    a_position.UnsafeLoadMixedV3f(imgVertices, 5);
                    a_texCoord.UnsafeLoadMixedV2f(imgVertices + 3, 5);
                }
            }

            SetCurrent();
            CheckViewMatrix();
            //-------------------------------------------------------------------------------------
            // Bind the texture...
            GL.ActiveTexture(TextureUnit.Texture0);
            GL.BindTexture(TextureTarget.Texture2D, bmp.GetServerTextureId());
            // Set the texture sampler to texture unit to 0
            s_texture.SetValue(0);
            OnSetVarsBeforeRenderer();
            GL.DrawElements(BeginMode.TriangleStrip, 4, DrawElementsType.UnsignedShort, indices);
        }