public Core()
        {
            TextureHandle bufferTexture = new TextureHandle();

            SingleBuffer buffer = new SingleBuffer();
            buffer.Load = true;
            buffer.Texture = bufferTexture;
            Effects.Add(buffer);

            ClearScreen clear = new ClearScreen();
            clear.ClearColor = new Color(0, 0, 0, 0.085f);
            Effects.Add(clear);

            Effects.Add(new RandomMovement());

            Effects.Add(new CustomScope());
            Effects.Add(new OrangeScope());

            buffer = new SingleBuffer();
            buffer.Load = false;
            buffer.Texture = bufferTexture;
            Effects.Add(buffer);

            Effects.Add(new CircularMovement());
        }
        public Core()
        {
            TextureHandle bufferTexture = new TextureHandle();
            
            SingleBuffer buffer = new SingleBuffer();
            buffer.Load = true;
            buffer.Texture = bufferTexture;
            this.Effects.Add(buffer);
            
            ClearScreen clear = new ClearScreen();
            clear.ClearColor = new Color(0, 0, 0, 0.085f);
            this.Effects.Add(clear);

            this.Effects.Add(new RandomMovement());

            this.Effects.Add(new CustomScope());

            Scope scope = new Scope();
            scope.Color = new Color(1, 0.5f, 0, 1);
            scope.Circular = true;
            scope.LineWidth = 3;
            this.Effects.Add(scope);

            buffer = new SingleBuffer();
            buffer.Load = false;
            buffer.Texture = bufferTexture;
            this.Effects.Add(buffer);
            
            this.Effects.Add(new CircularMovement());
        }
Example #3
0
 public static void ConvertOrientation(float[] forward, float[] up, SingleBuffer orientation)
 {
     orientation.Put(0, forward[0]);
     orientation.Put(1, forward[2]);
     orientation.Put(2, -forward[1]);
     orientation.Put(3, up[0]);
     orientation.Put(4, up[2]);
     orientation.Put(5, -up[1]);
 }
Example #4
0
 public VeldridSpriteBatch(SpriteKey key) : base(key)
 {
     Instances = new MultiBuffer <GpuSpriteInstanceData>(MinSize, BufferUsage.VertexBuffer, $"B_Inst:{Name}");
     Uniform   = new SingleBuffer <SpriteUniform>(new SpriteUniform
     {
         Flags         = Key.Flags,
         TextureWidth  = key.Texture.Width,
         TextureHeight = key.Texture.Height
     }, BufferUsage.UniformBuffer, $"B_SpriteUniform:{Name}");
     AttachChild(Instances);
     AttachChild(Uniform);
 }
Example #5
0
        public override void GL_SetDefaultState()
        {
            GL.ClearColor(1F, 0F, 0.5F, 0.5F);
            GL.CullFace(CullFaceMode.Front);
            GL.Enable(EnableCap.Texture2D);
            GL.Enable(EnableCap.AlphaTest);
            GL.AlphaFunc(AlphaFunction.Greater, 0.666F);
            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);
            GL.Disable(EnableCap.Blend);
            GL.Color4(1, 1, 1, 1);
            GL.PolygonMode(MaterialFace.FrontAndBack, PolygonMode.Fill);
            GL.ShadeModel(ShadingModel.Flat);
            GL_TextureMode(gl_texturemode.string_renamed);
            GL_TextureAlphaMode(gl_texturealphamode.string_renamed);
            GL_TextureSolidMode(gl_texturesolidmode.string_renamed);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, gl_filter_min);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, gl_filter_max);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)All.Repeat);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)All.Repeat);
            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            GL_TexEnv((int)All.Replace);
            if (qglPointParameterfEXT)
            {
                SingleBuffer att_buffer = Lib.NewSingleBuffer(4);
                att_buffer.Put(0, gl_particle_att_a.value);
                att_buffer.Put(1, gl_particle_att_b.value);
                att_buffer.Put(2, gl_particle_att_c.value);
                GL.Enable(EnableCap.PointSmooth);
                GL.PointParameter(PointParameterName.PointSizeMin, gl_particle_min_size.value);
                GL.PointParameter(PointParameterName.PointSizeMax, gl_particle_max_size.value);
                GL.PointParameter(PointParameterName.PointDistanceAttenuation, att_buffer.Array);
            }

            if (qglColorTableEXT && gl_ext_palettedtexture.value != 0F)
            {
                GL.Enable(EnableCap.SharedTexturePaletteExt);
                GL_SetTexturePalette(d_8to24table);
            }

            GL_UpdateSwapInterval();
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.ClientActiveTexture(TextureUnit.Texture0);
            GL.EnableClientState(ArrayCap.TextureCoordArray);
        }
