Basic State Management Example e Toget the current rgba color gIGetIntegerv(GL_CURRENT_COLOR, Params)or glGetFloatv (GL- CURRENT_ COLOR, Params e Toget how many bits per pixel are available for each individual color component gIGetIntegerv(GL_RED_BITS, red Bit Size) The possible values for pname can be referred to the tables in )pen GL State Variables""The Red Book http://fly.srk.fer.hr/-unreal/theredbook/appendixb.html(releasEone)
Basic State Management Example To get the current RGBA color: glGetIntegerv (GL_CURRENT_COLOR,params) or glGetFloatv (GL_CURRENT_COLOR,params) To get how many bits per pixel are available for each individual color component: glGetIntegerv (GL_RED_BITS,redBitSize) The possible values for pname can be referred to the tables in "OpenGL StateVariables“ in “The Red Book”. http://fly.srk.fer.hr/~unreal/theredbook/appendixb.html (Release one) 11
Color and gray scale The basic attribute for all primitives is color o In a color raster system, the number of colors available depends on the amount of storage per pixel in the frame buffer Two ways to store the color information ● RGB color code o directly stored in the frame buffer E. g: resolution-1024X1024, a full-color(24-bit per pixel)color system 3 megabytes of storage for the frame buffer Color index value(next slide) it references a color lookup table
Color and Gray Scale The basic attribute for all primitives iscolor. In a color raster system, the number of colors available depends on the amount of storage per pixel in the frame buffer. Two ways to store the color information RGB colorcode directly stored in the frame buffer E.g.: resolution - 1024X1024, a full-color (24-bit per pixel) color system 3 megabytes of storage for the frame buffer Color index value (nextslide) it references a color lookup table 12
Color and Gray scale Color index value(cont. Color code into a table(color lookup table or color map) o Tokeep the index value referencing the color-table entries into each pixel ocation Lookup Table To Red Gun e To Blue Gun 1962081 0000000010000010001 Only Megabyte for he frame buffe (ze:1024x1024) A color lookup table with 24 bits per entry that is accessed from a frame buffer with 8 bits per pixel. A value of 196 stored at pixel position (r, y) references the location in this table containing the hexadecimal value Ox0821(a decimal value of 2081) Each 8-bit segment of this entry controls the intensity level of one of the three electron an RGB Computer Graphics with Open GL, Third Edition, by Donald Hearn and M. Pauline Baker ISBN0-13-0-15390-70 2004 Pearson Education, Inc, Upper Saddle River, NJ. All rights reserved
Color and Gray Scale Color index value (cont.) Color code into a table (color lookup table or color map) To keep the index value referencing the color-table entries into each pixel location Only1megabyte for the frame buffer (size: 1024X1024) Figure 5-1 13
OpengL&GLUt Color Functions ● Color display mode o RGB(RGBA) Mode: GLUT_RGB, GLUT_RGBA; GL_ RGB, A"is the alpha value for color blending o Color-Index mode: GLUT INDEX GL COLOR INDEX Set up for using the function glutlnit Display Mode(GLUT- SINGLE GLUT- RGB) TABLE 5.1 RGB (RGBA)mode The eight RGB color codes for a 3-bit- per-pixel frame buffer glColor*(color Components Stored Color values in Frame Buffer Color Code RED GREEN BLUE Displayed Color g: glcolor3f(0.0,1.0,1.0; gIColor 3fv (color array) glColor3i(0,255,255 5 011 Red Ma White
OpenGL&GLUT Color Functions Color display mode RGB (RGBA) Mode:GLUT_RGB, GLUT_RGBA;GL_RGB,… “A” is the alpha value for color blending. Color-Index Mode: GLUT_INDEX;GL_COLOR_INDEX Set up for using the function glutInitDisplayMode (GLUT_SINGLE | GLUT_RGB); RGB (RGBA) mode glColor* (colorComponents); E.g.: glColor3f (0.0, 1.0,1.0); glColor3fv (colorArray); glColor3i (0, 255,255); 14
OpenGL Color Functions Color display mode( cont. Color-index mode gIIndex*(colorIndex) S, 1, d, or colorIndex is a non-negative integer value the number of index in a color table is al ways a power of 2 such as 256 or 1024 Es //set the current color by the index in a color table gIIndexi (196); //to establish the color table glutsetColor(index, red, green, blue)
Color display mode (cont.) Color-index mode glIndex* (colorIndex); *:ub,s,i, d, or f colorIndex is a non-negative integer value. the number of index in a color table is always a power of 2, such as 256 or 1024. E.g.: //set the current color by the index in a color table glIndexi(196); //to establish the color table glutSetColor (index, red, green,blue); OpenGL Color Functions 15