public void Dispose() { if (buffer != null) { buffer.Dispose(); buffer = null; } }
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()); }
public void Dispose() { if (voiceprintBuffer != null) { voiceprintBuffer.Dispose(); voiceprintBuffer = null; } }
private void ResizeTexture(int w, int h) { if (this.buffer == null) { this.buffer = new TextureHandle(w, h); } else { this.buffer.SetTextureSize(w, h); } }
private void InitTextures(IController controller) { if (mTextures == null) { mTextures = new TextureHandle[BufferCount]; for (int i = 0; i < mTextures.Length; i++) mTextures[i] = new TextureHandle(controller.Width, controller.Height); return; } foreach (TextureHandle i in mTextures) i.SetTextureSize(controller.Width, controller.Height); }
public void Dispose () { if (this.buffer != null) { this.buffer.Dispose(); this.buffer = null; } }
public override void Dispose() { if (Texture != null) { Texture.Dispose(); Texture = null; } base.Dispose(); }
private void ResizeToWidgetSize() { if (renderWidth == widgetWidth && renderHeight == widgetHeight) { if (resizeTexture != null) { resizeTexture.Dispose(); resizeTexture = null; } return; } if (resizeTexture == null) resizeTexture = new TextureHandle(); resizeTexture.SetTextureSize(renderWidth, renderHeight); Gl.glPushAttrib(Gl.GL_ENABLE_BIT); Gl.glDisable(Gl.GL_DEPTH_TEST); Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_DECAL); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_S, Gl.GL_CLAMP); Gl.glTexParameteri(Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_WRAP_T, Gl.GL_CLAMP); Gl.glBindTexture(Gl.GL_TEXTURE_2D, resizeTexture.TextureId); Gl.glCopyTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, 0, 0, renderWidth, renderHeight, 0); Gl.glViewport(0, 0, widgetWidth, widgetHeight); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glLoadIdentity(); Gl.glMatrixMode(Gl.GL_MODELVIEW); Gl.glLoadIdentity(); Gl.glColor4f(1, 1, 1, 1); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2f( 0, 0); Gl.glVertex2f( -1, -1); Gl.glTexCoord2f( 0, 1); Gl.glVertex2f( -1, 1); Gl.glTexCoord2f( 1, 1); Gl.glVertex2f( 1, 1); Gl.glTexCoord2f( 1, 0); Gl.glVertex2f( 1, -1); Gl.glEnd(); Gl.glPopAttrib(); }
public override void Dispose() { if (this.Texture != null) { this.Texture.Dispose(); this.Texture = null; } base.Dispose(); }
public void Render(IController controller) { GetSpectrum(controller); Gl.glPushAttrib(Gl.GL_ENABLE_BIT); Gl.glDisable(Gl.GL_DEPTH_TEST); Gl.glTexEnvf(Gl.GL_TEXTURE_ENV, Gl.GL_TEXTURE_ENV_MODE, Gl.GL_DECAL); // voiceprint Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glPushMatrix(); Gl.glLoadIdentity(); Glu.gluOrtho2D(0, controller.Width, 0, controller.Height); Gl.glMatrixMode(Gl.GL_TEXTURE); Gl.glPushMatrix(); Gl.glLoadIdentity(); Gl.glScalef(1f / controller.Width, 1f / controller.Height, 1f); if (voiceprintBuffer == null) { voiceprintBuffer = new TextureHandle(controller.Width, controller.Height); } else { voiceprintBuffer.SetTextureSize(controller.Width, controller.Height); } Gl.glBindTexture(Gl.GL_TEXTURE_2D, voiceprintBuffer.TextureId); // OPTIMIZATION: could just copy texture of width voiceprintHeightPx // but then the coordinates get tricky Gl.glCopyTexImage2D(Gl.GL_TEXTURE_2D, 0, Gl.GL_RGB, 0, 0, controller.Width, controller.Height, 0); // clean palette Gl.glClearColor(0, 0, 0, 1); Gl.glClear(Gl.GL_COLOR_BUFFER_BIT); // paste voiceprint region of copied texture, shifted down 1px Gl.glEnable(Gl.GL_TEXTURE_2D); Gl.glBegin(Gl.GL_QUADS); Gl.glTexCoord2f(0, 1); Gl.glVertex2f(0, 0); Gl.glTexCoord2f(0, voiceprintHeightPx); Gl.glVertex2f(0, voiceprintHeightPx - 1); Gl.glTexCoord2f(controller.Width, voiceprintHeightPx); Gl.glVertex2f(controller.Width, voiceprintHeightPx - 1); Gl.glTexCoord2f(controller.Width, 1); Gl.glVertex2f(controller.Width, 0); Gl.glEnd(); Gl.glDisable(Gl.GL_TEXTURE_2D); Gl.glBegin(Gl.GL_QUADS); // instead of using a smoothed buffer like with the analyzer, // use the direct buffer for nicer looking output (less blurry) float x = 0; for (int i = 0; i < bufferLength; i++) { float v = spectrumBuffer[i]; Color.FromHSL(120 * (1 - v), 1, Math.Min(0.5f, v)).Use(); // draw a little beyond the edge to ensure no visible seams Gl.glVertex2f(x, voiceprintHeightPx-1); Gl.glVertex2f(x, voiceprintHeightPx+1); x += bufferScaling[i]; Gl.glVertex2f(x, voiceprintHeightPx+1); Gl.glVertex2f(x, voiceprintHeightPx-1); } Gl.glEnd(); Gl.glMatrixMode(Gl.GL_TEXTURE); Gl.glPopMatrix(); Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glPopMatrix(); // analyzer Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glPushMatrix(); Gl.glLoadIdentity(); // analyzer at top side of screen Glu.gluOrtho2D(-1, 1, 1 - analyzerHeightOrtho, 1); RenderAnalyzer();// coordinates: [-1,+1] in x,y Gl.glMatrixMode(Gl.GL_PROJECTION); Gl.glPopMatrix(); Gl.glPopAttrib(); }