private GraphicsAdapter() { IntPtr infoPtr = Sdl.SDL_GetVideoInfo(); Sdl.SDL_VideoInfo info = (Sdl.SDL_VideoInfo)Marshal.PtrToStructure(infoPtr, typeof(Sdl.SDL_VideoInfo)); currentDisplayMode = new DisplayMode(info.current_w, info.current_h, -1, SurfaceFormat.Bgr32); hardwareCapabilities = new GraphicsDeviceCapabilities(); findGLCapabilities(); }
public GraphicsDevice(GraphicsAdapter adapter, DeviceType deviceType, IntPtr renderWindowHandle, PresentationParameters presentationParameters) { if (adapter == null || presentationParameters == null) { throw new ArgumentNullException("adapter or presentationParameters is null."); } graphicsDeviceCapabilities = adapter.GetCapabilities(deviceType); numActiveRenderTargets = 0; renderTargets = new RenderTarget[graphicsDeviceCapabilities.MaxSimultaneousRenderTargets]; initGL(); this.adapter = adapter; this.deviceType = deviceType; this.renderWindowHandle = renderWindowHandle; PresentationParameters = presentationParameters; // set through property to ensure OpenGL propagation this.textures = new TextureCollection(); this.clearColor = Color.Black; }
void PrintDeviceCapabilities(StreamWriter wr, GraphicsDeviceCapabilities state) { wr.WriteLine("/n /n -----------Device Capabilities-----------"); wr.WriteLine("AdapterOrdinalInGroup : {0}", state.AdapterOrdinalInGroup); wr.WriteLine("DeviceType : {0}", state.DeviceType); }
/// <summary>(Internal Helper) Checks the backbuffer's texture size</summary> bool CheckTextureSize(int width, int height, out int newwidth, out int newheight) { bool retval = false; GraphicsCaps = GraphicsAdapter.DefaultAdapter.GetCapabilities(DeviceType.Hardware); //MODERN HARDWARE SHOULDN'T NEED THIS CRAP if (GraphicsCaps.TextureCapabilities.RequiresPower2) { retval = true; // Return true to indicate the numbers changed /*Find the nearest base two log of the current width, and go up to the next integer */ double exp = Math.Ceiling(Math.Log(width) / Math.Log(2)); //and use that as the exponent of the new width width = (int)(exp * exp); //Repeat the process for height exp = Math.Ceiling(Math.Log(height) / Math.Log(2)); height = (int)(exp * exp); } if (GraphicsCaps.TextureCapabilities.RequiresSquareOnly) { retval = true; // Return true to indicate numbers changed width = Math.Max(width, height); height = width; } newwidth = Math.Min(GraphicsCaps.MaxTextureWidth, width); newheight = Math.Min(GraphicsCaps.MaxTextureHeight, height); return retval; }
/****************************************FUNCTIONS***************************************/ public void Initialize(ContentManager content) { SpriteBatch = new SpriteBatch(Core.Graphics.GraphicsDevice); vdPositionColor = new VertexDeclaration(Core.Graphics.GraphicsDevice, VertexPositionColor.VertexElements); vdPositionNormalTexture = new VertexDeclaration(Core.Graphics.GraphicsDevice, VertexPositionNormalTexture.VertexElements); GraphicsCaps = GraphicsAdapter.DefaultAdapter.GetCapabilities(DeviceType.Hardware); SceneTexture = new ResolveTexture2D(mGraphics.Peek.Device(), mGraphics.Peek.Device().PresentationParameters.BackBufferWidth, mGraphics.Peek.Device().PresentationParameters.BackBufferHeight, 1, mGraphics.Peek.Device().PresentationParameters.BackBufferFormat); SceneRenderTarget = CreateRenderTarget(1, mGraphics.Peek.Device().PresentationParameters.BackBufferFormat); mCamera.Peek.Initialize(Engine.TempVector3(0.0f, 0.0f, 0.0f)); }
private GraphicsAdapter() { IntPtr infoPtr = Sdl.SDL_GetVideoInfo (); Sdl.SDL_VideoInfo info = (Sdl.SDL_VideoInfo) Marshal.PtrToStructure (infoPtr, typeof (Sdl.SDL_VideoInfo)); currentDisplayMode = new DisplayMode(info.current_w, info.current_h, -1, SurfaceFormat.Bgr32); hardwareCapabilities = new GraphicsDeviceCapabilities(); findGLCapabilities(); }