Acidic32's picture

Enable WGL Access

Project:The Open Toolkit library
Version:all versions
Component:Code
Category:support request
Priority:critical
Assigned:Unassigned
Status:by design
Description

How can i enable WGL Access in OpenTK?

I dont want to include Tao's Platform class if possible

Thanks


Comments

Comment viewing options

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

#11

Right, Wgl.Library is a constant that should be set to "opengl32.dll":

const string Library = "opengl32.dll";

There's no need to load the library or anything like that, the runtime should take care of that.

Acidic32's picture

#12

Just having slight problem

Text priting is really slow, i tried text printer but its still the same

I have tried using Outline fonts, but dont now how to instaniate GlymphMetricFloats

ANy ideas on how to achieve fast text rendering.

the Fiddler's picture

#13

Have you tried objarni's TexLib? It allows you to create and use texture fonts, which should be very fast.

Acidic32's picture

#14

I must not be doing this right, but its hanging

// Load a bitmap from disc, and put it in a GL texture.
var tex = TexUtil.CreateTextureFromFile("fontmap.bmp");

var texFont = new TexLib.TextureFont(tex);
texFont.WriteStringAt("Center", 1, 50, 50, 0);

inside the Draw Routine

TexUtil.InitTexturing();

inside the Initialization routine

Acidic32's picture

#15

