Ejemplo n.º 1
0
 static SSLight()
 {
     for (LightName l = c_firstNameIdx; l <= c_lastNameIdx; ++l)
     {
         s_avaiableLightNames.Enqueue(l);
     }
 }
Ejemplo n.º 2
0
 public static void Light(LightName name, LightParameter pname, Color4 @params)
 {
     unsafe
     {
         GL.Light(name, pname, (float *)&@params);
     }
 }
Ejemplo n.º 3
0
        public Light(LightName id)
        {
            _id = id;

            GL.Enable(EnableCap.Lighting);
            GL.Enable((EnableCap)_id);
        }
Ejemplo n.º 4
0
        public static EnableCap lightNameCapLookUp(LightName name)
        {
            switch (name)
            {
            case LightName.Light0:
                return(EnableCap.Light0);

            case LightName.Light1:
                return(EnableCap.Light1);

            case LightName.Light2:
                return(EnableCap.Light2);

            case LightName.Light3:
                return(EnableCap.Light3);

            case LightName.Light4:
                return(EnableCap.Light4);

            case LightName.Light5:
                return(EnableCap.Light5);

            case LightName.Light6:
                return(EnableCap.Light6);

            case LightName.Light7:
                return(EnableCap.Light7);
            }

            return(EnableCap.Light0);
        }
Ejemplo n.º 5
0
 public Light(Vector3 lightPosition, Color4 ambientlightColor, Color4 diffuseLightColor, Color4 specularLightColor, LightName name)
 {
     LightPosition = lightPosition;
     AmbientColor  = ambientlightColor;
     DiffuseColor  = diffuseLightColor;
     SpecularColor = specularLightColor;
     Name          = name;
 }
Ejemplo n.º 6
0
        public static void Light(LightName light, LightParameter pname, float[] param)
        {
#if USE_OPENGL
            OpenTK.Graphics.OpenGL.GL.Light((OpenTK.Graphics.OpenGL.LightName)light, (OpenTK.Graphics.OpenGL.LightParameter)pname, param);
#else
            //throw new NotImplementedException();
#endif
        }
Ejemplo n.º 7
0
 public SourceLight(OpenGL gl, LightName lightNum, HomogeneousCoordinates position, ColorSettingLight colorSet)
 {
     this.position = position;
     this.colorSet = colorSet;
     this.gl       = gl;
     this.lightNum = lightNum;
     SetColorSet(colorSet);
 }
Ejemplo n.º 8
0
        public void Set()
        {
            const LightName id = LightName.Light0;

            GL.Light(id, LightParameter.Ambient, Ambient);
            GL.Light(id, LightParameter.Diffuse, Diffuse);
            GL.Light(id, LightParameter.Specular, Specular);
            GL.Light(id, LightParameter.Position, Position);
        }
Ejemplo n.º 9
0
        public override void DoLighting(LightManager lights)
        {
            FlushDrawBuffer();

            if (lights.Enabled == false)
            {
                GL.Disable(EnableCap.Lighting);
                return;
            }

            float[] array = new float[4];

            GL.Enable(EnableCap.Lighting);

            SetArray(array, lights.Ambient);
            GL.LightModelv(LightModelParameter.LightModelAmbient, array);

            GL.Enable(EnableCap.ColorMaterial);
            GL.ColorMaterial(MaterialFace.FrontAndBack,
                             ColorMaterialParameter.AmbientAndDiffuse);

            for (int i = 0; i < lights.Count || i < mMaxLightsUsed; i++)
            {
                EnableCap lightID   = (EnableCap)((int)EnableCap.Light0 + i);
                LightName lightName = (LightName)((int)LightName.Light0 + i);

                if (i >= lights.Count)
                {
                    GL.Disable(lightID);
                    continue;
                }

                if (lights[i].Enabled == false)
                {
                    GL.Disable(lightID);
                    continue;
                }

                GL.Enable(lightID);

                SetArray(array, lights[i].Diffuse);
                GL.Lightv(lightName, LightParameter.Diffuse, array);

                SetArray(array, lights[i].Ambient);
                GL.Lightv(lightName, LightParameter.Ambient, array);

                SetArray(array, lights[i].Position);
                GL.Lightv(lightName, LightParameter.Position, array);

                GL.Light(lightName, LightParameter.ConstantAttenuation, lights[i].AttenuationConstant);
                GL.Light(lightName, LightParameter.LinearAttenuation, lights[i].AttenuationLinear);
                GL.Light(lightName, LightParameter.QuadraticAttenuation, lights[i].AttenuationQuadratic);
            }

            mMaxLightsUsed = lights.Count;
        }
