Esempio n. 1
0
        private void RenderTexture(GLControl glControl1, NUT nut)
        {
            if (nut == null)
            {
                return;
            }
            glControl1.MakeCurrent();
            GL.Viewport(glControl1.ClientRectangle);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.ClearColor(Color.Black);
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);

            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.MatrixMode(MatrixMode.Projection);

            foreach (NutTexture tex in nut.Nodes)
            {
                ScreenDrawing.DrawTexturedQuad(nut.glTexByHashId[tex.HashId].Id, tex.Width, tex.Height, screenVao, true, true, true, true, true);
            }

            glControl1.SwapBuffers();
        }
Esempio n. 2
0
        private void RenderTexture()
        {
            if (OpenTKSharedResources.SetupStatus != OpenTKSharedResources.SharedResourceStatus.Initialized || glControl1 == null)
            {
                return;
            }

            if (!OpenTKSharedResources.shaders["Texture"].ProgramCreatedSuccessfully)
            {
                return;
            }

            glControl1.MakeCurrent();
            GL.Viewport(glControl1.ClientRectangle);

            if (textureListBox.SelectedItem == null)
            {
                glControl1.SwapBuffers();
                return;
            }

            int width  = ((NutTexture)textureListBox.SelectedItem).Width;
            int height = ((NutTexture)textureListBox.SelectedItem).Height;

            // Draw the texture to the screen.
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            if (textureToRender != null)
            {
                ScreenDrawing.DrawTexturedQuad(textureToRender.Id, width, height, renderR, renderG, renderB, renderAlpha, keepAspectRatio, 1,
                                               currentMipLevel);
            }

            glControl1.SwapBuffers();
        }
Esempio n. 3
0
        private void RenderAreaLightColor()
        {
            Vector3 topColor    = new Vector3(selectedAreaLight.skyR, selectedAreaLight.skyG, selectedAreaLight.skyB);
            Vector3 bottomColor = new Vector3(selectedAreaLight.groundR, selectedAreaLight.groundG, selectedAreaLight.groundB);

            ScreenDrawing.DrawQuadGradient(topColor, bottomColor, ScreenDrawing.screenQuadVbo);
        }
Esempio n. 4
0
        public BNTXEditor()
        {
            InitializeComponent();
            FilePath = "";
            Text     = "New Binary Texture";

            fw                     = new FileSystemWatcher();
            fw.Path                = Path.GetTempPath();
            fw.NotifyFilter        = NotifyFilters.Size | NotifyFilters.LastAccess | NotifyFilters.LastWrite;
            fw.EnableRaisingEvents = false;
            fw.Changed            += new FileSystemEventHandler(OnChanged);
            fw.Filter              = "";

            MenuItem export = new MenuItem("Export");

            export.Click += exportTextureToolStripMenuItem_Click;
            TextureMenu.MenuItems.Add(export);

            MenuItem replace = new MenuItem("Replace");

            replace.Click += replaceTextureToolStripMenuItem_Click;
            TextureMenu.MenuItems.Add(replace);

            OpenTKSharedResources.InitializeSharedResources();
            if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Initialized)
            {
                screenVao = ScreenDrawing.CreateScreenTriangleVao();
            }
        }
