can i use opentk and xna in the same project and showing the data on the same window? Does OpenTk Support Xna?

121 views Asked by At

there is somthing i want to draw using xna in the same window of OpenTk Project but i'm Starter in Xna so i don't know if that possible

i want to draw Xna in this method if that possible:

private void glControl1_Paint(object sender, PaintEventArgs e)
    {
        if (!glcontrol1_isloaded) return;
        glControl1.MakeCurrent();
        GL.MatrixMode(MatrixMode.Modelview);
        GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
        GL.LoadIdentity();
        Scientifical_Calculations.Camara.Update(moviendo);

        IntPtr sf = Glu.NewQuadric();

        GL.Translate(0, 0, 0);
        GL.Color3(Color.White);
        GL.Enable(EnableCap.Texture2D);
        Gl.glBindTexture(Gl.GL_TEXTURE_2D, suntext);
        Glu.QuadricTexture(sf, true);
        Glu.Sphere(sf, 10, 35, 35);
        GL.Disable(EnableCap.Texture2D);
        Stars.Draw();

        glControl1.SwapBuffers();


    }

i don't really know if any one tried this before but i hope so

1

There are 1 answers

0
The Fiddler On BEST ANSWER

XNA is using Direct3d, whereas OpenTK is OpenGL. In the general case, you cannot draw using OpenGL into a Direct3d window.[1]

What you can do is switch from XNA to MonoGame. It is an open-source implementation of XNA and supports both Direct3d and OpenGL. If you use the OpenGL version, you will be able to draw into the same window using both XNA and OpenTK.

[1] WGL_NV_DX_interop allows you to share textures and renderbuffers between OpenGL and Direct3d, so it might be possible to make this work on some systems. I would advise against it, unless you really know what you are doing.