OpenTK SEMI-TRANSMISSION METHOD

Asked 2 years ago, Updated 2 years ago, 119 views

I am currently drawing 3D graphics using C#OpenTK

For questions, please let me know if it is possible to GL.Clear in semi-transparent black (0,0,0,0.5).

Currently, I draw music waveforms using Lines
At that time, instead of clearing it in black every time,

by clearing in semi-transparent black I'm thinking that the line in front of one frame will be thin and the production will look like a blur.
Even if GL.ClearColor (0,0,0,0.5) is
It can only be cleared in black without transparency, and translucent lines will not remain.

Would it be possible to leave the color of the previous frame transparent?

I would appreciate it if you could let me know.
Thank you for your cooperation

protected override void OnRenderFrame (FrameEventArgse)
{
        GL.ClearColor (0.0f, 0.0f, 0.0f);

        GL.Clear (ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

        GL.Begin (BeginMode.Lines);

        int N = dataset.Length;
        for (int n = 1; n<N;n++)
        {
            float v1 = dataset [n-1];
            float v2 = dataset [n];

            Vector3zero=0.5f*(py-p0)+p0;
            Vector3nx = px-p0;

            Vector3 P1 = zero+nx*(float)(n-1)/N;
            Vector3 P2 = zero+nx*(float)n/N;

            Vector3Value1 = v1*(py-p0)*0.5f;
            Vector3Value2 = v2*(py-p0)*0.5f;

            P1 = P1 + Value1;
            P2 = P2 + Value 2;

            GL.Color3 (Color.Red);
            GL.Vertex3 (P1);
            GL.Vertex3 (P2);

        }
        GL.End();

        // SwapBuffer
        SwapBuffers();
    }

c# opengl

2022-09-30 21:29

1 Answers

When you ask questions, be sure to write down the environmental information first as a minimum of manners.
The OS, device drivers, IDE, SDK, library and other versions, hardware model numbers, and more.

Pattern language when asking questions in technical mailing lists

While glClearColor() and glClear() can clear alpha channels to any value (uniform setting), the behavior is only clear and does not blend the values to suit the previous drawing results.Also, the default frame buffer (back buffer) is always impermeable.

Use Frame Buffer Object (FBO) if you want OpenGL to synthesize with the previous (pre-frame) drawing results.Save the drawing results in a 2D texture and paste them into a rectangular polygon in the next frame for alpha synthesis.The buffers are ping-ponged.

  • [Initialization process below]
    1. Create 2 FBO and 2 RGBA2D textures (Deep Buffer Creation Optional)
    2. Bind 2D textures to their respective FBOs ( depth buffer binding is optional)
  • [Rendering loop below]
    1. Bind FBO#1 to GL context (drawing target will be 2D texture#1)
    2. Clear with
    3. (0,0,0,0)
    4. Disable depth buffer write and equal magnification of 2D texture #2 translucent drawing
    5. Enable depth buffer write to render scenes
    6. Bind Back Buffer (Frame Buffer 0) to GL Context
    7. Clear with any background color and draw 2D texture #1 in equal magnification
    8. Bind FBO#2 to GL context (drawing target will be 2D texture#2)
    9. Clear with
    10. (0,0,0,0)
    11. Disable depth buffer write and equal magnification of 2D texture #1 translucent drawing
    12. Enable depth buffer write to render scenes
    13. Bind Back Buffer (Frame Buffer 0) to GL Context
    14. Clear with any background color and draw 2D texture #2 in equal magnification
    15. Bind FBO#1 to GL context (drawing target will be 2D texture#1)
    16. Clear with
    17. (0,0,0,0)
    18. Disable depth buffer write and equal magnification of 2D texture #2 translucent drawing
    19. Enable depth buffer write to render scenes
    20. Bind Back Buffer (Frame Buffer 0) to GL Context
    21. Clear with any background color and draw 2D texture #1 in equal magnification
      ...

However, FBO is a standardized feature in OpenGL 3.0, and is provided as an enhanced GL_EXT_framebuffer_object in OpenGL 2.1 and earlier.Another method is to use a pixel buffer object (PBO), which is standardized in OpenGL 2.1, and is provided as an enhanced GL_ARB_pixel_buffer_object in OpenGL 2.0 and earlier.

You can also use a computer shader to draw 2D textures equally translucent.

C#/OpenTK information is probably hard to get, and both quality and quantity are low, so it's faster to look for C/C++ information.


2022-09-30 21:29

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.