PDA

View Full Version : [Open-GL]un paio di quesiti su opengl....


tylerdurden83
07-07-2005, 18:39
Ciao a tutti! Ho bisogno di un aiuto per quanto riguarda opengl. Avrei bisogno di sapere come poter visualizzare un immagine di sfondo, e come poter far si che dei punti mi vengano disegnati non tutti insieme ma, diciamo, per linee. Se non sono stato chiaro chiedetemi pure!
Grazie 1000 a tutti uqelli che mi aiuteranno!!!

DanieleC88
08-07-2005, 09:20
Per lo sfondo, mi sa che devi usare ripetute chiamate a glRasterPos*() e glBitmap*() per disegnare lo sfondo. Il secondo dubbio non l'ho capito. :)

tylerdurden83
08-07-2005, 12:38
nelle parentesi devo mettere l'immagine che voglio visualizzare?
ti spiego il secondo. diciamo che voglio far comparire uno sfondo e su questo sfondo andare a disegnare dei punti colorati random, mi interesserebbe far si che appaiano per righe invece che tutti insieme, un po come farebbe una stampante diciamo.

DanieleC88
08-07-2005, 16:10
The Current Raster Position
The current raster position is the origin where the next bitmap (or image) is to be drawn. In the F example, the raster position was set using glRasterPos*() to (20, 20), which is where the lower left corner of the F was drawn:

glRasterPos2i(20, 20);

void glRasterPos{234}{sifd}{v}(TYPE x, TYPE y, TYPE z, TYPE w);

Sets the current raster position. The x, y, z, and w arguments specify the coordinates of the raster position. If glRasterPos2*() is used, z is implicitly set to zero and w is implicitly set to one; similarly, with glRasterPos3*(), w is set to one.

The coordinates of the raster position are transformed to screen coordinates in exactly the same way as coordinates supplied with a glVertex*() command (that is, with the modelview and perspective matrices). After transformation, they either define a valid spot in the window on the screen, or they're clipped out because the transformed coordinates lie outside the viewport. If the transformed point is clipped out, the current raster position is invalid.

To obtain the current raster position, you can use the query command glGetFloatv() with GL_CURRENT_RASTER_POSITION as the first argument. The second argument should be a pointer to an allocated array that can hold the (x, y, z, w) values as floating-point numbers. Call glGetBooleanv() with GL_CURRENT_RASTER_POSITION_VALID as the first argument to determine whether the current raster position is valid.
Drawing the Bitmap
Once you've set the desired raster position, you probably want to use the glBitmap() command to draw the data. void glBitmap(GLsizei width, GLsizei height, GLfloat xbo, GLfloat ybo, GLfloat xbi, GLfloat ybi, const GLubyte *bitmap);

Draws the bitmap specified by bitmap, which is a pointer to the bitmap image. The origin of the bitmap is placed at the most recently defined current raster position. If the current raster position is invalid, nothing is drawn, and the raster position remains invalid. The width and height arguments indicate the width and height, in pixels, of the bitmap. The width need not be a multiple of 8, although the data is stored in unsigned characters of 8 bits each. (In the F example, it wouldn't matter if there were garbage bits in the data beyond the tenth bit; since glBitmap() was called with a width of 10, only 10 bits of the row are rendered.) Use xbo and ybo to define the origin of the bitmap (positive values move the origin up and to the right; negative values move it down and to the left); xbi and ybi indicate the x and y increments that are added to the raster position after the bitmap is rasterized (see Figure 8-2 ).

[IMAGE]

Figure 8-2 : A Bitmap and Its Associated Parameters



Allowing the origin of the bitmap to be placed arbitrarily makes it easy for characters to extend below the origin (typically used for characters with descenders, such as g, j, and y), or to extend beyond the left of the origin (used for various swash characters, which have extended flourishes, or for characters in fonts that lean to the left).

After the bitmap is drawn, the current raster position is advanced by xbi and ybi in the x- and y-directions, respectively. For standard Latin fonts, ybi is typically 0.0 and xbi is positive (since successive characters are drawn from left to right). For Hebrew, where characters go from right to left, the xbi values would typically be negative. Fonts that draw successive characters vertically in columns would use zero for xbi and nonzero values for ybi. In Figure 8-2 , each time the F is drawn, the current raster position advances by 12 pixels, allowing a 2-pixel space between successive characters.

Since xbo, ybo, xbi, and ybi are floating-point values, characters need not be an integral number of pixels wide. Actual characters are drawn on exact pixel boundaries, but the current raster position is kept in floating point so that each character is drawn as close as possible to where it belongs. For example, if the code in the F example was modified so that xbi is 11.5 instead of 12, and if more characters were drawn, the space between letters would alternate between one and two pixels, giving the best approximation to the requested 1.5-pixel space. Note that bitmaps can't be used for rotatable fonts because the bitmap is always drawn aligned to the x and y framebuffer axes.

Per i punti, devi disegnarli uno ad uno con un intervallo.

DanieleC88
11-07-2005, 16:50
Dimenticavo: http://www.opengl.org/documentation/red_book_1.0/

tylerdurden83
11-07-2005, 16:54
grazie 100000000 adesso me lo studio!!!