コード例 #1
0
        private static GLDisplayList CreateCube(GLContext ctx)
        {
            GLDisplayList list = new GLDisplayList(ctx);

            list.Begin();

            ctx.glBegin(GLPrimitiveType.QuadStrip);

            Vector3 p1 = new Vector3(0);
            Vector3 p2 = new Vector3(0.99f);

            ctx.glVertex(p1._x, p1._y, p1._z);
            ctx.glVertex(p1._x, p2._y, p1._z);
            ctx.glVertex(p2._x, p1._y, p1._z);
            ctx.glVertex(p2._x, p2._y, p1._z);
            ctx.glVertex(p2._x, p1._y, p2._z);
            ctx.glVertex(p2._x, p2._y, p2._z);
            ctx.glVertex(p1._x, p1._y, p2._z);
            ctx.glVertex(p1._x, p2._y, p2._z);
            ctx.glVertex(p1._x, p1._y, p1._z);
            ctx.glVertex(p1._x, p2._y, p1._z);

            ctx.glEnd();

            ctx.glBegin(GLPrimitiveType.Quads);

            ctx.glVertex(p1._x, p2._y, p1._z);
            ctx.glVertex(p1._x, p2._y, p2._z);
            ctx.glVertex(p2._x, p2._y, p2._z);
            ctx.glVertex(p2._x, p2._y, p1._z);

            ctx.glVertex(p1._x, p1._y, p1._z);
            ctx.glVertex(p1._x, p1._y, p2._z);
            ctx.glVertex(p2._x, p1._y, p2._z);
            ctx.glVertex(p2._x, p1._y, p1._z);

            ctx.glEnd();

            list.End();
            return(list);
        }
コード例 #2
0
        private static GLDisplayList CreateLine(GLContext ctx)
        {
            GLDisplayList list = new GLDisplayList(ctx);

            ctx.glBegin(GLPrimitiveType.Lines);

            ctx.glVertex(0.0f, 0.0f, 0.0f);
            ctx.glVertex(2.0f, 0.0f, 0.0f);

            ctx.glEnd();

            list.End();
            return(list);
        }
コード例 #3
0
        private static GLDisplayList CreateRing(GLContext ctx)
        {
            GLDisplayList list = new GLDisplayList(ctx);

            list.Begin();

            ctx.glBegin(GLPrimitiveType.LineLoop);

            float angle = 0.0f;

            for (int i = 0; i < 360; i++, angle = i * Maths._deg2radf)
            {
                ctx.glVertex(Math.Cos(angle), Math.Sin(angle));
            }

            ctx.glEnd();

            list.End();
            return(list);
        }
コード例 #4
0
        internal unsafe void Render(GLContext context, uint[] texIds)
        {
            if (!_enabled)
            {
                return;
            }

            //context.glEnable(GLEnableCap.Texture2D);

            if (_parent._uvData[0] == null)
            {
                return;
            }

            //Vector3* vPtr = (Vector3*)_parent._vertices.Address;
            //Vector3* nPtr = _parent._normals != null ? (Vector3*)_parent._normals.Address : null;
            ARGBPixel *c1Ptr = _parent._colors1 != null ? (ARGBPixel *)_parent._colors1.Address : null;
            ARGBPixel *c2Ptr = _parent._colors2 != null ? (ARGBPixel *)_parent._colors2.Address : null;
            //Vector2* uvPtr = _parent._uvData[0] != null ? (Vector2*)_parent._uvData[0].Address : null;

            int numUV = 0;

            Vector2 *[] uPtrs = new Vector2 *[8];
            while (_parent._uvData[numUV] != null)
            {
                uPtrs[numUV] = (Vector2 *)_parent._uvData[numUV].Address;
                numUV++;
            }

            Vector3 v, n;
            Vector2 u;
            uint    id;

            fixed(Vector3 *vPtr = _vertices)
            fixed(Vector3 * nPtr = _normals)
            {
                for (int t = 0; t < 1; t++)
                {
                    if ((id = texIds[t]) == 0)
                    {
                        continue;
                    }

                    context.glBindTexture(GLTextureTarget.Texture2D, id);
                    context.glBegin(_type);
                    for (int i = 0; i < _elements; i++)
                    {
                        if (c1Ptr != null)
                        {
                            context.glColor4((byte *)&c1Ptr[_colorIndices[0][i]]);
                        }
                        //if(c2Ptr != null)
                        //    context.glColor4((byte*)&c2Ptr[_colorIndices[1][i]]);

                        context.glNormal((float *)&nPtr[i]);

                        context.glTexCoord2((float *)&uPtrs[0][_uvIndices[0][i]]);
                        //u = uPtrs[t][_uvIndices[t][i]];
                        //context.glTexCoord2((float*)&u);

                        context.glVertex3v((float *)&vPtr[i]);
                    }
                    context.glEnd();
                }
            }
            context.CheckErrors();
        }