Esempio n. 5
0
        private void RenderTexture()
        {
            if (OpenTKSharedResources.SetupStatus != OpenTKSharedResources.SharedResourceStatus.Initialized || glControl1 == null)
            {
                return;
            }

            if (!OpenTKSharedResources.shaders["Texture"].LinkStatusIsOk)
            {
                return;
            }

            glControl1.MakeCurrent();
            GL.Viewport(glControl1.ClientRectangle);

            if (textureListBox.SelectedItem == null)
            {
                glControl1.SwapBuffers();
                return;
            }

            int width  = ((BRTI)textureListBox.SelectedItem).Width;
            int height = ((BRTI)textureListBox.SelectedItem).Height;

            Texture texture = ((BRTI)textureListBox.SelectedItem).display;

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            if (textureToRender != null)
            {
                ScreenDrawing.DrawTexturedQuad(textureToRender, width, height, screenTriangle, renderR, renderG, renderB, renderAlpha, keepAspectRatio, 1,
                                               currentMipLevel);
            }

            glControl1.SwapBuffers();
        }
        private void RenderTexture(bool justRenderAlpha = false)
        {
            if (OpenTKSharedResources.SetupStatus != OpenTKSharedResources.SharedResourceStatus.Initialized)
            {
                return;
            }

            if (!tabControl1.SelectedTab.Text.Equals("Textures"))
            {
                return;
            }

            if (!OpenTKSharedResources.shaders["Texture"].ProgramCreatedSuccessfully)
            {
                return;
            }

            // Get the selected NUT texture.
            NutTexture nutTexture     = null;
            int        displayTexture = 0;

            if (currentMaterialList[currentMatIndex].entries.ContainsKey("NU_materialHash") && texturesListView.SelectedIndices.Count > 0)
            {
                int hash = currentMaterialList[currentMatIndex].textures[texturesListView.SelectedIndices[0]].hash;

                // Display dummy textures from resources.
                if (Enum.IsDefined(typeof(NUD.DummyTextures), hash))
                {
                    displayTexture = RenderTools.dummyTextures[(NUD.DummyTextures)hash].Id;
                }
                else
                {
                    foreach (NUT n in Runtime.TextureContainers)
                    {
                        if (n.glTexByHashId.ContainsKey(hash))
                        {
                            n.getTextureByID(hash, out nutTexture);
                            displayTexture = n.glTexByHashId[hash].Id;
                            break;
                        }
                    }
                }
            }

            if (justRenderAlpha)
            {
                texAlphaGlControl.MakeCurrent();
                GL.Viewport(texAlphaGlControl.ClientRectangle);
                ScreenDrawing.DrawTexturedQuad(displayTexture, 1, 1, false, false, false, true);
                texAlphaGlControl.SwapBuffers();
            }
            else
            {
                texRgbGlControl.MakeCurrent();
                GL.Viewport(texRgbGlControl.ClientRectangle);
                ScreenDrawing.DrawTexturedQuad(displayTexture, 1, 1);
                texRgbGlControl.SwapBuffers();
            }
        }
Esempio n. 7
0
 private void DrawGradient(Vector3 topColor, Vector3 bottomColor)
 {
     if (screenTriangle == null)
     {
         screenTriangle = ScreenDrawing.CreateScreenTriangle();
     }
     ScreenDrawing.DrawQuadGradient(topColor, bottomColor, screenTriangle);
 }
Esempio n. 8
0
 private void glControl1_Load(object sender, System.EventArgs e)
 {
     OpenTKSharedResources.InitializeSharedResources();
     if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Initialized)
     {
         nut.RefreshGlTexturesByHashId();
         pngExportFramebuffer = new Framebuffer(FramebufferTarget.Framebuffer, glControl1.Width, glControl1.Height);
         screenTriangle       = ScreenDrawing.CreateScreenTriangle();
     }
 }
Esempio n. 9
0
    private void Awake()
    {
        m_collider = this.GetComponent <Collider>();
        cam        = Camera.main;


        ScreenDrawing s = FindObjectOfType <ScreenDrawing>();

        m_zOffset = s.m_zOffset;
    }
Esempio n. 10
0
 private void SetUpRendering()
 {
     // Make sure the shaders and textures are ready for rendering.
     OpenTKSharedResources.InitializeSharedResources();
     if (OpenTKSharedResources.SetupStatus == OpenTKSharedResources.SharedResourceStatus.Initialized)
     {
         currentNut.RefreshGlTexturesByHashId();
         pngExportFramebuffer = new Framebuffer(FramebufferTarget.Framebuffer, glControl1.Width, glControl1.Height);
         screenTriangle       = ScreenDrawing.CreateScreenTriangle();
     }
 }
Esempio n. 11
0
        private void RenderLightMapColor()
        {
            lightMapGLControl.MakeCurrent();
            GL.Viewport(lightMapGLControl.ClientRectangle);

            Vector3 topColor    = new Vector3(1);
            Vector3 bottomColor = new Vector3(1);

            ScreenDrawing.DrawQuadGradient(topColor, bottomColor, ScreenDrawing.screenQuadVbo);

            lightMapGLControl.SwapBuffers();
        }
Esempio n. 12
0
        private void glControl1_Paint(object sender, PaintEventArgs e)
        {
            if (OpenTKSharedResources.SetupStatus != OpenTKSharedResources.SharedResourceStatus.Initialized)
            {
                return;
            }

            glControl1.MakeCurrent();
            GL.Viewport(glControl1.ClientRectangle);
            // Draw darker to make the UVs visible.
            ScreenDrawing.DrawTexturedQuad(RenderTools.uvTestPattern.Id, 0.5f);
            NudUvRendering.DrawUv(polygonToRender, glControl1.Width, glControl1.Height);
            glControl1.SwapBuffers();
        }