Maybe its my Image ? :(

the Fiddler's picture

#16

Sorry, no idea... You'll have to create a bug report against the TexLib library.

That said, the source code is quite short and should be relatively simple to debug. Try placing a few breakpoints and seeing where exactly it hangs.

Acidic32's picture

#17

ok, but its weird, my way is fast, when there is only a little bit of text, put lots of text, it slows a hell of a lot, there is about 2,000 text it needs to print, it just slows when zooming/panning. A program similar to mine, has the same if not more, and its fast

I just dont understand how? Maybe need to send all my text to a DisplayList and call that, but not sure if that would speed things up, as it needs to be re-projected everytime we pan, but it stays in same location when we zoom..

Hrmm

This is my current routine:

        public void Draw()
        {
            this.oglRadar.MakeCurrent();
            var paramsa = new double[16];
            var numArray2 = new double[16];
            var numArray3 = new int[4];
 
 
            var FIXsProjected = new List<Projected>();
            var NDBsProjected = new List<ProjectedFreq>();
            var VORsProjected = new List<ProjectedFreq>();
            var AirportsProjected = new List<ProjectedFreq>();
 
            var InV = new Vector3();
            var OutV = new Vector3();
 
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.Translate(-this.Center.Lon, -this.Center.Lat, 0);
            GL.GetDouble(GetPName.ModelviewMatrix, paramsa);
            GL.GetDouble(GetPName.ProjectionMatrix, numArray2);
            GL.GetInteger(GetPName.Viewport, numArray3);
 
 
            this.Draw_DisplayLists();
 
 
                if (Configuration.Instance.ShowFIX && (SectorFile.Instance.SectorLoaded))
                    //Save time, if they dont want it, dont loop!
                {
                    foreach (var fixline in SectorFile.Instance.Fixes)
                    {
                        InV.X = (float) fixline.Value.Longitude + (0*360);
                        InV.Y = (float) fixline.Value.Latitude;
                        InV.Z = (float) 0.5;
 
                        Glu.Project(InV, paramsa, numArray2, numArray3, out OutV);
                        FIXsProjected.Add(new Projected((int) OutV.X, (int) OutV.Y, fixline.Key));
 
                    }
                }
 
                if ((Configuration.Instance.ShowVOR) && (SectorFile.Instance.SectorLoaded))
                    //Save time, if they dont want it, dont loop! 
                {
                    foreach (var vorline in SectorFile.Instance.VORs)
                    {
                        InV.X = (float) vorline.Coord.Longitude + (0*360);
                        InV.Y = (float) vorline.Coord.Latitude;
                        InV.Z = (float) 0.5;
                        Glu.Project(InV, paramsa, numArray2, numArray3, out OutV);
                        VORsProjected.Add(new ProjectedFreq((int) OutV.X, (int) OutV.Y, vorline.Name, vorline.Freq));
                    }
                }
 
                if (Configuration.Instance.ShowNDB && (SectorFile.Instance.SectorLoaded))
                    //Save time, if they dont want it, dont loop!
                {
                    foreach (var ndbline in SectorFile.Instance.NDBs)
                    {
                        InV.X = (float) ndbline.Coord.Longitude + (0*360);
                        InV.Y = (float) ndbline.Coord.Latitude;
                        InV.Z = (float) 0.5;
                        Glu.Project(InV, paramsa, numArray2, numArray3, out OutV);
                        NDBsProjected.Add(new ProjectedFreq((int) OutV.X, (int) OutV.Y, ndbline.Name, ndbline.Freq));
                    }
                }
 
                if (Configuration.Instance.ShowAirport && (SectorFile.Instance.SectorLoaded))
                    //Save time, if they dont want it, dont loop!
                {
                    foreach (var airportline in SectorFile.Instance.Airports)
                    {
                        InV.X = (float) airportline.Coord.Longitude + (0*360);
                        InV.Y = (float) airportline.Coord.Latitude;
                        InV.Z = (float) 0.5;
                        Glu.Project(InV, paramsa, numArray2, numArray3, out OutV);
                        AirportsProjected.Add(new ProjectedFreq((int) OutV.X, (int) OutV.Y, airportline.Name,
                                                                airportline.Freq));
                    }
                }
 
 
 
            GL.MatrixMode(MatrixMode.Projection);
            GL.PushMatrix();
            GL.MatrixMode(MatrixMode.Modelview);
            GL.PushMatrix();
            GL.MatrixMode(MatrixMode.Projection);
            GL.LoadIdentity();
            GL.Ortho(0.0, (this.oglRadar.ClientSize.Width - 1), 0.0,
                     (this.oglRadar.ClientSize.Height - 1),
                     1.0, 5.0);
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            GL.MatrixMode(MatrixMode.Modelview);
            GL.LoadIdentity();
            var graphics = Graphics.FromHdc(Program.GetCurrentDC());
            this.Draw_AtisAndClock();
 
            if (Configuration.Instance.ShowFlightStrip)
            this.Draw_FlightStrip();
 
                if (Configuration.Instance.ShowFIX && (SectorFile.Instance.SectorLoaded))
                    //They want to see it! :)
                {
                    SetColor(Configuration.Instance.ColorFIX);
                    foreach (var info in FIXsProjected)
                    {
                    GL.Begin(BeginMode.Triangles);
                    GL.Vertex3((info.screenloc.X), (info.screenloc.Y + 2), -4.4);
                    GL.Vertex3((info.screenloc.X - 2), (info.screenloc.Y - 2), -4.4);
                    GL.Vertex3((info.screenloc.X + 2), (info.screenloc.Y - 2), -4.4);
                    GL.End();
 
                    if (Configuration.Instance.ShowFIXname)
                    {
                        SetColor(Configuration.Instance.ColorFIXName);
                        PrintString(info.screenloc.X + 2, info.screenloc.Y + 1, -1.2, this.pFontListNavData,
                                    info.name);
                    }
                }
        }
 
 
            GL.PopMatrix();
            GL.MatrixMode(MatrixMode.Projection);
            GL.PopMatrix();
            GL.Flush();
        }
Acidic32's picture

#18

And this is my printing routine

        private void BuildFonts()
        {
            var deviceContext = Program.GetCurrentDC();
            this.pFontNavData = new Font("Terminal", 7.0F, FontStyle.Regular);
            Program.SelectObject(deviceContext, new Font("Terminal", 7.0F, FontStyle.Regular).ToHfont());
            Program.UseFontBitmapsA(deviceContext, 32, 224, this.pFontListNavData);
}
        private void PrintString(double lon, double lat, double z, int listBase, string text)
        {
            // Pust the ListBit Attribute
            GL.PushAttrib(AttribMask.ListBit);
 
            // Raster the position
            GL.RasterPos3(lon, lat, z);
 
            // Call the List
            GL.ListBase(listBase - 32);
            GL.CallLists(text.Length, ListNameType.UnsignedShort, text);
 
            // Pop the ListBit Attribute
            GL.PopAttrib();
        }
objarni's picture

#19

Acidic32;

You seem to be mixing GDI and OpenTK since you are using both HDC's and GL.* calls.

I don't know whether that mix works at all..?

Acidic32's picture

#20

It works, its just text when its displayed slows the rendeing down by 5 times

ie without text stopwatch reports 30ms-40ms

with text stopwatch reports 200ms +

Mmmm Need some fast text display