Ejemplo n.º 10
0
 public static void Lightiv(LightName light, LightParameter pname, int[] @params)
 {
     unsafe
     {
         fixed(int * @params_ptr = @params)
         {
             Interop.Calli((int)light, (int)pname, @params_ptr, LightivAddress);
         }
     }
 }
Ejemplo n.º 11
0
 public MovingLight(OpenGL gl, LightName lightNum, HomogeneousCoordinates position, ColorSettingLight colorSet)
     : base(gl, lightNum, position, colorSet)
 {
     this.position = position;
     this.colorSet = colorSet;
     this.gl       = gl;
     this.lightNum = lightNum;
     SetColorSet(colorSet);
     angleRot = 0;
 }
Ejemplo n.º 12
0
        public void Lightfv(LightName light, LightParameter pname, float[] param)
        {
            if (param == null || param.Length > HeapData.LightfvMaxSize)
            {
                throw new ArgumentException("Array has to many elements.");
            }

            Marshal.Copy(param, 0, HeapData.ptrLightfv, param.Length);
            lightfv(light, pname, HeapData.ptrLightfv);
        }
Ejemplo n.º 13
0
        public void setLight()
        {
            LightName lightname  = LightName.Light0;
            EnableCap enablename = EnableCap.Light0;


            if (playn == 1)
            {
                lightname  = LightName.Light1;
                enablename = EnableCap.Light1;
            }
            else if (playn == 2)
            {
                lightname  = LightName.Light2;
                enablename = EnableCap.Light2;
            }
            else if (playn == 3)
            {
                lightname  = LightName.Light3;
                enablename = EnableCap.Light3;
            }
            else if (playn == 4)
            {
                lightname  = LightName.Light4;
                enablename = EnableCap.Light4;
            }

            if (!Visible)
            {
                GL.Disable(enablename);
                return;
            }


            const float k_amb  = 0.6f;
            const float k_diff = 0.3f;
            const float k_spec = 1.0f;

            Color4 Color = theAppearance.Color;

            Color4  light_ambient  = new Color4(Color.R * k_amb, Color.G * k_amb, Color.B * k_amb, 1);
            Color4  light_diffuse  = new Color4(Color.R * k_diff, Color.G * k_diff, Color.B * k_diff, 1);
            Color4  light_specular = new Color4(k_spec, k_spec, k_spec, 1.0f);
            Vector4 light_pos      = new Vector4(Center.X, Center.Y, Center.Z - 4, 1);
            Vector4 light_dir      = new Vector4(0, 0, 1, 1);

            GL.Light(lightname, LightParameter.Ambient, light_ambient);
            GL.Light(lightname, LightParameter.Diffuse, light_diffuse);
            GL.Light(lightname, LightParameter.Specular, light_specular);
            GL.Light(lightname, LightParameter.Position, light_pos);
            GL.Light(lightname, LightParameter.SpotDirection, light_dir);
            GL.Light(lightname, LightParameter.SpotCutoff, 30.0f);
            GL.Enable(enablename);
        }
Ejemplo n.º 14
0
        public Light(LightName name)
        {
            sphereSource.LatitudinalSlices  = 8;
            sphereSource.LongitudinalSlices = 8;
            sphereSource.SetColor(1.0f, 1.0f, 1.0f);
            sphereSource.SetRenderMode(RenderMode.WIRE);
            coneSource.SetColor(1.0f, 1.0f, 1.0f);
            coneSource.SetRenderMode(RenderMode.WIRE);

            lightName = name;
            GL.Enable(lightNameCapLookUp(name));
        }
Ejemplo n.º 15
0
        public SSLight() : base()
        {
            if (s_avaiableLightNames.Count == 0)
            {
                string msg = "Cannot support this many lights.";
                throw new Exception(msg);
            }

            this.m_lightName = s_avaiableLightNames.Dequeue();
            this._pos        = new Vector3(0, 0, 1);
            this.calcMatFromState();
        }
Ejemplo n.º 16
0
        public Light(LightName name)
        {
            sphereSource.LatitudinalSlices = 8;
            sphereSource.LongitudinalSlices = 8;
            sphereSource.SetColor(1.0f, 1.0f, 1.0f);
            sphereSource.SetRenderMode(RenderMode.WIRE);
            coneSource.SetColor(1.0f, 1.0f, 1.0f);
            coneSource.SetRenderMode(RenderMode.WIRE);

            lightName = name;
            GL.Enable(lightNameCapLookUp(name));
        }
