OpenGL Help Session - Computer graphics

OpenGL Help Session - Computer graphics

OpenGL Help Session CS248 Fall 2008 Derek Chan OpenGL needs a windowing system OpenGL by itself does not talk to the windowing system/manager by itself. Need a toolkit to tell the windowing system that

we need an OpenGL window. Examples: GLUT/ GLUI (used in Project 2) SDL (more features: sound, image file loaders) wxWidgets, Qt (full fledged widget toolkits, probably overkill for a game) OpenGL needs a windowing system What does the windowing toolkit handle?

Opening a window in the OS Window resizing Mouse/ keyboard presses Mouse position/movement What does OpenGL do? - draw Drawing glBegin(): GL_POINTS GL_LINES

GL_TRIANGLES Etc. Drawing glBegin(GL_LINES); glColor3f(r,g,b); glNormal3f(x,y,z); glTexCoord2d(u,v); glVertex3f(x,y,z);

glEnd(); OpenGL function suffixes OpenGL functions that take different types of arguments while providing the same functionality will often have a suffix to denote which type of function they are:

glVertex2i - input is 2 integers glVertex3fv - input is 3 floats in an array glVertex3f - input is 3 floats OpenGL Camera glFrustrum gluPerspective

glOrtho gluOrtho2d glViewport gluLookAt OpenGL glEnable( ) glDisable( ) GL_DEPTH_TEST GL_BLEND

GL_LIGHTING GL_LIGHT1 OpenGL Find simple tutorials online OpenGL does many things which you might not know about Display Lists (glGenLists, glCallList)

OpenGL extensions Extensions to the OpenGL base system often have their own suffixes. For example: glCreateProgramObjectARB (to create a shader program using an ARB extension)

Use GLEW (OpenGL Extension Wrangler) for easy access to extensions. Basic OpenGL Game Flowchart 1.Load up an OpenGL window using a toolkit to talk to the windowing system Set up projection matrices, shading properties, etc. Load textures, etc.

Event loop: Check for any events or user input and process them Redraw the OpenGL scene as necessary Wait a small amount of time. General Programming Advice 1. have a math library 1. use object oriented programming 1. use c++ stl classes (or equivalent)

Example Pitfalls Depth Testing vs blending (transperancies) Texture dimensions power of 2 (fixed in more recent implementations of OpenGL) Projection matrix should only be used for camera position, etc. It has a shorter stack than the Model-View matrix.

Recently Viewed Presentations

  • The Centralized Evaluation Team Process

    The Centralized Evaluation Team Process

    VB-MAPP: Verbal Behavior - Milestones Assessment and Placement Program. Questions to Guide the Use of Standardized Tools. Does the tool have adequate technical adequacy? What is the purpose or intended outcomes?
  • Poster Project - kyrene.org

    Poster Project - kyrene.org

    The word Dystopia should be a title somewhere on the poster. H.W. and classwork/ Things to find: Images/pictures that depict a dystopia. Words/synonyms/ phrases that tie into dystopian concepts. Art. GRADE. 25-30: Has at least 8 images and at least...
  • Management and Methods of Mobile Ip Security

    Management and Methods of Mobile Ip Security

    Security Models. In some environments proper security is not maintained between the users while leads to the many attacks. In-order to increase these aspects we have to follow some strong level of security by applying some authentication methods and encryption...
  • Two Primary Purposes for ANCOVA  Adjust the means

    Two Primary Purposes for ANCOVA Adjust the means

    Xuhua Xia. Analysis of Covariance (ANCOVA) ANCOVA combines analysis of variance with regression. When it is used. Its rationale. The relationship between Y and the covariate needs to have the same slope in different groups.
  • Data Capture, Quality Management, and Storage Tools for

    Data Capture, Quality Management, and Storage Tools for

    Note: There are several other tracking entities with unique IDs that are not shown here but they are extremely important for data quality management (e.g., Team Name, Trip ID) and for effective data mining from a central database (e.g., Station...
  • The Role of the Executive Headteacher HfL Governors

    The Role of the Executive Headteacher HfL Governors

    HfL Governors Conference 2017. Ali Pepper. HfL School Effectiveness Adviser. Dr. Tony Breslin. ... How do Executive Heads fit into a leadership structure? School to school consistency and collaboration. Outward. facing. Strategic . thinking. Coaching and staff development. Improvement.
  • Evolution - Science in the Making

    Evolution - Science in the Making

    Evolution: change in the ... Before fertilization (Pre-zygotic isolation) - Prevents genotypes from entering the gene pool. ... meiosis (Mendel's Law of Independent Assortment) or due to a . natural disaster. This can cause one allele to become . more...
  • Mobile Flash Butt Welding Of Rails Kuldeep Singh

    Mobile Flash Butt Welding Of Rails Kuldeep Singh

    Mobile Flash Butt Welding. Mobile Flash Butt Welding is a Rail cum Road Machine. Mobile Flash Butt Welding Plant is a four wheeled mobile vehicle, which can travel on roads with rubberised wheels and on rails with metal wheels in...