예제 #1
0
        public override void MakeTexture()
        {
            if (PrepDevice != null)
            {
                try
                {
                    texture2d = PrepDevice.createTexture();

                    PrepDevice.bindTexture(GL.TEXTURE_2D, texture2d);
                    PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_S, GL.CLAMP_TO_EDGE);
                    PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_WRAP_T, GL.CLAMP_TO_EDGE);

                    if (GetHipsFileExtention() == ".fits" && RenderContext.UseGlVersion2)
                    {
                        PrepDevice.texImage2D(GL.TEXTURE_2D, 0, GL.R32F, (int)fitsImage.SizeX, (int)fitsImage.SizeY, 0, GL.RED, GL.FLOAT, fitsImage.dataUnit);
                        PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.NEAREST);
                        PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MAG_FILTER, GL.NEAREST);
                    }
                    else
                    {
                        ImageElement image = texture;
                        PrepDevice.texImage2D(GL.TEXTURE_2D, 0, GL.RGBA, GL.RGBA, GL.UNSIGNED_BYTE, image);
                        PrepDevice.texParameteri(GL.TEXTURE_2D, GL.TEXTURE_MIN_FILTER, GL.LINEAR_MIPMAP_NEAREST);
                        PrepDevice.generateMipmap(GL.TEXTURE_2D);
                    }

                    PrepDevice.bindTexture(GL.TEXTURE_2D, null);
                }
                catch
                {
                    errored = true;
                }
            }
        }