Example #6
0
        public virtual void AddParticle(float[] org, int color, float alpha)
        {
            if (r_numparticles >= Defines.MAX_PARTICLES)
            {
                return;
            }
            int i = r_numparticles++;
            int c = particle_t.colorTable[color];

            c |= (int)(alpha * 255) << 24;
            particle_t.colorArray.Put(i, c);
            i *= 3;
            SingleBuffer vertexBuf = particle_t.vertexArray;

            vertexBuf.Put(i++, org[0]);
            vertexBuf.Put(i++, org[1]);
            vertexBuf.Put(i++, org[2]);
        }
Example #7
0
        public static void AddParticle(Single[] org, Int32 color, Single alpha)
        {
            if (r_numparticles >= MAX_PARTICLES)
            {
                return;
            }
            var i = r_numparticles++;
            var c = particle_t.colorTable[color];

            c |= ( Int32 )(alpha * 255) << 24;
            particle_t.colorArray.Put(i, c);
            i *= 3;
            SingleBuffer vertexBuf = particle_t.vertexArray;

            vertexBuf.Put(i++, org[0]);
            vertexBuf.Put(i++, org[1]);
            vertexBuf.Put(i++, org[2]);
        }
Example #8
0
    internal SkyboxRenderable(ITextureHolder texture, ISamplerHolder sampler, SkyboxManager manager)
    {
        if (texture == null)
        {
            throw new ArgumentNullException(nameof(texture));
        }
        if (sampler == null)
        {
            throw new ArgumentNullException(nameof(sampler));
        }
        _manager = manager;

        _uniformBuffer = new SingleBuffer <SkyboxUniformInfo>(new SkyboxUniformInfo(), BufferUsage.UniformBuffer, "SpriteUniformBuffer");
        ResourceSet    = new SkyboxResourceSet
        {
            Name    = $"RS_Sky:{texture.Name}",
            Texture = texture,
            Sampler = sampler,
            Uniform = _uniformBuffer
        };

        AttachChild(_uniformBuffer);
        AttachChild(ResourceSet);

        On <EngineUpdateEvent>(_ =>
        {
            var config = Resolve <CoreConfig>().Visual.Skybox;
            if (Resolve <ICamera>() is not PerspectiveCamera camera)
            {
                return;
            }

            _uniformBuffer.Data = new SkyboxUniformInfo
            {
                uYaw               = camera.Yaw,
                uPitch             = camera.Pitch,
                uVisibleProportion = config.VisibleProportion
            };
        });
    }
