/
ComputerWorcester ComputerWorcester

ComputerWorcester - PDF document

liane-varnes
liane-varnes . @liane-varnes
Follow
351 views
Uploaded On 2015-07-29

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "ComputerWorcester" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

ComputerWorcester –Rendering zoolabmachines already on graphics card glInfo:yourto zoolabcards (e.g2010) .dllfilesfreeglut2.8.1, graphicscard InstallGLUT, freeglut2.8.1,.dllfilesStudio…\include\directoryStudio….\lib\directory graphicscard InstallGLUT, .cppfile:shaderfiles:(e.gchange main( ) ) .cppIn Create GLUT, GettingC&#xGL/g;&#xlut.;&#xh000;#include &#xstdl;&#xib.h;#include &#xstdi;&#xo.h0;#include shaderstuffinfinitely GLUT, InialializeGLEW CreateGLUT Registercallback GLUT Inialializations glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); OpenGLvoid main(int argc, char** argv){//glutInit(&argc, argv); // initialize toolkitglutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(640, 480);glutInitWindowPosition(100, 150);glutCreateWindow(“my first attempt”);glewInit( );//…… 480100150my first attempt Sequentialprograms)N)infiniteWorld’sprogram? OpenGL:toeventsuntil Left mouse click Keyboard ‘h’ key OpenGL:mouse Mouse click myMouse EventCallback function GLUTCallbackforeventsto=hittingkeys GLUTCallbackskeletonwindowpressedpressedglutMainLoop( ):infinite void main(intargc, char** argv){ vertices)vertices vertices)3verticesverticesvertices Renderedvertices Program(on CPU) DrawpointsglDrawArraysCreatebuffersforvertices 1.GeneratecornersStoreverticesarray Movearrayverticesfrombuffer 1.3// generate 3 triangle vertices + store in arrayvoid generateGeometry( void ){points[0] = point2( -0.5, -0.5 ); (-0.5, -0.5)(0.5, -0.5)(0.0, 0.5) (x,y)locations(x,y,z)vectorE.gvec3 vector1;typedefvec2 point2;Declares (x, y, z) coordinates of a vector OpenGLvoid main(int argc, char** argv){glutInit(&argc, argv); // initialize toolkitglutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(640, 480);glutInitWindowPosition(100, 150);glutCreateWindow(“my first attempt”);glewInit( );//…glutReshapeFunc(myReshape);glewInit( );generateGeometry( );glutMainLoop( );} // generate 3 triangle vertices + store in arrayvoid generateGeometry( void ){points[0] = point2( -0.5, -0.5 );} significantlyGLuintvao;glGenVertexArrays( 1, &vao); glBindVertexArray( vao); VAO GLuintbuffer;glGenBuffers(1, Number of Buffer Objects to return Data is array of values generated earlier to VBOapplication Data to be transferred to GPU memory (generated earlier) PutTogether:4.memoryvoid initGPUBuffers( void ){// Create a vertex array objectGLuint vao;glGenVertexArrays( 1, &vao );glBindVertexArray( vao );// Create and initialize a buffer objectGLuint buffer;glGenBuffers( 1, &buffer );glBindBuffer( GL_ARRAY_BUFFER, buffer );glBufferData( GL_ARRAY_BUFFER, sizeof(points), points, GL_STATIC_DRAW );} VAO OpenGLvoid main(int argc, char** argv){glutInit(&argc, argv); // initialize toolkitglutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); glutInitWindowSize(640, 480);glutInitWindowPosition(100, 150);glutCreateWindow(“my first attempt”);glewInit( );//…glutReshapeFunc(myReshape);glewInit( );generateGeometry( );initGPUBuffers( );glutMainLoop( );} void initGPUBuffers( void ){// Create a vertex array objectglBindVertexArray( vao );// Create and initialize a buffer objectGLuint buffer;glGenBuffers( 1, &buffer );glBindBuffer( GL_ARRAY_BUFFER, buffer );sizeof(points), points, GL_STATIC_DRAW );} 5.void mydisplay(void){glClear(GL_COLOR_BUFFER_BIT); // clear screenglDrawArrays(GL_LINE_LOOP, 0, 3); // draw the pointsglFlush( ); // force rendering to show} Render buffered data as points Starting Number of ReferencesGraphics,6edition,232

Related Contents


Next Show more