internal FrameBuffer(GraphicsContext graphics) { this.handle = 0; this.state = new FrameBufferState(); this.state.status = true; PsmGraphicsContext.GetScreenInfo(graphics.handle, out this.state.width, out this.state.height, out this.state.colorFormat, out this.state.depthFormat, out this.state.multiSampleMode); }
public void ReadPixels(TextureCube texture, int level, TextureCubeFace cubeFace, int dx, int dy, int sx, int sy, int sw, int sh) { this.CheckUpdate(); int errorCode = PsmGraphicsContext.ReadPixels2(this.handle, texture.handle, level, cubeFace, dx, dy, sx, sy, sw, sh); if (errorCode != 0) { Error.ThrowNativeException(errorCode); } }
public void ReadPixels(byte[] pixels, PixelFormat format, int sx, int sy, int sw, int sh) { this.CheckUpdate(); int errorCode = PsmGraphicsContext.ReadPixels(this.handle, pixels, format, sx, sy, sw, sh); if (errorCode != 0) { Error.ThrowNativeException(errorCode); } }
public void DrawArraysInstanced(DrawMode mode, int first, int count, int instFirst, int instCount) { this.CheckUpdate(); int errorCode = PsmGraphicsContext.DrawArraysInstanced(this.handle, mode, first, count, instFirst, instCount); if (errorCode != 0) { Error.ThrowNativeException(errorCode); } }
public void DrawArrays(Primitive[] primitives) { this.CheckUpdate(); int errorCode = PsmGraphicsContext.DrawArrays2(this.handle, primitives, 0, -1); if (errorCode != 0) { Error.ThrowNativeException(errorCode); } }
public void Clear(ClearMask mask) { this.CheckUpdate(); int errorCode = PsmGraphicsContext.Clear(this.handle, mask); if (errorCode != 0) { Error.ThrowNativeException(errorCode); } }
protected virtual void Dispose(bool disposing) { if (disposing) { if (this.virtualScreen != null) { this.virtualScreen.Dispose(); } this.virtualScreen = null; } PsmGraphicsContext.Delete(this.handle); this.handle = 0; }
public void DrawArrays(Primitive[] primitives, int first, int count) { this.CheckUpdate(); if (count < 0) { count = int.MaxValue; } int errorCode = PsmGraphicsContext.DrawArrays2(this.handle, primitives, first, count); if (errorCode != 0) { Error.ThrowNativeException(errorCode); } }
public void SwapBuffers() { if (this.virtualScreen != null) { this.virtualScreen.Present(this, this.deviceScreen); } int errorCode = PsmGraphicsContext.SwapBuffers(this.handle); if (errorCode != 0) { Error.ThrowNativeException(errorCode); } GraphicsContext.notifyUpdate |= GraphicsUpdate.Viewport; }
private void CheckUpdate() { if (this.shaderProgram != null) { this.shaderProgram.UpdateShader(); } if (GraphicsContext.notifyUpdate != GraphicsUpdate.None) { if ((GraphicsContext.notifyUpdate & GraphicsUpdate.ShaderProgram) != GraphicsUpdate.None) { this.handles[0] = ((this.shaderProgram == null) ? 0 : this.shaderProgram.handle); } PsmGraphicsContext.Update(this.handle, GraphicsContext.notifyUpdate, ref this.state, this.handles); GraphicsContext.notifyUpdate = GraphicsUpdate.None; } }
static GraphicsContext() { int result; PsmGraphicsContext.GetScreenSizes(null, out result); GraphicsContext.screenSizes = new ImageSize[result]; PsmGraphicsContext.GetScreenSizes(GraphicsContext.screenSizes, out result); int screenWidth; int screenHeight; PsmGraphicsContext.GetMaxScreenSize(out screenWidth, out screenHeight); for (int i = 0; i < result; i++) { if (GraphicsContext.screenSizes[i].Width > screenWidth || GraphicsContext.screenSizes[i].Height > screenHeight) { ScreenBuffer.FitRect(screenWidth, screenHeight, ref GraphicsContext.screenSizes[i].Width, ref GraphicsContext.screenSizes[i].Height); } } }
public GraphicsContext(int width, int height, PixelFormat colorFormat, PixelFormat depthFormat, MultiSampleMode multiSampleMode) { int errorCode = PsmGraphicsContext.Create(width, height, colorFormat, depthFormat, multiSampleMode, out this.handle); if (errorCode != 0) { Error.ThrowNativeException(errorCode); } this.caps = new GraphicsCaps(this); this.screen = (this.deviceScreen = new FrameBuffer(this)); if (ScreenBuffer.NeedVirtualScreen(this.screen, ref width, ref height)) { this.screen = (this.virtualScreen = new ScreenBuffer(this, this.deviceScreen, width, height, colorFormat, depthFormat, multiSampleMode)); GraphicsContext.notifyUpdate |= (GraphicsUpdate)6U; } this.SetFrameBuffer(null); this.state.Reset(this.screen); GraphicsContext.notifyUpdate |= GraphicsUpdate.Viewport; }
public static bool NeedVirtualScreen(FrameBuffer screen, ref int width, ref int height) { if (width == 0) { width = screen.Width; } if (height == 0) { height = screen.Height; } int screenWidth; int screenHeight; PsmGraphicsContext.GetMaxScreenSize(out screenWidth, out screenHeight); if (width > screenWidth || height > screenHeight) { ScreenBuffer.FitRect(screenWidth, screenHeight, ref width, ref height); } return(screen.Width != width || screen.Height != height); }
private void AdjustAspect(GraphicsContext graphics, FrameBuffer deviceScreen, int width, int height) { int endPointY = 0; int endPointX = 0; int w = width; int h = height; int screenWidth = deviceScreen.Width; int screenHeight = deviceScreen.Height; ushort[] vertexData = new ushort[4]; float multip; if (ScreenBuffer.FitRect(screenWidth, screenHeight, ref width, ref height)) { endPointY = (screenWidth - width) / 2; multip = (float)endPointY / (float)screenWidth * 2f - 1f; vertexData[0] = 18; vertexData[1] = 27; vertexData[2] = 36; vertexData[3] = 45; } else { endPointX = (screenHeight - height) / 2; multip = (float)endPointX / (float)screenHeight * -2f + 1f; vertexData[0] = 10; vertexData[1] = 28; vertexData[2] = 37; vertexData[3] = 55; } for (int i = 0; i < 4; i++) { ScreenBuffer.vertexData[(int)vertexData[i]] = multip; ScreenBuffer.vertexData[(int)(vertexData[i] + 36)] = -multip; } PsmGraphicsContext.SetActiveScreen(graphics.handle, endPointY, endPointX, width, height); PsmGraphicsContext.SetVirtualScreen(graphics.handle, 0, 0, w, h); }
internal GraphicsCaps(GraphicsContext graphics) { PsmGraphicsContext.GetCaps(graphics.handle, out this.state); }