   OpenGL printing: getting too thin lines and too small points
  Hello,I am trying to output my OpenGL scene to a bitmap and a printer using code that is very similar to the one contained here:http://www.codeguru.com/cpp/g-m/opengl/printing/article.php/c5585It executes fine, except for one thing: in the output, lines appear very thin and points appear very small when using high resolution printing(say 600 dpi). Output to smaller resolutions yields correct results. Calls to glLineWidth() and glPointSize() appear to have no effect or little effect for values higher than 2.To summarize:* When generating BMP files with 75 or 96 dpi, everything is rendered correctly. Lines and Points follow screen appearance.* When printing to a PDF or Laser Printer (which, by default, uses 600 dpi) lines and points appear as 1 pixel width/size.The DPI values retrieved from printer influence size of memory bitmap to where I render. Does anybody now if bitmap size influences how lines and points are rasterized?Thanks in advance.João Pedro   
Quote:Original post by jpnascimHello,I am trying to output my OpenGL scene to a bitmap and a printer using code that is very similar to the one contained here:http://www.codeguru.com/cpp/g-m/opengl/printing/article.php/c5585It executes fine, except for one thing: in the output, lines appear very thin and points appear very small when using high resolution printing(say 600 dpi). Output to smaller resolutions yields correct results. Calls to glLineWidth() and glPointSize() appear to have no effect or little effect for values higher than 2.To summarize:* When generating BMP files with 75 or 96 dpi, everything is rendered correctly. Lines and Points follow screen appearance.* When printing to a PDF or Laser Printer (which, by default, uses 600 dpi) lines and points appear as 1 pixel width/size.The DPI values retrieved from printer influence size of memory bitmap to where I render. Does anybody now if bitmap size influences how lines and points are rasterized?Thanks in advance.João Pedroin opengl a line normally doesn't have a width so when rasterized it becomes as thin as possible, a higher resolution means the line gets thinner, the recommended resolution in windows is 96 dpi (1280x960 for a 16.7" 4:3 monitor) which is why 96 dpi rasterizations match what you see.http://www.khronos.org/opengles/sdk/docs/man/glLineWidth.xmlThe only linewidth that is guaranteed to be supported is 1  , the rest is implementation specific, use glGet to see what range your implementation supports.;Quote:* When generating BMP files with 75 or 96 dpi, everything is rendered correctly. Lines and Points follow screen appearance.* When printing to a PDF or Laser Printer (which, by default, uses 600 dpi) lines and points appear as 1 pixel width/size.A line that is 1 pixel wide at 77/96 dpi is not 1 pixel wide at 600 dpi.You need to scale up glLineWidth() accordingly.  Use GetDeviceCaps() to get the ppi for you device.   ;  Hello,Sorry for not getting back sooner. Thank you for the replies.Quote:Original post by SimonForsmanThe only linewidth that is guaranteed to be supported is 1  , the rest is implementation specific, use glGet to see what range your implementation supports.Ok, I see. By calling glGetIntegerv(GL_LINE_WIDTH_RANGE, range) when render context is the memory bitmap, I get min=1 and max=10.Quote:Original post by samster581A line that is 1 pixel wide at 77/96 dpi is not 1 pixel wide at 600 dpi.You need to scale up glLineWidth() accordingly. Use GetDeviceCaps() to get the ppi for you device.Right. In fact that's what I was doing. I get device DPI for the PDF printer I am using, in this case, 600 dpi. With DPI and page size, I determine bitmap render size, like this:const unsigned X_DPI = GetDeviceCaps(PrinterDialog.hDC, LOGPIXELSX); const unsigned Y_DPI = GetDeviceCaps(PrinterDialog.hDC, LOGPIXELSY);// Define the size of the image that will be createdbitmapWidthOnPage  = pageWidthInches  * X_DPI;bitmapHeightOnPage = pageHeightInches * Y_DPI;Then I build the bitmap, device context, rendering context and activate everything://Create Bitmap herememset(&BitmapInfo, 0, sizeof(BITMAPINFO));BitmapInfo.bmiHeader.biSize   = sizeof(BITMAPINFOHEADER);BitmapInfo.bmiHeader.biWidth   = bitmapWidthOnPage;BitmapInfo.bmiHeader.biHeight   = bitmapHeightOnPage;BitmapInfo.bmiHeader.biPlanes   = 1;BitmapInfo.bmiHeader.biBitCount   = 24;BitmapInfo.bmiHeader.biCompression = BI_RGB;BitmapInfo.bmiHeader.biSizeImage   = ((width * 3) + complement) * height;// Create DIBDibNew = CreateDIBSection(NULL, &BitmapInfo, DIB_RGB_COLORS, &BitmapBits, NULL, (DWORD)0);//Create Device ContextHDC_MemoryBitmap = CreateCompatibleDC(NULL);//...//Create Rendering ContextHRC_MemoryBitmap = wglCreateContext(HDC_MemoryBitmap);//...//Make it currentwglMakeCurrent(HDC_MemoryBitmap, HRC_MemoryBitmap);//...Then I render the scene to the bitmap taking care to set lineWidth to the maximum value of 10 obtained earlier(as a test). Still, rendered line is thin.Any other ideas?Thank you very much,Joao Pedro[Edited by - jpnascim on May 3, 2010 8:50:46 AM];  OpenGL only knows about pixels, it doesn't know anything about ppi or device resolution (as far as I know).   As long as you're setting up a thick line width using glLineWidth(), then the line should look thicker, provided it's supported by your graphics card.So, open up your 600 ppi bitmap and measure the pixel width of your line.  If you say you set its width to 10, then your linesshould be 10 pixels wide.  There's your proof.If you want bigger lines than 10, then you'll have to come up with a new way to render OpenGL lines.  Like, drawing them asthick polygon rectangles.  That will support lines of any thickness.   ;  Well, problem solved.Before the correction, I was generating a bitmap with a size dependent on output device DPI. For example, if page size is A4(8.27 X 11.69 inches) and printer's DPI is 600 I was trying to render a bitmap with size:horizontal = 8.27 x 600 = 4962 pixelsvertical = 11.69 x 600 = 7014 pixelsWhen rendering to this bitmap lines appeared thin, no matter the values I've passed to glLineWidth(). The reason I was doing this was because I thought I would loose image quality in a high DPI device if I rendered to a smaller bitmap and called StretchDIBits() (Win32 API).Well, it turned out that if I generate my bitmap considering 96 dpi:horizontal = 8.27 x 96 dpi = 794  pixelsvertical = 11.69 x 96 dpi  = 1122 pixelsand make a call to StretchDIBits() with the parameters:nDestWidth  = 4962 (paper width in pixels)nDestHeight = 7014 (paper height in pixels)nSrcWidth  = 794  (rendered bitmap width in pixels)nSrcHeight = 1122 (rendered bitmap height in pixels)With these values, results are correct. Lines and Points appear with programmed thickness. Also, print quality is excellent with no loss of resolution due to bitmap scale up operation.Thanks for the help,João Pedro   