Example #9
0
        public virtual void GL_DrawParticles(Int32 num_particles)
        {
            Single origin_x, origin_y, origin_z;

            Math3D.VectorScale(vup, 1.5F, up);
            Math3D.VectorScale(vright, 1.5F, right);
            GL_Bind(r_particletexture.texnum);
            GL.DepthMask(false);
            GL.Enable(EnableCap.Blend);
            GL_TexEnv(( Int32 )All.Modulate);
            GL.Begin(PrimitiveType.Triangles);
            SingleBuffer sourceVertices = particle_t.vertexArray;
            Int32Buffer  sourceColors   = particle_t.colorArray;
            Single       scale;
            Int32        color;

            for (Int32 j = 0, i = 0; i < num_particles; i++)
            {
                origin_x = sourceVertices.Get(j++);
                origin_y = sourceVertices.Get(j++);
                origin_z = sourceVertices.Get(j++);
                scale    = (origin_x - r_origin[0]) * vpn[0] + (origin_y - r_origin[1]) * vpn[1] + (origin_z - r_origin[2]) * vpn[2];
                scale    = (scale < 20) ? 1 : 1 + scale * 0.004F;
                color    = sourceColors.Get(i);
                GL.Color4(( Byte )((color) & 0xFF), ( Byte )((color >> 8) & 0xFF), ( Byte )((color >> 16) & 0xFF), ( Byte )((color >> 24)));
                GL.TexCoord2(0.0625F, 0.0625F);
                GL.Vertex3(origin_x, origin_y, origin_z);
                GL.TexCoord2(1.0625F, 0.0625F);
                GL.Vertex3(origin_x + up[0] * scale, origin_y + up[1] * scale, origin_z + up[2] * scale);
                GL.TexCoord2(0.0625F, 1.0625F);
                GL.Vertex3(origin_x + right[0] * scale, origin_y + right[1] * scale, origin_z + right[2] * scale);
            }

            GL.End();
            GL.Disable(EnableCap.Blend);
            GL.Color4(1, 1, 1, 1);
            GL.DepthMask(true);
            GL_TexEnv(( Int32 )All.Replace);
        }
