simple graphic pipeline in OpenGL -
i reading schaum's outlines computer graphics. book says simple graphic pipeline this: geometric representation --> transformation --> scan conversion (though author has decided teach scan conversion chapter before transformation chapter). wish learn simple pipeline through example in opengl. suppose wish create line end coordinates (150,400) , (700,100) in window of size (750,500). below code works well. asking experts explain 'steps in sequence' when transformation happening , when scan conversion. know may sound stupid need straight. adult beginner learning graphics @ own hobby. guess scan conversion not happening here in program. done opengl automatically between glbegin , glend calls. am right?
#include <gl/glut.h> void init(void) { glclearcolor (0.5, 0.2, 0.3, 0.0); glclear (gl_color_buffer_bit); glcolor4f(0.5,0.7,0.3,0.0); gllinewidth(3); } void display(void) { glbegin(gl_lines); glvertex2i(50, 400); glvertex2i(700, 100); glend(); glutswapbuffers(); } void reshape(int w, int h) { glviewport(0, 0, (glsizei) w, (glsizei) h); glmatrixmode(gl_projection); glloadidentity(); gluortho2d(0.0, (gldouble)w, 0.0, (gldouble)h); } int main (int argc, char *argv[]) { glutinit(&argc, argv); glutinitdisplaymode (glut_rgba | glut_depth); glutinitwindowposition(100,150); glutinitwindowsize(750,500); // aspect ratio of 3/2 glutcreatewindow (argv[0]); init(); glutdisplayfunc(display); glutreshapefunc(reshape); glutmainloop(); // when frame buffer displayed on screen return (0); }
all stages done within opengl implementation (mostly in hardware). specify states , data, gl - if speaking in terms of old gl 1.0 - assemble data vertices, pass every vertex through transformation stage, rasterize resulting primitives fragments, perform per-fragment tests (that may discard fragments), , update resulting pixels on render target.
there no point in user code may on 'one stage' in pipeline - doesn't have callbacks, , many possible stages working @ same time.
Comments
Post a Comment