Esempio n. 13
0
        private void RenderUvs()
        {
            glControl1.MakeCurrent();

            Mesh3D screenTriangle = ScreenDrawing.CreateScreenTriangle();


            GL.Viewport(glControl1.ClientRectangle);
            // Draw darker to make the UVs visible.
            ScreenDrawing.DrawTexturedQuad(RenderTools.uvTestPattern.Id, 0.5f, screenTriangle);

            DrawPolygonUvs();

            glControl1.SwapBuffers();
        }
Esempio n. 14
0
        private void RenderTexture()
        {
            int hash;

            glControl1.MakeCurrent();

            GL.Viewport(glControl1.ClientRectangle);

            if (lumen.Endian == 0)
            {
                foreach (NutTexture nutTexture in nut.Nodes)
                {
                    hash = nutTexture.HashId;
                    Texture texture = nut.glTexByHashId[hash];
                    int     width   = nutTexture.Width;
                    int     height  = nutTexture.Height;

                    GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);

                    ScreenDrawing.DrawTexturedQuad(texture, width, height, screenTriangle);
                }
                glControl1.SwapBuffers();
            }
            else
            {
                foreach (NutTexture nutTexture in nut.Nodes)
                {
                    hash = nutTexture.HashId;
                    Texture texture = nut.glTexByHashId[hash];
                    int     width   = nutTexture.Width;
                    int     height  = nutTexture.Height;

                    GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);

                    ScreenDrawing.DrawTexturedQuad(texture, width, height, screenTriangle);
                }
                glControl1.SwapBuffers();
            }
        }
Esempio n. 15
0
 private void RenderCharacterLightGradient(LightColor topColor, LightColor bottomColor)
 {
     ScreenDrawing.DrawQuadGradient(new Vector3(topColor.R, topColor.G, topColor.B), new Vector3(bottomColor.R, bottomColor.G, bottomColor.B), ScreenDrawing.screenQuadVbo);
 }
Esempio n. 16
0
        private void RenderTexture(bool justRenderAlpha = false)
        {
            if (OpenTKSharedResources.SetupStatus != OpenTKSharedResources.SharedResourceStatus.Initialized)
            {
                return;
            }

            if (!tabControl1.SelectedTab.Text.Equals("Textures"))
            {
                return;
            }

            if (!OpenTKSharedResources.shaders["Texture"].LinkStatusIsOk)
            {
                return;
            }

            // Get the selected NUT texture.
            NutTexture nutTexture     = null;
            Texture    displayTexture = null;

            if (currentMaterialList[currentMatIndex].entries.ContainsKey("NU_materialHash") && texturesListView.SelectedIndices.Count > 0)
            {
                int hash = currentMaterialList[currentMatIndex].textures[texturesListView.SelectedIndices[0]].hash;

                // Display dummy textures from resources.
                if (Enum.IsDefined(typeof(NudEnums.DummyTexture), hash))
                {
                    displayTexture = RenderTools.dummyTextures[(NudEnums.DummyTexture)hash];
                }
                else
                {
                    foreach (NUT n in Runtime.TextureContainers)
                    {
                        if (n.glTexByHashId.ContainsKey(hash))
                        {
                            n.getTextureByID(hash, out nutTexture);
                            displayTexture = n.glTexByHashId[hash];
                            break;
                        }
                    }
                }
            }

            // We can't share these vaos across both contexts.
            if (justRenderAlpha)
            {
                texAlphaGlControl.MakeCurrent();

                Mesh3D screenTriangle = ScreenDrawing.CreateScreenTriangle();

                GL.Viewport(texAlphaGlControl.ClientRectangle);
                if (displayTexture != null)
                {
                    ScreenDrawing.DrawTexturedQuad(displayTexture, 1, 1, screenTriangle, false, false, false, true);
                }
                texAlphaGlControl.SwapBuffers();
            }
            else
            {
                texRgbGlControl.MakeCurrent();

                Mesh3D screenTriangle = ScreenDrawing.CreateScreenTriangle();

                GL.Viewport(texRgbGlControl.ClientRectangle);
                if (displayTexture != null)
                {
                    ScreenDrawing.DrawTexturedQuad(displayTexture, 1, 1, screenTriangle);
                }
                texRgbGlControl.SwapBuffers();
            }
        }