Ejemplo n.º 17
0
        private void PrepareState_Lighting(GpuStateStruct *GpuState)
        {
            //Console.WriteLine(GpuState->LightingState.AmbientModelColor);
            var LightingState = &GpuState->LightingState;

            // if (!glEnableDisable(GL_LIGHTING, state.lighting.enabled) && (state.texture.mapMode != TextureMapMode.GU_ENVIRONMENT_MAP)) {
            if (!GlEnableDisable(EnableCap.Lighting, LightingState->Enabled))
            {
                return;
            }

            GL.LightModel(
                LightModelParameter.LightModelColorControl,
                (int)((LightingState->LightModel == LightModelEnum.SeparateSpecularColor) ? LightModelColorControl.SeparateSpecularColor : LightModelColorControl.SingleColor)
                );
            GL.LightModel(LightModelParameter.LightModelAmbient, &LightingState->AmbientLightColor.Red);

            for (int n = 0; n < 4; n++)
            {
                var       LightState = &(&LightingState->Light0)[n];
                LightName LightName  = (LightName)(LightName.Light0 + n);

                if (!GlEnableDisable((EnableCap)(EnableCap.Light0 + n), LightState->Enabled))
                {
                    continue;
                }

                GL.Light(LightName, LightParameter.Specular, &LightState->SpecularColor.Red);
                GL.Light(LightName, LightParameter.Ambient, &LightState->AmbientColor.Red);
                GL.Light(LightName, LightParameter.Diffuse, &LightState->DiffuseColor.Red);

                LightState->Position.W = 1.0f;
                GL.Light(LightName, LightParameter.Position, &LightState->Position.X);

                GL.Light(LightName, LightParameter.ConstantAttenuation, &LightState->Attenuation.Constant);
                GL.Light(LightName, LightParameter.LinearAttenuation, &LightState->Attenuation.Linear);
                GL.Light(LightName, LightParameter.QuadraticAttenuation, &LightState->Attenuation.Quadratic);

                if (LightState->Type == LightTypeEnum.SpotLight)
                {
                    GL.Light(LightName, LightParameter.SpotDirection, &LightState->SpotDirection.X);
                    GL.Light(LightName, LightParameter.SpotExponent, &LightState->SpotExponent);
                    GL.Light(LightName, LightParameter.SpotCutoff, &LightState->SpotCutoff);
                }
                else
                {
                    GL.Light(LightName, LightParameter.SpotExponent, 0);
                    GL.Light(LightName, LightParameter.SpotCutoff, 180);
                }
            }
        }
Ejemplo n.º 18
0
        public static EnableCap lightNameCapLookUp(LightName name)
        {
            switch (name)
            {
                case LightName.Light0:
                    return EnableCap.Light0;
                case LightName.Light1:
                    return EnableCap.Light1;
                case LightName.Light2:
                    return EnableCap.Light2;
                case LightName.Light3:
                    return EnableCap.Light3;
                case LightName.Light4:
                    return EnableCap.Light4;
                case LightName.Light5:
                    return EnableCap.Light5;
                case LightName.Light6:
                    return EnableCap.Light6;
                case LightName.Light7:
                    return EnableCap.Light7;
            }

            return EnableCap.Light0;
        }
Ejemplo n.º 19
0
		public static void Light(LightName light, LightParameter pname, Int32[] @params)
		{
			unsafe {
				fixed (Int32* p_params = @params)
				{
					Debug.Assert(Delegates.pglLightiv != null, "pglLightiv not implemented");
					Delegates.pglLightiv((Int32)light, (Int32)pname, p_params);
					CallLog("glLightiv({0}, {1}, {2})", light, pname, @params);
				}
			}
			DebugCheckErrors();
		}
 public static extern void Lightf( LightName light, LightParameter pname, float param );
Ejemplo n.º 21
0
 public SSDirectionalLight(LightName lightName)
     : base(lightName)
 {
     this.Direction = new Vector3 (0f, 0f, 1f);
 }
Ejemplo n.º 22
0
		public static void Light(LightName light, LightParameter pname, float[] param)
		{
#if USE_OPENGL
			if (openGlHardwareAvailable)
			{
				OpenTK.Graphics.OpenGL.GL.Light((OpenTK.Graphics.OpenGL.LightName)light, (OpenTK.Graphics.OpenGL.LightParameter)pname, param);
			}
#else
			//throw new NotImplementedException();
#endif
		}