Example #10
0
        public virtual void GL_LerpVerts(Int32 nverts, Int32[] ov, Int32[] v, Single[] move, Single[] frontv, Single[] backv)
        {
            SingleBuffer lerp = vertexArrayBuf;

            lerp.Limit = (nverts << 2) - nverts;
            Int32 ovv, vv;

            if ((currententity.flags & (Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0)
            {
                Single[] normal;
                var      j = 0;
                for (var i = 0; i < nverts; i++)
                {
                    vv     = v[i];
                    normal = r_avertexnormals[(vv >> 24) & 0xFF];
                    ovv    = ov[i];
                    lerp.Put(j, move[0] + (ovv & 0xFF) * backv[0] + (vv & 0xFF) * frontv[0] + normal[0] * Defines.POWERSUIT_SCALE);
                    lerp.Put(j + 1, move[1] + ((ovv >> 8) & 0xFF) * backv[1] + ((vv >> 8) & 0xFF) * frontv[1] + normal[1] * Defines.POWERSUIT_SCALE);
                    lerp.Put(j + 2, move[2] + ((ovv >> 16) & 0xFF) * backv[2] + ((vv >> 16) & 0xFF) * frontv[2] + normal[2] * Defines.POWERSUIT_SCALE);
                    j += 3;
                }
            }
            else
            {
                var j = 0;
                for (var i = 0; i < nverts; i++)
                {
                    ovv = ov[i];
                    vv  = v[i];
                    lerp.Put(j, move[0] + (ovv & 0xFF) * backv[0] + (vv & 0xFF) * frontv[0]);
                    lerp.Put(j + 1, move[1] + ((ovv >> 8) & 0xFF) * backv[1] + ((vv >> 8) & 0xFF) * frontv[1]);
                    lerp.Put(j + 2, move[2] + ((ovv >> 16) & 0xFF) * backv[2] + ((vv >> 16) & 0xFF) * frontv[2]);
                    j += 3;
                }
            }
        }
Example #11
0
 public virtual void GlTexCoordPointer(int size, int stride, SingleBuffer pointer)
 {
 }
Example #12
0
 public virtual void GlInterleavedArrays(int format, int stride, SingleBuffer pointer)
 {
 }
Example #13
0
 public virtual void GlLoadMatrix(SingleBuffer m)
 {
 }
Example #14
0
 static Surf( )
 {
     globalPolygonInterleavedBuf.Position = glpoly_t.STRIDE - 2;
     globalPolygonTexCoord1Buf            = globalPolygonInterleavedBuf.Slice();
     globalPolygonInterleavedBuf.Position = 0;
 }
Example #15
0
 public virtual void GlGetFloat(int pname, SingleBuffer params_renamed)
 {
 }
Example #16
0
 public virtual void GlColorPointer(int size, int stride, SingleBuffer pointer)
 {
 }
Example #17
0
        public virtual void GL_DrawAliasFrameLerp(qfiles.dmdl_t paliashdr, Single backlerp)
        {
            Single l;

            qfiles.daliasframe_t frame, oldframe;
            Int32[] v, ov;
            Int32[] order;
            var     orderIndex = 0;
            Int32   count;
            Single  frontlerp;
            Single  alpha;

            Single[]   move    = new Single[] { 0, 0, 0 };
            Single[][] vectors = new Single[][] { new Single[] { 0, 0, 0 }, new Single[] { 0, 0, 0 }, new Single[] { 0, 0, 0 } };
            Single[]   frontv  = new Single[] { 0, 0, 0 };
            Single[]   backv   = new Single[] { 0, 0, 0 };
            Int32      i;
            Int32      index_xyz;

            frame    = paliashdr.aliasFrames[currententity.frame];
            v        = frame.verts;
            oldframe = paliashdr.aliasFrames[currententity.oldframe];
            ov       = oldframe.verts;
            order    = paliashdr.glCmds;
            if ((currententity.flags & Defines.RF_TRANSLUCENT) != 0)
            {
                alpha = currententity.alpha;
            }
            else
            {
                alpha = 1F;
            }
            if ((currententity.flags & (Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0)
            {
                GL.Disable(EnableCap.Texture2D);
            }
            frontlerp = 1F - backlerp;
            Math3D.VectorSubtract(currententity.oldorigin, currententity.origin, frontv);
            Math3D.AngleVectors(currententity.angles, vectors[0], vectors[1], vectors[2]);
            move[0] = Math3D.DotProduct(frontv, vectors[0]);
            move[1] = -Math3D.DotProduct(frontv, vectors[1]);
            move[2] = Math3D.DotProduct(frontv, vectors[2]);
            Math3D.VectorAdd(move, oldframe.translate, move);
            for (i = 0; i < 3; i++)
            {
                move[i]   = backlerp * move[i] + frontlerp * frame.translate[i];
                frontv[i] = frontlerp * frame.scale[i];
                backv[i]  = backlerp * oldframe.scale[i];
            }

            if (gl_vertex_arrays.value != 0F)
            {
                GL_LerpVerts(paliashdr.num_xyz, ov, v, move, frontv, backv);
                GL.EnableClientState(ArrayCap.VertexArray);
                new Pinnable(vertexArrayBuf.Array, (ptr) =>
                {
                    GL.VertexPointer(3, VertexPointerType.Float, 0, ptr);
                });
                if ((currententity.flags & (Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0)
                {
                    GL.DisableClientState(ArrayCap.ColorArray);
                    GL.Color4(shadelight[0], shadelight[1], shadelight[2], alpha);
                }
                else
                {
                    GL.EnableClientState(ArrayCap.ColorArray);
                    new Pinnable(colorArrayBuf.Array, (ptr) =>
                    {
                        GL.ColorPointer(4, ColorPointerType.Float, 0, ptr);
                    });
                    SingleBuffer color = colorArrayBuf;
                    var          j     = 0;
                    for (i = 0; i < paliashdr.num_xyz; i++)
                    {
                        l = shadedots[(v[i] >> 24) & 0xFF];
                        color.Put(j++, l * shadelight[0]);
                        color.Put(j++, l * shadelight[1]);
                        color.Put(j++, l * shadelight[2]);
                        color.Put(j++, alpha);
                    }
                }

                //if (qglLockArraysEXT)
                //    gl.GlLockArraysEXT(0, paliashdr.num_xyz);
                while (true)
                {
                    count = order[orderIndex++];
                    if (count == 0)
                    {
                        break;
                    }
                    if (count < 0)
                    {
                        count = -count;
                        GL.Begin(PrimitiveType.TriangleFan);
                    }
                    else
                    {
                        GL.Begin(PrimitiveType.TriangleStrip);
                    }

                    if ((currententity.flags & (Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0)
                    {
                        do
                        {
                            index_xyz   = order[orderIndex + 2];
                            orderIndex += 3;
                            GL.ArrayElement(index_xyz);
                        }while (--count != 0);
                    }
                    else
                    {
                        do
                        {
                            GL.TexCoord2(BitConverter.ToSingle(BitConverter.GetBytes(order[orderIndex + 0])), BitConverter.ToSingle(BitConverter.GetBytes(order[orderIndex + 1])));
                            index_xyz   = order[orderIndex + 2];
                            orderIndex += 3;
                            GL.ArrayElement(index_xyz);
                        }while (--count != 0);
                    }

                    GL.End();
                }

                // if (qglLockArraysEXT)
                //     gl.GlUnlockArraysEXT();
            }
            else
            {
                GL_LerpVerts(paliashdr.num_xyz, ov, v, s_lerped, move, frontv, backv);
                Single[] tmp;
                while (true)
                {
                    count = order[orderIndex++];
                    if (count == 0)
                    {
                        break;
                    }
                    if (count < 0)
                    {
                        count = -count;
                        GL.Begin(PrimitiveType.TriangleFan);
                    }
                    else
                    {
                        GL.Begin(PrimitiveType.TriangleStrip);
                    }

                    if ((currententity.flags & (Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE)) != 0)
                    {
                        do
                        {
                            index_xyz   = order[orderIndex + 2];
                            orderIndex += 3;
                            GL.Color4(shadelight[0], shadelight[1], shadelight[2], alpha);
                            tmp = s_lerped[index_xyz];
                            GL.Vertex3(tmp[0], tmp[1], tmp[2]);
                        }while (--count != 0);
                    }
                    else
                    {
                        do
                        {
                            GL.TexCoord2(BitConverter.ToSingle(BitConverter.GetBytes(order[orderIndex + 0])), BitConverter.ToSingle(BitConverter.GetBytes(order[orderIndex + 1])));
                            index_xyz   = order[orderIndex + 2];
                            orderIndex += 3;
                            l           = shadedots[(v[index_xyz] >> 24) & 0xFF];
                            GL.Color4(l * shadelight[0], l * shadelight[1], l * shadelight[2], alpha);
                            tmp = s_lerped[index_xyz];
                            GL.Vertex3(tmp[0], tmp[1], tmp[2]);
                        }while (--count != 0);
                    }

                    GL.End();
                }
            }

            if ((currententity.flags & (Defines.RF_SHELL_RED | Defines.RF_SHELL_GREEN | Defines.RF_SHELL_BLUE | Defines.RF_SHELL_DOUBLE | Defines.RF_SHELL_HALF_DAM)) != 0)
            {
                GL.Enable(EnableCap.Texture2D);
            }
        }
Example #18
0
 public void GlLoadMatrix(SingleBuffer m)
 {
     GL11.GlLoadMatrix(m);
 }
Example #19
0
 public void GlTexCoordPointer(int size, int stride, SingleBuffer pointer)
 {
     GL11.GlTexCoordPointer(size, stride, pointer);
 }
Example #20
0
 public void GlGetFloat(int pname, SingleBuffer params_renamed)
 {
     GL11.GlGetFloat(pname, params_renamed);
 }
Example #21
0
 public virtual void GlTexCoordPointer(int size, int stride, SingleBuffer pointer)
 {
     gl.GlTexCoordPointer(size, GL_FLOAT, stride, pointer);
 }
Example #22
0
 public virtual void GlColorPointer(int size, int stride, SingleBuffer pointer)
 {
     GL.ColorPointer(size, GL_FLOAT, stride, pointer);
 }
Example #23
0
        public static void PlayAllSounds(SingleBuffer listenerOrigin)
        {
            SingleBuffer sourceOrigin = sourceOriginBuffer;
            Channel      ch;
            int          sourceId;
            int          state;

            for (int i = 0; i < numChannels; i++)
            {
                ch = channels[i];
                if (ch.active)
                {
                    sourceId = ch.sourceId;
                    switch (ch.type)
                    {
                    case Channel.LISTENER:
                        sourceOrigin.Put(0, listenerOrigin.Get(0));
                        sourceOrigin.Put(1, listenerOrigin.Get(1));
                        sourceOrigin.Put(2, listenerOrigin.Get(2));
                        break;

                    case Channel.DYNAMIC:
                        CL_ents.GetEntitySoundOrigin(ch.entnum, entityOrigin);
                        ConvertVector(entityOrigin, sourceOrigin);
                        break;

                    case Channel.FIXED:
                        ConvertVector(ch.origin, sourceOrigin);
                        break;
                    }

                    if (ch.modified)
                    {
                        if (ch.bufferChanged)
                        {
                            try
                            {
                                AL10.AlSourcei(sourceId, AL10.AL_BUFFER, ch.bufferId);
                            }
                            catch (OpenALException e)
                            {
                                AL10.AlSourceStop(sourceId);
                                AL10.AlSourcei(sourceId, AL10.AL_BUFFER, ch.bufferId);
                            }
                        }

                        if (ch.volumeChanged)
                        {
                            AL10.AlSourcef(sourceId, AL10.AL_GAIN, ch.volume);
                        }

                        AL10.AlSourcef(sourceId, AL10.AL_ROLLOFF_FACTOR, ch.rolloff);
                        AL10.AlSource(sourceId, AL10.AL_POSITION, sourceOrigin);
                        AL10.AlSourcePlay(sourceId);
                        ch.modified = false;
                    }
                    else
                    {
                        state = AL10.AlGetSourcei(sourceId, AL10.AL_SOURCE_STATE);
                        if (state == AL10.AL_PLAYING)
                        {
                            AL10.AlSource(sourceId, AL10.AL_POSITION, sourceOrigin);
                        }
                        else
                        {
                            ch.Clear();
                        }
                    }

                    ch.autosound = false;
                }
            }
        }
Example #24
0
 public static void ConvertVector(float[] from, SingleBuffer to)
 {
     to.Put(0, from[0]);
     to.Put(1, from[2]);
     to.Put(2, -from[1]);
 }
Example #25
0
 public virtual void GlVertexPointer(int size, int stride, SingleBuffer pointer)
 {
 }
Example #26
0
 public void GlPointParameterEXT(int pname, SingleBuffer pfParams)
 {
     EXTPointParameters.GlPointParameterEXT(pname, pfParams);
 }
Example #27
0
 public virtual void GlPointParameterEXT(int pname, SingleBuffer pfParams)
 {
 }
Example #28
0
 public void GlColorPointer(int size, int stride, SingleBuffer pointer)
 {
     GL11.GlColorPointer(size, stride, pointer);
 }
Example #29
0
 public virtual void GlVertexPointer(int size, int stride, SingleBuffer pointer)
 {
     GL.VertexPointer(size, GL_FLOAT, stride, pointer);
 }
Example #30
0
 public virtual void GlPointParameterEXT(int pname, SingleBuffer pfParams)
 {
     gl.GlPointParameterfvEXT(pname, pfParams);
 }
Example #31
0
 public void GlInterleavedArrays(int format, int stride, SingleBuffer pointer)
 {
     GL11.GlInterleavedArrays(format, stride, pointer);
 }
Example #32
0
 public override SingleBuffer Put(SingleBuffer buffer)
 {
     throw new ReadOnlyBufferException();
 }