bool WriteFrame(Frame a_frame) { if (!m_internalClient.IsConnected) { InternalConsole.AddMessage("Failed to write to disconnected stream"); } try { m_internalClient.WriteToStream(a_frame.ToBytes()); return(true); } catch (IOException e) { InternalConsole.Error(string.Format("Discord Client: Failed to write frame: IOException: {0}", e.Message)); } catch (ObjectDisposedException) { InternalConsole.Error("Discord Client: Failed to write frame: Disposed"); } catch (InvalidOperationException) { InternalConsole.Error("Discord Client: Invalid Operaion when writing frame"); } return(false); }
public void ModifyObject() { m_handle = GL.CreateProgram(); PixelShader pixelShader = m_program.PixelShader; GeometryShader geometryShader = m_program.GeometryShader; VertexShader vertexShader = m_program.VertexShader; if (pixelShader != null) { GL.AttachShader(m_handle, ((OpenTKPixelShader)pixelShader.InternalObject).Handle); } if (geometryShader != null) { GL.AttachShader(m_handle, ((OpenTKGeometryShader)geometryShader.InternalObject).Handle); } if (vertexShader != null) { GL.AttachShader(m_handle, ((OpenTKVertexShader)vertexShader.InternalObject).Handle); } GL.LinkProgram(m_handle); #if DEBUG_INFO string info; GL.GetProgramInfoLog(m_handle, out info); if (!string.IsNullOrEmpty(info)) { InternalConsole.AddMessage(info, InternalConsole.e_Alert.Warning); } #endif }
public static void GLError(string a_error) { ErrorCode error = GL.GetError(); if (error != ErrorCode.NoError) { InternalConsole.AddMessage(a_error + error.ToString(), InternalConsole.e_Alert.Error); } }
public Device() { if (m_activeDevice == null) { m_activeDevice = this; } InitContext(); InternalConsole.AddMessage(string.Format("Init OpenAL: Version: {0}, Vendor {1}, Renderer {2}", AL.Get(ALGetString.Version), AL.Get(ALGetString.Vendor), AL.Get(ALGetString.Renderer))); }
public void ModifyObject() { int shader = GL.CreateShader(ShaderType.VertexShader); GL.ShaderSource(shader, m_source); GL.CompileShader(shader); m_shader.Handle = shader; #if DEBUG_INFO string info = GL.GetShaderInfoLog(shader); if (info != string.Empty) { InternalConsole.AddMessage(info, InternalConsole.e_Alert.Warning); } #endif }
void Handshake() { InternalConsole.AddMessage("Attempting Discord Handshake"); if (m_state != e_RPCState.Disconnected) { InternalConsole.Warning("Discord Client: State must be disconnected to handshake"); return; } if (WriteFrame(new Frame(Frame.e_OpCode.Handshake, new Handshake() { Version = m_version, ClientID = m_clientID }))) { m_state = e_RPCState.Connecting; } }
void Input() { while (!m_inputQueue.IsEmpty) { IGraphicsObject obj; if (!m_inputQueue.TryDequeue(out obj)) { InternalConsole.AddMessage("Pipeline: Input Dequeue Failed", InternalConsole.e_Alert.Warning); return; } obj.ModifyObject(); #if DEBUG_INFO Pipeline.GLError("Pipeline: Input: "); #endif } }
void Disposal() { while (!m_disposalQueue.IsEmpty) { IGraphicsObject obj; if (!m_disposalQueue.TryDequeue(out obj)) { InternalConsole.AddMessage("Pipeline: Disposal Dequeue Failed", InternalConsole.e_Alert.Warning); return; } obj.DisposeObject(); #if DEBUG_INFO Pipeline.GLError("Pipeline: Disposal: "); #endif } }
void Disposal() { while (!m_disposalQueue.IsEmpty) { IRenderObject obj; if (!m_disposalQueue.TryDequeue(out obj)) { InternalConsole.AddMessage("Graphics: Diposal Dequeue Failed", InternalConsole.e_Alert.Error); return; } obj.RemoveObject(m_drawingObjects, m_updateRenderers); #if DEBUG_INFO Pipeline.GLError("Graphics: Disposal: "); #endif } }
void Input() { while (!m_inputQueue.IsEmpty) { IRenderObject obj; if (!m_inputQueue.TryDequeue(out obj)) { InternalConsole.AddMessage("Graphics: Input Dequeue Failed", InternalConsole.e_Alert.Error); return; } obj.AddObject(m_drawingObjects, m_updateRenderers); #if DEBUG_INFO Pipeline.GLError("Graphics: Input: "); #endif } }
public override bool AttemptConnection(string a_pipe) { try { m_stream = new NamedPipeClientStream(".", a_pipe, PipeDirection.InOut, PipeOptions.Asynchronous); m_stream.Connect(1000); do { Thread.Sleep(10); }while (!m_stream.IsConnected); InternalConsole.AddMessage(string.Format("Connected: {0}", a_pipe)); return(true); } catch (Exception e) { InternalConsole.Error(string.Format("Failed to connect to {0}: {1}", a_pipe, e.Message)); } return(false); }
void DiscordLoop() { bool connected = false; m_join = false; for (int i = 0; i < 10; ++i) { if (AttemptConnection(i)) { connected = true; break; } if (m_shutdown) { break; } } if (!connected) { InternalConsole.Error("Failed to connect to Discord"); m_shutdown = true; } else { m_internalClient.BeginRead(); EnqueueMessage(new ConnectionEstablishedMessage(m_connectedPipe)); Handshake(); while (!m_shutdown) { Frame frame; if (ReadFrame(out frame)) { switch (frame.OpCode) { case Frame.e_OpCode.Close: { ClosePayload close = frame.GetObject <ClosePayload>(); InternalConsole.AddMessage("Discord Client Remotely Terminated"); EnqueueMessage(new CloseMessage(close.Code, close.Reason)); m_shutdown = true; break; } case Frame.e_OpCode.Ping: { WriteFrame(new Frame(Frame.e_OpCode.Pong, frame.Data)); break; } case Frame.e_OpCode.Pong: { InternalConsole.Warning("Got a pong from Discord?"); break; } case Frame.e_OpCode.Frame: { if (m_shutdown) { break; } if (frame.Data == null) { InternalConsole.Error("Discord Client: No data in frame"); } EventPayload response = frame.GetObject <EventPayload>(); ProcessEvent(response); break; } default: { InternalConsole.Error("Discord Client: Invalid Operation"); m_shutdown = true; break; } } } ProcessCommandQueue(); } ProcessCommandQueue(); } m_join = true; }