Ejemplo n.º 23
0
 internal static extern void glLighti(LightName light, LightParameter pname, Int32 param);
Ejemplo n.º 24
0
 public SSLightBase(LightName lightName)
 {
     this.m_lightName = lightName;
 }
Ejemplo n.º 25
0
		public static UInt32 BindLightParameterEXT(LightName light, LightParameter value)
		{
			UInt32 retValue;

			Debug.Assert(Delegates.pglBindLightParameterEXT != null, "pglBindLightParameterEXT not implemented");
			retValue = Delegates.pglBindLightParameterEXT((Int32)light, (Int32)value);
			CallLog("glBindLightParameterEXT({0}, {1}) = {2}", light, value, retValue);
			DebugCheckErrors();

			return (retValue);
		}
Ejemplo n.º 26
0
 internal static extern void glLightf(LightName light, LightParameter pname, Single param);
 public static extern void GetLightiv( LightName light, LightParameter pname, [Out]int[] @params );
Ejemplo n.º 28
0
 public partial uint BindLightParameter([Flow(FlowDirection.In)] LightName light, [Flow(FlowDirection.In)] LightParameter value);
Ejemplo n.º 29
0
 public SSLightBase(LightName lightName)
 {
     this.m_lightName = lightName;
 }
Ejemplo n.º 30
0
		public static void Light(LightName light, LightParameter pname, float[] @params)
		{
			unsafe {
				fixed (float* p_params = @params)
				{
					Debug.Assert(Delegates.pglLightfv != null, "pglLightfv not implemented");
					Delegates.pglLightfv((Int32)light, (Int32)pname, p_params);
					LogFunction("glLightfv({0}, {1}, {2})", light, pname, LogValue(@params));
				}
			}
			DebugCheckErrors(null);
		}
 public static extern void Lightiv( LightName light, LightParameter pname, int[] @params );
