Fidchells_eye's picture

ABS newbie trying to get it to work

Fidchells_eye here again

I am converting an old C++ to C#
But before i can continue to do that I need the test render function DrawX() to draw an X on screen
But my setup function is failing, due to GL being NULL.

The structure of the project is;
BaseScope is inherited into any ToolScope Class.
The BaseScope class is used in the ModularScopeDisplay class so I can switch the tools as needed

The main does have a GLControl called GLDisplay1.

public class ModularScopeDisplay
{
#region Data
ScopeBase sBase;
#endregion
public ModularScopeDisplay(OpenTK.GLControl GL_Display, ScopeBase.ScopeMode mode)
{
if (mode == ScopeBase.ScopeMode.WFM)
{
sBase = new Scope_WFM(ref GL_Display);
}
//gl = GL_Display;
}
}

public abstract class ScopeBase
{
...
protected OpenTK.Graphics.OpenGL.GL gl;
...
}
public class Scope_WFM:ScopeBase
{
.....
}


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
haplokuon's picture

In your first post you wrote that you were converting an existing code form c++ to c#, so I will assume that the values of the original code for the proyection and the camera get the result as you want. It seems that you want to draw a cross from one corner to the opposite of the viewport.

Besides that, the problem I see is that you are not specifying the colors for the background and the lines. Never tried but it might be that, by default, it uses white; so you are drawing two white lines in a white background.

For the background color use GL.ClearColor before calling GL.Clear, and for the lines use GL.Color before drawing the lines.

I will recommend to study the examples provided in the OpenTK examples for the proper way of using OpenGL with OpenTK and handling the events in a windows form with a GLControl. There are a some very basic examples that will help you.

haplokuon's picture

Sorry double post.

Fidchells_eye's picture

No that did not work.

It's still white.

Does the GL control have or need a connection function to a class that is executing the GL commands?
Is there a makecontext function I need to call?

haplokuon's picture

Oh, I forgot one more thing that is needed at the end of the DrawX function to swap the buffers by means of openglControl.SwapBuffers().

I still recommend to start with one of the simplest OpenTK examples that make use of GLControl and modified it with your own code.

Fidchells_eye's picture

That was the final piece and the test function works.
Thanks.