1 / 35

computer graphics

computer graphics. TA: Nouf Al- harbi. NoufNaief.net nouf200@hotmail.com. What’s Computer Graphics..?. Image Description. Computer. Computer Graphics. How we look at an image!. Color: B/W or color (RGB) Frame: length, width Size: length, width, area, height and volume if 3D

Télécharger la présentation

computer graphics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. computer graphics TA: Nouf Al-harbi NoufNaief.net nouf200@hotmail.com

  2. What’s Computer Graphics..? Image Description Computer Computer Graphics

  3. How we look at an image! • Color: B/W or color (RGB) • Frame: length, width • Size: length, width, area, height and volume if 3D • Type: Static or animated • Content: The scene: Objects, characters • Background/ Foreground • lighting, shading • Textures • Viewing angle: camera location

  4. How The computer see an image! • The computer generally sees an image as a set of square points or PIXELS (Picture Elements) • Each Pixel having a defined RGB color • These pixels and their colors are processed to extract information about the image content

  5. Introductiom to OpenGL Computer Graphics LAB Objective To give you a good practical experience in programming graphics using C++ and OpenGL

  6. Introductiom to OpenGL LAB Marks

  7. Introductiom to OpenGL Lab Materials .. NoufNaief.net

  8. Computer graphicslab 1 Introduction to OpenGL

  9. Introductiom to OpenGL objectives • By the end of this lab you will be able to know : • What’s OpenGl ..? • What does it do ? And what doesn’t it do..? • What’s GLUT and why do we use it ..? • Write the 1st OpenGL program

  10. Introductiom to OpenGL What is OpenGL? • OpenGL stands of Open Graphical Library • It is a software interface to graphics hardware. • It consists of about 120 distinct commands • to specify the objects and operations needed to produce interactive 3D applications • It is developed by many companies and it is free to use • You can develop OpenGL-applications without Licensing • OpenGL is a system-independent interface • it can work with any programming language and any operating system

  11. Introductiom to OpenGL What I can do with OpenGL ..? • This picture may give you an idea of the kinds of things you can do with the OpenGL graphics system • This picture is the cover of the ‘Red Book’: OpenGl Programming user guide

  12. Introductiom to OpenGL What OpenGL doesn’t do ?

  13. Introductiom to OpenGL The support libraries GLU and GLUT

  14. Introduction to OpenGL GLUT • The OpenGL UtilityToolkit (GLUT) is a Programming interface • It implements a simple windowing application programming interface (API) for OpenGL • The toolkit supports the following functionality : • Create Display windows. • Interactive with input devices and detect user input. • An “idle” routine and timers. • Utility routines to generate various solid and wire frame objects.

  15. Introductiom to OpenGL GLU • GLU: OpenGL Utility Library • provides functions for drawing more complex primitives than those of OpenGL • such as curves and surfaces

  16. Introductiom to OpenGL OpenGL Basics • Function names: • Begins with gl . • Each component word starts with capital letter. • Examples: • glClear( ) • glClearColor( )

  17. Introductiom to OpenGL OpenGL Basics • Basic Constants: • Starts with GL • Component words are written in Capital letters and separated by underscore ( _ ). • Examples: • GL_COLOR_BUFFER_BIT • GL_POINTS • GL_LINES

  18. Introductiom to OpenGL OpenGL Basics • All the functions in GLUT starts with glut • All the functions in GLU starts with glu

  19. Introductiom to OpenGL your first OpenGL Program • Preparing the graphics work environment • We will use VC++ • You need to include these files to your computer

  20. your first OpenGL ProgramGenerate a square on a solid background • Open VC++ • New  source file • Write the following code • Compile and build it

  21. Introductiom to OpenGL your first OpenGL Program • You have to link used libraries to your project • Select Project/Settings from the main menu. • A dialog box appears, select the Link tab. • Add the following files to the Object/library modules: opengl32.lib glut32.lib glu32.lib

  22. Introductiom to OpenGL your first OpenGL Program • To write OpenGL program, we must include these files • glut. h • glu. h • gl. h • #include <GL/glut.h> should automatically include the others

  23. Introductiom to OpenGL your first OpenGL Program • There are 2 functions in our program • Display function • Main function • Each of them calls a number of OpenGL/glut functions 1 2

  24. Introductiom to OpenGL Main Function Commands • Initializes GLUT • should be called before any OpenGL command • takes the arguments from main()

  25. Introductiom to OpenGL Main Function Commands • Creates a window on the screen with the title • Parameters: • Title of the window would be created • Returns an integer that can be used to refer to the window in multi-window situations.

  26. Introductiom to OpenGL Main Function Commands In order to respond to the input event, the application must provide a function – known as a callback function – to handle the event; OpenGL automatically calls the application’s function, passing it the event data. • The function display() is called each time there is a display callback • Parameters: • A function that contains what we want to draw in the screen

  27. Introductiom to OpenGL Main Function Commands • Causes the program to enter an event-processing loop • Once called, this routine will never return. • It will call as necessary any callbacks that have been registered. • This statement should be the last one in the main() function

  28. Introductiom to OpenGL Display Function Commands • called by GLUT when the window is redrawn. • we should specify what we want to output to screen.

  29. Introductiom to OpenGL Display Function Commands OpenGL doesn’t draw its graphics directly to the window. It actually draws into a data structure (an array of pixels) inside OpenGL called the frame-buffer. Periodically, OpenGL copies the pixels in the frame buffer into the window. • clears one or more of OpenGL’s buffers. • When glClear() is called, each pixel in the buffer is set to the current clear color, which is set to black by default. • Parameters: • GL_COLOR _BUFFER_BIT: • frame buffer, which holds the pixels which will be copied to the window

  30. Introductiom to OpenGL Display Function Commands • Specifies the beginning of an object of type mode • Modes include: • GL_POINTS • GL_LINES • GL_POLYGON , …etc.

  31. Introductiom to OpenGL Display Function Commands glVertex{234}{sifd}(X_coordinate, Y_coordinate,...) • {234} Specifies the location of a vertex in two, three, or four dimensions with the types short (s), int (i), float (f), or double (d)

  32. Introductiom to OpenGL (0,1) x (1,0) (-1,0) (0,0) (0, -1)

  33. Introductiom to OpenGL Display Function Commands • Specifies the end of a list of vertices.

  34. Introductiom to OpenGL Display Function Commands • instructs OpenGL to make sure the screen is up to date. • it causes the contents of any internal OpenGL buffers are “flushed” to the screen

  35. Introductiom to OpenGL REFERENCES: • Materials of this lab are prepared using: • An Introduction to Graphics Programming with OpenGL by : Toby Howard, School of Computer Science, University of Manchester • Lighthouse3d: http://www.lighthouse3d.com/opengl/glut/index.php?1 • OpenGL Programming Guide 'The Red Book’ • Computer Graphics Lab -1st semester – 2010-2011 by : Ins. Ruwaida Al-harbi & Ins. Nouf Al-harbi • Computer Graphics Lectures – 1st semester 2009-2010 by Dr.AhmedGhali

More Related