Ejemplo n.º 32
0
        public void AddLight(LightSource light)
        {
            if (enabledLights == 0)
            {
                GL.Enable(EnableCap.Lighting);

                float[] global_ambient = new float[] { 0.0f, 0.0f, 0.0f, 1.0f };
                GL.LightModelv(LightModelParameter.LightModelAmbient, global_ambient);
            }

            if (enabledLights < 8)
            {
                LoadTransformation(light.Entity.Transformation.GlobalMatrix);

                GL.Enable((EnableCap)(EnableCap.Light0 + enabledLights));

                LightName lightName = (LightName)(LightName.Light0 + enabledLights);

                GL.Lightv(lightName, LightParameter.Ambient, light.AmbientColor);
                GL.Lightv(lightName, LightParameter.Diffuse, light.DiffuseColor);

                if (light.LightType == LightType.SPOT)
                {
                    GL.Lightv(lightName, LightParameter.Position, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
                    GL.Lightv(lightName, LightParameter.SpotDirection, new Vector4(0.0f, 0.0f, -1.0f, 0.0f));
                    GL.Light(lightName, LightParameter.SpotCutoff, light.SpotCutoff);
                    GL.Light(lightName, LightParameter.SpotExponent, light.SpotExponent);
                }
                else
                {
                    GL.Lightv(lightName, LightParameter.Position, new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
                    GL.Lightv(lightName, LightParameter.SpotDirection, new Vector4(0.0f, 0.0f, 0.0f, 0.0f));
                    GL.Light(lightName, LightParameter.SpotCutoff, 180.0f);
                    GL.Light(lightName, LightParameter.SpotExponent, 0);
                }

                if (light.Distance > 0.0f)
                {
                    float dist = 1.0f / light.Distance;

                    if (light.Quadratic)
                    {
                        GL.Light(lightName, LightParameter.ConstantAttenuation, 1.0f);
                        GL.Light(lightName, LightParameter.LinearAttenuation, 0.0f);
                        GL.Light(lightName, LightParameter.QuadraticAttenuation, dist);
                    }
                    else
                    {
                        GL.Light(lightName, LightParameter.ConstantAttenuation, 1.0f);
                        GL.Light(lightName, LightParameter.LinearAttenuation, dist);
                        GL.Light(lightName, LightParameter.QuadraticAttenuation, 0.0f);
                    }
                }
                else
                {
                    GL.Light(lightName, LightParameter.ConstantAttenuation, 1.0f);
                    GL.Light(lightName, LightParameter.LinearAttenuation, 0.0f);
                    GL.Light(lightName, LightParameter.QuadraticAttenuation, 0.0f);
                }

                enabledLights++;
            }
        }
Ejemplo n.º 33
0
 public static void glLighti(LightName light, LightParameter pname, Int32 param)
 {
     i_OpenGL1_0.glLighti(light, pname, param);
 }
Ejemplo n.º 34
0
		public static void Light(LightName light, LightParameter pname, float param)
		{
			Debug.Assert(Delegates.pglLightf != null, "pglLightf not implemented");
			Delegates.pglLightf((Int32)light, (Int32)pname, param);
			LogFunction("glLightf({0}, {1}, {2})", light, pname, param);
			DebugCheckErrors(null);
		}
Ejemplo n.º 35
0
 public static void glGetLightiv(LightName light, LightParameter pname, ref Int32[] @params)
 {
     i_OpenGL1_0.glGetLightiv(light, pname, ref @params);
 }
Ejemplo n.º 36
0
 internal static extern void glLightfv(LightName light, LightParameter pname, [OutAttribute] Single * @params);
 public static extern void Lighti( LightName light, LightParameter pname, int param );
Ejemplo n.º 38
0
 internal static extern void glLightiv(LightName light, LightParameter pname, [OutAttribute] Int32 * @params);
 public static extern void Lightfv( LightName light, LightParameter pname, float[] @params );
Ejemplo n.º 40
0
 public static void glLightf(LightName light, LightParameter pname, Single param)
 {
     i_OpenGL1_0.glLightf(light, pname, param);
 }
Ejemplo n.º 41
0
		public static void Light(LightName name, LightParameter pname, Vector4 @params) {
			unsafe {
				Gl.Light(name, pname, (float*)&@params.X);
			}
		}
Ejemplo n.º 42
0
 public static void glGetLightfv(LightName light, LightParameter pname, ref Single[] @params)
 {
     i_OpenGL1_0.glGetLightfv(light, pname, ref @params);
 }
 public static unsafe void GetLightx(this OesFixedPoint thisApi, [Flow(FlowDirection.In)] LightName light, [Flow(FlowDirection.In)] OES pname, [Count(Computed = "pname"), Flow(FlowDirection.Out)] Span <int> @params)
 {
     // SpanOverloader
     thisApi.GetLightx(light, pname, out @params.GetPinnableReference());
 }
 public static unsafe void Lightx(this OesFixedPoint thisApi, [Flow(FlowDirection.In)] LightName light, [Flow(FlowDirection.In)] LightParameter pname, [Count(Computed = "pname"), Flow(FlowDirection.In)] ReadOnlySpan <int> @params)
 {
     // SpanOverloader
     thisApi.Lightx(light, pname, in @params.GetPinnableReference());
 }
Ejemplo n.º 45
0
		internal static extern void glLightf(LightName light, LightParameter pname, Single param);
Ejemplo n.º 46
0
 public static void Light(LightName name, LightParameter pname, Color4 @params)
 {
     unsafe { GL.Light(name, pname, (float*)&@params); }
 }
Ejemplo n.º 47
0
		internal static extern void glLightfv(LightName light, LightParameter pname, [OutAttribute] Single* @params);
 public static uint BindLightParameterEXT( LightName light, LightParameter value )
 {
     if (_BindLightParameterEXT == null) throw new Exception( "Extension method BindLightParameterEXT not found" );
     return  _BindLightParameterEXT( light, value );
 }
Ejemplo n.º 49
0
		internal static extern void glLighti(LightName light, LightParameter pname, Int32 param);
Ejemplo n.º 50
0
		public static void Light(LightName light, LightParameter pname, Int32 param)
		{
			Debug.Assert(Delegates.pglLighti != null, "pglLighti not implemented");
			Delegates.pglLighti((Int32)light, (Int32)pname, param);
			CallLog("glLighti({0}, {1}, {2})", light, pname, param);
			DebugCheckErrors();
		}
Ejemplo n.º 51
0
		internal static extern void glLightiv(LightName light, LightParameter pname, [OutAttribute] Int32* @params);
Ejemplo n.º 52
0
 public static void Light(LightName light, LightParameter pname, float[] param)
 {
     Instance?.Light(light, pname, param);
 }
 private void setLightColor(LightName lightName, float[] whiteSpecularLight, float[] blackAmbientLight, float[] whiteDiffuseLight)
 {
     GL.Light(lightName, LightParameter.Specular, whiteSpecularLight);
     GL.Light(lightName, LightParameter.Ambient, blackAmbientLight);
     GL.Light(lightName, LightParameter.Diffuse, whiteDiffuseLight);
 }