Archive for November, 2007

Page 406 (Web hosting faq) OpenGL Super Bible! Table 11-2 OpenGL

Friday, November 9th, 2007

Page 406 OpenGL Super Bible! Table 11-2 OpenGL Pixel Types Type Description GL_BYTE Signed 8-bit values (from 128 to 127) GL_UNSIGNED_BYTE Unsigned 8-bit values (from 0 to 255) GL_BITMAP Bitmap image (from 0 to 1) Remapping Colors When using GL_COLOR_INDEX colors, you can remap the colors in your pixmap or bitmap using the glPixelMap or glPixelTransfer functions. The glPixelTransfer function lets you specify scaling and offsets for color index and RGB values. For example, here is the code to brighten an RGB image by 10%: glPixelTransferf(GL_RED_SCALE, 1.1) glPixelTransferf(GL_GREEN_SCALE, 1.1); glPixelTransferf(GL_BLUE_SCALE, 1.1); Similarly, to offset the color indices of a bitmap to the palette entries you have defined for it, use glPixelTransferi(GL_INDEX_OFFSET, bitmap_entry); In the smiley bitmap example (Listing 11-7), we might use this to remap the two colors in the bitmap to difference indices: Listing 11-7 Repaint Window function to draw smiley faces void RepaintWindow(RECT *rect) /* I - Client area rectangle */ { int i; /* Looping var */ static GLubyte smiley[] = /* 16×16 smiley face */ { 0×03, 0xc0, 0, 0, /* **** */ 0×0f, 0xf0, 0, 0, /* ******** */ 0×1e, 0×78, 0, 0, /* **** **** */ 0×39, 0×9c, 0, 0, /* *** ** *** */ 0×77, 0xee, 0, 0, /* *** ****** *** */ 0×6f, 0xf6, 0, 0, /* ** ******** ** */ 0xff, 0xff, 0, 0, /* **************** */
We recommend high quality webhost to host and run your jsp application: christian web host services.

OpenGL Super Bible! Page 405 (Best web hosting) Drawing Pixmaps OpenGL

Thursday, November 8th, 2007

OpenGL Super Bible! Page 405 Drawing Pixmaps OpenGL provides a single function for drawing pixmaps called glDrawPixels. Like glBitmap, glDrawPixels uses the current raster position to define the lower-left corner of the image. You cannot specify a raster origin or movement as you can for glBitmap. BITMAPINFO *BitmapInfo; GLubyte *BitmapBits; glRasterPos2i(xoffset, yoffset); glDrawPixels(BitmapInfo->bmiHeader.biWidth, BitmapInfo->bmiHeader.biHeight, GL_RGB, GL_UNSIGNED_BYTE, BitmapBits); The glDrawPixels function accepts five arguments: glDrawPixels(GLsizei width, GLsizei height, GLenum format, GLenum type, Glvoid *pixels) The format parameter specifies the colorspace of the pixmap; valid formats are in Table 11 1. The GL_COLOR_INDEX format specifies that each color value in the pixmap is an index into the current Windows logical color palette. Color index images are often used for icons. The GL_LUMINANCE format maps each color value to a grayscale value on the screen, with the minimum value being completely black and the maximum value being completely white. The GL_RGB format specifies the exact red, green, and blue values for each pixel in the image. Table 11-1 OpenGL Pixel Formats Format Description GL_COLOR_INDEX Color index pixels GL_LUMINANCE Grayscale pixels GL_RGB RGB pixels The type parameter of glDrawPixels specifies the type and range of each color value or component, as listed in Table 11-2.
If you are in need for chaep and reliable webhost to host your website, our recommendation is http web server services.

Page 404 OpenGL Super Bible! A Note About (Unlimited web hosting)

Wednesday, November 7th, 2007

Page 404 OpenGL Super Bible! A Note About glCallLists and Strings: It is important to remember that glCallLists and the font functions presented here do not handle control characters such as tab and newline. If you include control characters in the string you display, other display lists may be called that affect your final output. This behavior can be controlled by parsing the incoming string prior to using glCallLists. Newline and tab functionality can be simulated using the glBitmap technique outlined in the previous note, A Note About the Current Raster Position, along with a call to glGetIntegerv (described in Chapter 14). The FontPrintf function (Listing 11-6) uses the header file to manage the variable number of arguments needed for vsprintf, which formats the string to be drawn. Listing 11-6 FontPrintf function #define MAX_STRING 1024 void FontPrintf(GLuint font, /* I - Font to use */ char *format, /* I - printf() style format string */ )/* I - Other arguments as necessary */ { va_list ap; /* Argument pointer */ char s[MAX_STRING + 1]; /* Output string */ if (format == NULL) return; va_start(ap, format); /* Start variable argument processing */ vsprintf(s, format, ap); /* Format the text into our output string */ va_end(ap); /* End variable argument processing */ FontPuts(font, s); } The complete code for FontCreate, FontDelete, FontPuts, and FontPrintf can be found in the CH11FONT.C file. Prototypes are in the CH11FONT.H file on the source code CD-ROM. Pixmaps: Bitmaps with Color Images with more than two colors are usually called pixmaps (short for pixel maps) and are used as background images or textures (covered in Chapter 12). In OpenGL, pixmaps are generally either 8-bit color index images or 24-bit RGB images.
You want to have a cheap webhost for your apache application, then check apache web hosting services.

Medical web site - OpenGL Super Bible! Page 403 else font =

Wednesday, November 7th, 2007

OpenGL Super Bible! Page 403 else font = CreateFont(height, 0, 0, 0, weight, italic, FALSE, FALSE, UNICODE_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, DEFAULT_PITCH, typeface); SelectObject(hdc, font); wglUseFontBitmaps(hdc, 32, 224, base); To complement FontCreateBitmaps you ll need a font deletion function (Listing 11-4). Here the glDeleteLists function simply deletes the specified display lists, in this case our font bitmaps. As with the FontCreateBitmaps function, to make this function work with international character sets you need to change the number of display lists from 96 to 224. Listing 11-4 FontDelete function void FontDelete(GLuint font) /* I - Font to delete */ { if (font == 0) return; glDeleteLists(font, 96); } Finally, to make drawing character strings easier, you can make put-string and printf-string functions. FontPuts (Listing 11-5) uses the glPushAttrib and glPopAttrib functions to save and restore the current display list base ID. If you forget to do this, you might inadvertently affect your other drawing code that uses display lists! Listing 11-5 FontPuts function void FontPuts(GLuint font, /* I - Font to use */ char *s) /* I - String to display */ { if (font == 0) return; if (s == NULL) return; glPushAttrib(GL_LIST_BIT); glListBase(font - 32); glCallLists(strlen(s), GL_UNSIGNED_BYTE, s); glPopAttrib(); }
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Page 402 OpenGL Super Bible! { Gluint base; (Yahoo free web hosting)

Tuesday, November 6th, 2007

Page 402 OpenGL Super Bible! { Gluint base; /* Base display list for font */ HFONT font; /* Windows font ID */ if ((base = glGenLists(96)) == 0) return (0); The typeface argument is simply the name of the font, such as Courier or Helvetica, and specifies the style of character that you want. The height, weight, and italic arguments are passed directly to wglUseFontBitmaps and set the size and appearance of the characters. Before you create the font bitmaps, you need to decide on a character set. Normally you ll use the ANSI or UNICODE character sets. The ANSI character set (ANSI_CHARSET) provides the standard 7-bit ASCII character set. To support international characters and diacritical marks, use the UNICODE character set instead (UNICODE_CHARSET). Some fonts use special character sets. The Symbol font, for example, provides Greek letters and many scientific symbols. For this simple implementation, we will set the character set to ANSI_CHARSET for normal fonts, and SYMBOL_FONTSET for the Symbol font. See Listing 11-3. Listing 11-3 Continuation of the FontCreateBitmaps function if (stricmp(typeface, “symbol”) == 0) font = CreateFont(height, 0, 0, 0, weight, italic, FALSE, FALSE, SYMBOL_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, DEFAULT_PITCH, typeface); else font = CreateFont(height, 0, 0, 0, weight, italic, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DRAFT_QUALITY, DEFAULT_PITCH, typeface); SelectObject(hdc, font); wglUseFontBitmaps(hdc, 32, 96, base); return (base); } If you need to use international characters, change the normal character set to UNICODE_CHARSET, and define 224 characters (256 minus 32), as shown here:
We recommend you use shared web hosting services, because many users agree that it is cheap, reliable and customer-satisfying webhost.

OpenGL Super (Web hosting companies) Bible! Page 401 Bitmap Fonts One

Monday, November 5th, 2007

OpenGL Super Bible! Page 401 Bitmap Fonts One very important application of bitmaps is displaying character strings. Under ordinary circumstances, you would have to define a bitmap array for each character and then draw the bitmaps as necessary to display the string. Fortunately, the Microsoft Windows Win32 libraries provide a function called wglUseFontBitmaps to generate these bitmaps from font files loaded on your system. To use the font bitmaps, OpenGL provides three functions: glGenLists, glListBase and glCallLists (described in Chapter 10). The glGenLists function generates a contiguous series of OpenGL display list IDs that will hold the character bitmaps created by wglUseFontBitmaps. GLuint base; HDC hdc; base = glGenLists(96); wglUseFontBitmaps(hdc, 32, 96, base); This creates 96 character bitmaps from the current font starting at character 32, the ASCII code for the space character. The base variable contains the first display list bitmap in the font in this case, character 32 (ASCII space). To display a string of characters using these bitmaps, you use a combination of glListBase and glCallLists: char *s; glListBase(base - 32); glCallLists(strlen(s), GL_UNSIGNED_BYTE, s); The glListBase function sets the base display list ID. The glCallList and glCallLists functions will add this number to the display list ID(s) passed to them, effectively selecting the font you just defined. The glCallLists function calls a series of display lists based upon the array of characters (unsigned bytes) you pass in, which draws the character string. Building a Simple Font Library Certainly the wglCreateFontBitmaps function simplifies font creation, but you still have to do a lot just to output a character string. You can build a usable font library fairly easily, however. To start, you ll need a font creation function (Listing 11-2). Listing 11-2 The beginning of the FontCreateBitmaps function GLuint FontCreateBitmaps(HDC hdc, /* I - Device Context */ char *typeface, /* I - Font specification */ int height, /* I - Font height/size in pixels */ int weight, /* I - Weight of font (bold, etc) */ DWORD italic) /* I - Text is italic */
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Page 400 OpenGL Super Bible! A Note About

Sunday, November 4th, 2007

Page 400 OpenGL Super Bible! A Note About Clipping: Polygons and other vector-drawing primitives will still be drawn if they lie partially out of the current viewport, and clipped to the edges of the viewport. Clipping for bitmaps works a little differently. If the raster position you specify lies outside of the current viewport, the bitmap will not be drawn. To draw the bitmap, call the glBitmap function: glBitmap(16, 16, 8.0, 8.0, 0.0, 0.0, smiley); In this case we are drawing a 16 x 16 bitmap whose center lies at (8.0, 8.0) in the bitmap. After the bitmap is drawn, the raster position is moved (0.0, 0.0) pixels. The prototype for this function is as follows: glBitmap(GLsizei width, GLsizei height, Gfloat xorig, GLfloat yorig, GLfloat xmove, GLfloat ymove, const GLubyte *bits) The width and height parameters specify the width and height of the bitmap. The bits parameter contains the bitmap you want to draw and is 32-bit aligned. The xorig and yorig parameters contain the center location of the bitmap. After the bitmap is drawn, the current raster position is moved by (xmove,ymove) pixels, and the raster position valid flag is left unchanged. The xmove and ymove parameters are normally used for bitmap fonts (described in the upcoming section) to advance to the next character cell. A Note About the Current Raster Position: As stated earlier, bitmaps will not be drawn if the raster position is outside the bitmap. However, since the raster position valid flag is left unchanged after a call to glBitmap, you can use glBitmap to position and draw bitmaps that are partially clipped on the edge of the current viewport. For example, here s how to draw the smiley bitmap just to the left of the current viewport: glRasterPos2i(0, 0); glBitmap(0, 0, 0.0, 0.0, -4.0, 0.0, NULL); glBitmap(16, 16, 8.0, 8.0, 0.0, 0.0, smiley); The NULL parameter in the first call to glBitmap simply specifies that there is no bitmap to draw. After the first call to glBitmap, the current raster position will be moved 4 pixels to the left ( 4.0) before the real bitmap is drawn in the second call. This solution also applies to drawing pixmaps, explained later in this chapter.
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

OpenGL Super Bible! Page (Web design careers) 399 /* * This

Saturday, November 3rd, 2007

OpenGL Super Bible! Page 399 /* * This bitmap is aligned to 4-byte boundaries */ glPixelTransferi(GL_UNPACK_ALIGNMENT, 4); glColor3f(1.0, 0.0, 0.0); for (i = 0; i < 100; i ++) { glRasterPos2i(rand() % rect->right, rand() % rect->bottom); glBitmap(16, 16, 8.0, 8.0, 0.0, 0.0, smiley); }; glFinish(); } In this example, we have defined a 16 x 16-pixel bitmap image of a smiley face. The bitmap is an array of 32 unsigned bytes (GLubyte), with bit 7 of the first byte corresponding to the bottom-left corner. Some Things to Note About Bitmaps: OpenGL bitmaps are usually defined upside down. That is, they are stored from bottom to top. (In fact, you can see that the happy face defined as smiley is upside down.) To define them from top to bottom, you must specify a negative height. Also, because of bugs in the Microsoft OpenGL libraries, you must align each scanline (row) of bitmap data to a 4-byte boundary. With a properly functioning OpenGL library, you could use the glPixelStore function described later in this chapter to change the bitmap alignment. After defining a bitmap image to draw, we must specify the current raster position by calling the glRasterPos function: glRasterPos2i(rand() % rect->right, rand() % rect->bottom); In this example, we are positioning our smiley face randomly within the client area of our window with the bitmap offset by 8 pixels from the left and bottom. The raster position is specified in world/model coordinates, just like a glVertex position. In addition to setting the current raster position, glRasterPos also sets a raster position valid flag. This Boolean flag is True if the raster position lies inside the current viewport, and False otherwise.
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Web hosting companies - Page 398 OpenGL Super Bible! Figure 11-1 Output

Friday, November 2nd, 2007

Page 398 OpenGL Super Bible! Figure 11-1 Output from glBitmap example Listing 11-1 Drawing the window of smiley faces void RepaintWindow(RECT *rect) /* I - Client area rectangle */ { int i; /* Looping var */ static GLubyte smiley[] = /* 16×16 smiley face */ { 0×03, 0xc0, 0, 0, /* **** */ 0×0f, 0xf0, 0, 0, /* ******** */ 0×1e, 0×78, 0, 0, /* **** **** */ 0×39, 0×9c, 0, 0, /* *** ** *** */ 0×77, 0xee, 0, 0, /* *** ****** *** */ 0×6f, 0xf6, 0, 0, /* ** ******** ** */ 0xff, 0xff, 0, 0, /* **************** */ 0xff, 0xff, 0, 0, /* **************** */ 0xff, 0xff, 0, 0, /* **************** */ 0xff, 0xff, 0, 0, /* **************** */ 0×73, 0xce, 0, 0, /* *** **** *** */ 0×73, 0xce, 0, 0, /* *** **** *** */ 0×3f, 0xfc, 0, 0, /* ************ */ 0×1f, 0xf8, 0, 0, /* ********** */ 0×0f, 0xf0, 0, 0, /* ******** */ 0×03, 0xc0, 0, 0 /* **** */ }; glViewport(0, 0, rect->right, rect->bottom); glClearColor(0.0, 0.0, 0.0, 1.0); glClear(GL_COLOR_BUFFER_BIT); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, rect->right - 1.0, 0.0, rect->bottom - 1.0, -1.0, 1.0);
Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

OpenGL Super Bible! (Dedicated web hosting) Page 397 Chapter 11 Raster

Thursday, November 1st, 2007

OpenGL Super Bible! Page 397 Chapter 11 Raster Graphics in OpenGL What you ll learn in this chapter: How to Functions You ll Use Draw bitmap images glBitmap/glRasterPos Use bitmap fonts wglUseFontBitmaps/glGenLists/glCallLists Draw color images glDrawPixels Read and copy color images on the screen glCopyPixels/glReadPixels Read and write Windows bitmap files LoadDIBitmap/SaveDIBitmap You ve probably heard a lot of sales hype lately about how much better it is to work with 3D graphics than with those old 2D graphics from years ago. While this is true for the most part, ultimately those 3D graphics are drawn in two dimensions on your screen. Raster graphics are two-dimensional arrays of colors and are used not only for displaying 3D graphics on the screen but also for printing images on raster printers or motion-picture film In addition to the vector and polygon functions we ve examined so far, OpenGL provides several functions that directly manage 2D bitmaps and images. Those functions are the subject of this chapter. Drawing Bitmaps Bitmaps in OpenGL are two-color images that are used to quickly draw characters or symbols (such as icons) on the screen. This diverges from the (incorrect) Microsoft Windows definition that includes multicolored images, as well. OpenGL provides a single function to draw bitmaps: glBitmap. When you draw a bitmap with glBitmap, the first color (0) is transparent. The second color (1) is drawn using the current color and lighting material attributes. Figure 11-1 shows an OpenGL bitmap image of smiley faces. The code (Listing 11-1) to draw this window consists of the bitmap data followed by a call to glBitmap.
You need excellent and relaible webhost company to host your web applications? Then pay a visit to Inexpensive Web Hosting services.