private StepMode Interpreter_Step(object sender, DebugInformation e) { // Check if on GL Thread - we don't want to block it. if (GLThread.IsGLThread()) { _currentScriptExec = "Found script, but it was on the GL Thread where it can't be debugged."; return(StepMode.None); } // If this errors it will break the script, that's why it should be in a try-catch. try { // Get the source and write it down. string sourceFull = e.CurrentStatement.Location.Source; if (string.IsNullOrEmpty(sourceFull)) { _currentScriptExec = "Unknown Script Source"; } else { _currentScriptExec = sourceFull; _currentStatement = sourceFull.Substring(e.CurrentStatement.Range[0], e.CurrentStatement.Range[1] - e.CurrentStatement.Range[0]); } _canStepInto = true; if (e.CallStack.Count > 0) { _canStepOut = true; } bool wait = true; StepMode exit = StepMode.None; _stepFunction = mode => { exit = mode; wait = false; }; while (wait) { if (!Open) { return(StepMode.Into); } Engine.ScriptingEngine.Interpreter.ResetTimeoutTicks(); } _canStepInto = false; _canStepOut = false; return(exit); } catch (Exception ex) { Engine.Log.Warning($"Rationale script debugger encountered an error: {ex}", MessageSource.Other); return(StepMode.Into); } }
/// <summary> /// Bind the textures in use. /// </summary> public virtual void BindTextures() { Debug.Assert(GLThread.IsGLThread()); for (uint i = 0; i < TextureSlotUtilization; i++) { Texture.EnsureBound(_textureBinding[i], i); } }
/// <summary> /// Create a shader program by linking compiled shaders. /// </summary> /// <param name="vertShader">The vert shader to attach.</param> /// <param name="fragShader">The frag shader to attach.</param> /// <returns></returns> public static ShaderProgram CreateFromShaders(uint vertShader, uint fragShader) { Debug.Assert(GLThread.IsGLThread()); uint pointer = Gl.CreateProgram(); Gl.AttachShader(pointer, vertShader); Gl.AttachShader(pointer, fragShader); // Set default parameter locations. Gl.BindAttribLocation(pointer, VertexLocation, "vertPos"); Gl.BindAttribLocation(pointer, UvLocation, "uv"); Gl.BindAttribLocation(pointer, ColorLocation, "color"); Gl.LinkProgram(pointer); if (Engine.Configuration.GlDebugMode) { Gl.ValidateProgram(pointer); } // Check linking status. var programCompileStatusReader = new StringBuilder(1024); Gl.GetProgramInfoLog(pointer, 1024, out int length, programCompileStatusReader); if (length > 0) { var programStatus = programCompileStatusReader.ToString(0, length); if (programStatus != "") { Engine.Log.Warning($"Log for linking shaders (v:{vertShader} f:{fragShader}) is {programStatus}", MessageSource.GL); } } var valid = false; Gl.GetProgram(pointer, ProgramProperty.LinkStatus, out int state); if (state == 0) { Engine.Log.Warning($"Couldn't link shader program {pointer}.", MessageSource.GL); } else { valid = true; } var newProgram = new ShaderProgram { Pointer = pointer, Valid = valid }; return(newProgram); }
/// <summary> /// Create a new data buffer. /// </summary> /// <param name="type">The type of buffer to create.</param> /// <param name="byteSize">The size of the buffer in bytes. This is optional and can be set later with an upload.</param> /// <param name="dataUsage">The usage for the data. Only matters if a size is specified.</param> public DataBuffer(BufferTarget type, uint byteSize = 0, BufferUsage dataUsage = BufferUsage.StreamDraw) { Debug.Assert(GLThread.IsGLThread()); Type = type; Pointer = Gl.GenBuffer(); EnsureBound(Pointer, Type); if (byteSize != 0) { Upload(IntPtr.Zero, byteSize, dataUsage); } }