コード例 #1
0
        public void Create(GLItemsList items, GLRenderProgramSortedList rObjects, List <SystemClass> incomingsys, float bookmarksize, GLStorageBlock findbufferresults, bool depthtest)
        {
            if (ridisplay == null)
            {
                //var vert = new GLPLVertexScaleLookat(rotate: dorotate, rotateelevation: doelevation, commontransform: false, texcoords: true,      // a look at vertex shader
                //
                //                var vert = new GLPLVertexShaderWorldCoord();
                var vert = new GLPLVertexScaleLookat(rotatetoviewer: dorotate, rotateelevation: doelevation, texcoords: true, generateworldpos: true,
                                                     autoscale: 500, autoscalemin: 1f, autoscalemax: 20f);            // below 500, 1f, above 500, scale up to 20x


                const int texbindingpoint = 1;
                var       frag            = new GLPLFragmentShaderTexture(texbindingpoint); // binding - simple texturer based on vs model coords

                objectshader = new GLShaderPipeline(vert, null, null, null, frag);
                items.Add(objectshader);

                var objtex = items.NewTexture2D("Bookmarktex", TestOpenTk.Properties.Resources.dotted2, OpenTK.Graphics.OpenGL4.SizedInternalFormat.Rgba8);

                objectshader.StartAction += (s, m) =>
                {
                    objtex.Bind(texbindingpoint);   // bind tex array to, matching above
                };

                bookmarkposbuf = items.NewBuffer();         // where we hold the vertexes for the suns, used by renderer and by finder

                GLRenderState rt = GLRenderState.Tri();
                rt.DepthTest = depthtest;

                bookmarksize *= 10;

                // 0 is model pos, 1 is world pos by a buffer, 2 is tex co-ords
                ridisplay = GLRenderableItem.CreateVector4Vector4Vector2(items, OpenTK.Graphics.OpenGL4.PrimitiveType.TriangleStrip, rt,
                                                                         GLShapeObjectFactory.CreateQuadTriStrip(bookmarksize, bookmarksize), // quad2 4 vertexts as the model positions
                                                                         bookmarkposbuf, 0,                                                   // world positions come from here - not filled as yet
                                                                         GLShapeObjectFactory.TexTriStripQuad,
                                                                         ic: 0, seconddivisor: 1);

                rObjects.Add(objectshader, "bookmarks", ridisplay);

                var geofind = new GLPLGeoShaderFindTriangles(findbufferresults, 16);//, forwardfacing:false);
                findshader = items.NewShaderPipeline(null, vert, null, null, geofind, null, null, null);

                // hook to modelworldbuffer, at modelpos and worldpos.  UpdateEnables will fill in instance count
                rifind = GLRenderableItem.CreateVector4Vector4Vector2(items, OpenTK.Graphics.OpenGL4.PrimitiveType.TriangleStrip, rt,
                                                                      GLShapeObjectFactory.CreateQuadTriStrip(bookmarksize, bookmarksize),   // quad2 4 vertexts as the model positions
                                                                      bookmarkposbuf, 0,
                                                                      GLShapeObjectFactory.TexTriStripQuad,
                                                                      ic: 0, seconddivisor: 1);
            }

            bookmarkposbuf.AllocateFill(incomingsys.Select(x => new Vector4((float)x.X, (float)x.Y, (float)x.Z, 1)).ToArray());
            ridisplay.InstanceCount = rifind.InstanceCount = incomingsys.Count;
        }
コード例 #2
0
ファイル: Bookmarks.cs プロジェクト: EDDiscovery/EDDiscovery
        public void Start(GLItemsList items, GLRenderProgramSortedList rObjects, float bookmarksize, GLStorageBlock findbufferresults, bool depthtest)
        {
            var vert = new GLPLVertexScaleLookat(rotatetoviewer: dorotate, rotateelevation: doelevation, texcoords: true, generateworldpos: true,
                                                 autoscale: 30, autoscalemin: 1f, autoscalemax: 30f);            // above autoscale, 1f

            const int texbindingpoint = 1;
            var       frag            = new GLPLFragmentShaderTexture(texbindingpoint); // binding - simple texturer based on vs model coords

            objectshader = new GLShaderPipeline(vert, null, null, null, frag);
            items.Add(objectshader);

            var objtex = items.NewTexture2D("Bookmarktex", BaseUtils.Icons.IconSet.GetBitmap("GalMap.Bookmark"), OpenTK.Graphics.OpenGL4.SizedInternalFormat.Rgba8);

            objectshader.StartAction += (s, m) =>
            {
                objtex.Bind(texbindingpoint);   // bind tex array to, matching above
            };

            bookmarkposbuf = items.NewBuffer();         // where we hold the vertexes for the suns, used by renderer and by finder

            GLRenderState rt = GLRenderState.Tri();

            rt.DepthTest = depthtest;

            // 0 is model pos, 1 is world pos by a buffer, 2 is tex co-ords
            ridisplay = GLRenderableItem.CreateVector4Vector4Vector2(items, OpenTK.Graphics.OpenGL4.PrimitiveType.TriangleStrip, rt,
                                                                     GLShapeObjectFactory.CreateQuadTriStrip(bookmarksize, bookmarksize), // quad2 4 vertexts as the model positions
                                                                     bookmarkposbuf, 0,                                                   // world positions come from here - not filled as yet
                                                                     GLShapeObjectFactory.TexTriStripQuad,
                                                                     ic: 0, seconddivisor: 1);

            rObjects.Add(objectshader, "bookmarks", ridisplay);

            var geofind = new GLPLGeoShaderFindTriangles(findbufferresults, 16);//, forwardfacing:false);

            findshader = items.NewShaderPipeline(null, vert, null, null, geofind, null, null, null);

            // hook to modelworldbuffer, at modelpos and worldpos.  UpdateEnables will fill in instance count
            rifind = GLRenderableItem.CreateVector4Vector4Vector2(items, OpenTK.Graphics.OpenGL4.PrimitiveType.TriangleStrip, rt,
                                                                  GLShapeObjectFactory.CreateQuadTriStrip(bookmarksize, bookmarksize),   // quad2 4 vertexts as the model positions
                                                                  bookmarkposbuf, 0,
                                                                  GLShapeObjectFactory.TexTriStripQuad,
                                                                  ic: 0, seconddivisor: 1);
        }