2.3At the lowest level of processing, we manipulate bits in the framebuffer. In
ID: 3784099 • Letter: 2
Question
2.3At the lowest level of processing, we manipulate bits in the framebuffer. In WebGL, we can create a virtual framebuffer in our application as a two- dimensional array. You can experiment with simple raster algorithms, such as drawing lines or circles, through a function that generates a single value in the array. Write a small library that will allow you to work in a virtual frame- buffer that you create in memory. The core functions should be WritePixel and ReadPixel. Your library should allow you to set up and display your vir- tual framebuffer and to run a user program that reads and writes pixels using gl.POINTS in gl.drawArrays. 2.4 Turtle graphics is an alternative positioning system that is based on the concept of a turtle moving around the screen with a pen attached to the bottom of its shell. The turtle’s position can be described by a triplet (x, y, ), giving the location of the center and the orientation of the turtle. A typical API for such a system includes functions such as the following: init(x,y,theta); // initialize position and orientation of turtle forward(distance); right(angle); left(angle); pen(up_down); Implement a turtle graphics library using WebGL. All this using Html file
Explanation / Answer
Two & three dimensions scenes Drawing in two dimensions plane is a special case of 3Ddrawing • Viewer at the origin • View direction: positive z axis • Orthogonal (parallel)projection • Specifying the objects in XY (z=0) plane OpenGL drawing includes • Points • Line segments • Polygons Each primitive is completely specified by points in the 3D (called vertices) How we can specify a vertex? Warning: this is a draft copy. It has not been passed any revision Vertex specification • glVertex***(); • The first * could be 2 (z=0), 3(3D) or 4 (Homogeneous) to denote the number of coordinates • The second star could be i for integer, f for float, or d for double • The third star could be v for passing coordinates in an array or null for giving the coordinates directly • Instead of using c standard types use GL types • Use Glint instead of int • Use Glfloat instead of float • Use Gldouble instead of double, an so on Warning: this is a draft copy. It has glV«rt«x3f (x,y,0) ; glV«rtex2£(x t y); glVertex2i (GLint xi. GLlnt yi) glVertex3f(GLfloat x, CLfloat y, GLfloat z) GLflo&t vortex [3] gl Vert ex3f v (vertex) glBegin(CL.LIMES); glVertex3f(xl,yl,zl); glVertex3f (x2,y2,z2) ; glEndO, glBegin(GL_POIMTS); glVertex3f (xl.yl.zl); glVertex3f (x2 # y2,z2); glEndO ; been passed any revision OpenGL function classification • Primitive functions • Attribute functions • Viewing functions • Transformation functions • Input functions • Control functions • Query functions Warning: this is a draft copy. It has not been passed any revision OpenGL libraries • OpenGL core library - OpenGL32 on Windows - GL on most unix/linux systems (libGL.a) • OpenGL Utility Library (GLU) - Provides functionality in OpenGL core but avoids having to rewrite code (use OpenGL to provide complex tasks) • Links with window system - GLX for X window systems - WGL for Windows - AGLfor Macintosh Warning: this is a draft copy. It has not been passed any revision GLUT
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.