/// <summary> /// Resizes the section. /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="bitCount">The bit count.</param> public void Resize(int width, int height, int bitCount) { // Destroy existing objects. this.DestroyBitmap(); // Set parameters. this.Width = width; this.Height = height; // Create a bitmap info structure. var info = new BitmapInfo(); info.Init(); // Set the data. info.biBitCount = (short)bitCount; info.biPlanes = 1; info.biWidth = width; info.biHeight = height; // Create the bitmap. this.HBitmap = Win32.CreateDIBSection(this.MemoryDeviceContext, ref info, Win32.DIB_RGB_COLORS, out this.bits, IntPtr.Zero, 0); Win32.SelectObject(this.MemoryDeviceContext, this.HBitmap); }
/// <summary> /// Creates the specified width. /// </summary> /// <param name="deviceContext"></param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="bitCount">The bit count.</param> /// <returns></returns> public virtual bool Create(IntPtr deviceContext, int width, int height, int bitCount) { this.Width = width; this.Height = height; this.MemoryDeviceContext = Win32.CreateCompatibleDC(deviceContext); // Destroy existing objects. this.DestroyBitmap(); // Create a bitmap info structure. var info = new BitmapInfo(); info.Init(); // Set the data. info.biBitCount = (short)bitCount; info.biPlanes = 1; info.biWidth = width; info.biHeight = height; // Create the bitmap. this.HBitmap = Win32.CreateDIBSection(this.MemoryDeviceContext, ref info, Win32.DIB_RGB_COLORS, out this.bits, IntPtr.Zero, 0); Win32.SelectObject(this.MemoryDeviceContext, this.HBitmap); // Set the OpenGL pixel format. SetPixelFormat(this.MemoryDeviceContext, bitCount); return(true); }
/// <summary> /// Creates the specified width. /// </summary> /// <param name="deviceContext"></param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="parameters">parameters.</param> public DIBSection(IntPtr deviceContext, int width, int height, ContextGenerationParams parameters) { this.Width = width; this.Height = height; this.MemoryDeviceContext = Win32.CreateCompatibleDC(deviceContext); // Destroy existing objects. this.DestroyBitmap(); // Create a bitmap info structure. var info = new BitmapInfo(); info.Init(); // Set the data. info.biBitCount = parameters.ColorBits; info.biPlanes = 1; info.biWidth = width; info.biHeight = height; // Create the bitmap. IntPtr mdc = this.MemoryDeviceContext; this.HBitmap = Win32.CreateDIBSection(mdc, ref info, Win32.DIB_RGB_COLORS, out this.bits, IntPtr.Zero, 0); Win32.SelectObject(mdc, this.HBitmap); // Set the OpenGL pixel format. this.SetPixelFormat(mdc, parameters); }
/// <summary> /// Resizes the section. /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="bitCount">The bit count.</param> public void Resize(int width, int height, int bitCount) { // Destroy existing objects. Destroy(); // Set parameters. Width = width; Height = height; // Create a bitmap info structure. BITMAPINFO info = new BITMAPINFO(); info.Init(); // Set the data. info.biBitCount = (short)bitCount; info.biPlanes = 1; info.biWidth = width; info.biHeight = height; // Create the bitmap. HBitmap = Win32.CreateDIBSection(parentDC, ref info, Win32.DIB_RGB_COLORS, out bits, IntPtr.Zero, 0); Win32.SelectObject(parentDC, HBitmap); }
/// <summary> /// Creates the specified width. /// </summary> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <param name="bitCount">The bit count.</param> /// <returns></returns> public virtual bool Create(IntPtr hDC, int width, int height, int bitCount) { this.Width = width; this.Height = height; parentDC = hDC; // Destroy existing objects. Destroy(); // Create a bitmap info structure. BITMAPINFO info = new BITMAPINFO(); info.Init(); // Set the data. info.biBitCount = (short)bitCount; info.biPlanes = 1; info.biWidth = width; info.biHeight = height; // Create the bitmap. HBitmap = Win32.CreateDIBSection(hDC, ref info, Win32.DIB_RGB_COLORS, out bits, IntPtr.Zero, 0); Win32.SelectObject(hDC, HBitmap); // Set the OpenGL pixel format. SetPixelFormat(hDC, bitCount); return(true); }
private static FontBitmapEntry CreateFontBitmapEntry(string faceName, int height) { // Make the OpenGL instance current. //GL.MakeCurrent(); IntPtr renderContext = Win32.wglGetCurrentContext(); IntPtr deviceContext = Win32.wglGetCurrentDC(); Win32.wglMakeCurrent(deviceContext, renderContext); // Create the font based on the face name. var hFont = Win32.CreateFont(height, 0, 0, 0, Win32.FW_DONTCARE, 0, 0, 0, Win32.DEFAULT_CHARSET, Win32.OUT_OUTLINE_PRECIS, Win32.CLIP_DEFAULT_PRECIS, Win32.CLEARTYPE_QUALITY, Win32.VARIABLE_PITCH, faceName); // Select the font handle. var hOldObject = Win32.SelectObject(deviceContext, hFont); // Create the list base. var listBase = OpenGL.GenLists(1); // Create the font bitmaps. bool result = Win32.wglUseFontBitmaps(deviceContext, 0, 255, listBase); // Reselect the old font. Win32.SelectObject(deviceContext, hOldObject); // Free the font. Win32.DeleteObject(hFont); // Create the font bitmap entry. var fbe = new FontBitmapEntry() { HDC = deviceContext, HRC = renderContext, FaceName = faceName, Height = height, ListBase = listBase, ListCount = 255 }; // Add the font bitmap entry to the internal list. fontBitmapEntries.Add(fbe); return(fbe); }