Bob s Concise Introduction to Doxygen

Similar documents
Lecture 3. Understanding of OPenGL programming

Duc Nguyen CSE 420 Computer Graphics 10/10/2018 Homework 1

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

C++ is Fun Part 13 at Turbine/Warner Bros.! Russell Hanson

Announcements OpenGL. Computer Graphics. Spring CS4815

Drawing Primitives. OpenGL basics

Introduction to OpenGL: Part 2

Programming with OpenGL Part 2: Complete Programs Computer Graphics I, Fall

COMPUTER GRAPHICS LAB # 3

Programming with OpenGL Part 3: Three Dimensions

Teacher Assistant : Tamir Grossinger Reception hours: by - Building 37 / office -102 Assignments: 4 programing using

Lectures OpenGL Introduction

Graphics Programming

To Do. Computer Graphics (Fall 2008) Course Outline. Course Outline. Methodology for Lecture. Demo: Surreal (HW 3)

6. Make use of glviewport() to display two sine curves on the same screen, one on the

CS 543 Lecture 1 (Part II): Intro to OpenGL and GLUT (Part I) Emmanuel Agu

Programming using OpenGL: A first Introduction

Basic Graphics Programming

CS559: Computer Graphics. Lecture 12: OpenGL Li Zhang Spring 2008

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Graphics Programming. August 31, Programming of the Sierpinski gasket. Programming with OpenGL and C/C++

Using OpenGL with CUDA

Introduction to MS Visual C/C++

by modifying the glutinitwindowsize() function you can change the screen size to whatever you please.

Assignment 1. Simple Graphics program using OpenGL

Introduction to Computer Graphics with OpenGL/GLUT

C++ - OpenGL - Setting up Visual Studio

Computer Graphics. OpenGL

CS 4731 Lecture 3: Introduction to OpenGL and GLUT: Part II. Emmanuel Agu

Lecture 2 CISC440/640 Spring Department of Computer and Information Science

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

CSE4030 Introduction to Computer Graphics

OpenGL JOGL. OpenGL & JOGL. Shaoting Zhang, or Tony. September 12, 2007

Books, OpenGL, GLUT, GLUI, CUDA, OpenCL, OpenCV, PointClouds, and G3D

CS 543 Lecture 1 (Part 3) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Graphics Hardware and OpenGL

3D computer graphics: geometric modeling of objects in the computer and rendering them

Books, OpenGL, GLUT, CUDA, OpenCL, OpenCV, PointClouds, G3D, and Qt


CS 432 Interactive Computer Graphics

Computer Graphics (CS 543) Lecture 1 (Part 2): Introduction to OpenGL/GLUT (Part 1)

UNIT 7 LIGHTING AND SHADING. 1. Explain phong lighting model. Indicate the advantages and disadvantages. (Jun2012) 10M

PART-I: Lab for MCS-051 (Advanced Internet Technologies)

CS Computer Graphics: Intro to OpenGL

CS Computer Graphics: Intro to OpenGL

Basic Graphics Programming

11/1/13. Basic Graphics Programming. Teaching Assistant. What is OpenGL. Course Producer. Where is OpenGL used. Graphics library (API)

Programming with OpenGL Part 1: Background

CS 4204 Computer Graphics

CS380: Computer Graphics Basic OpenGL Structure. Sung-Eui Yoon ( 윤성의 ) Course URL:

Graphics Programming. 1. The Sierpinski Gasket. Chapter 2. Introduction:

CMSC 425: Lecture 4 More about OpenGL and GLUT Tuesday, Feb 5, 2013

Overview of Graphics Systems Hearn & Baker Chapter 2. Some slides are taken from Robert Thomsons notes.

Computer Graphics (CS 4731) OpenGL/GLUT(Part 1)

Precept 2 Aleksey Boyko February 18, 2011

Computer Graphics (4731) Lecture 4: 2D Graphics Systems (Drawing Polylines, tiling, & Aspect Ratio)

Computer Graphics Course 2005

C OMPUTER G RAPHICS Thursday

Introduction to OpenGL

CS559: Computer Graphics. Lecture 12: OpenGL Transformation Li Zhang Spring 2008

RECITATION - 1. Ceng477 Fall

Computer Graphics (Basic OpenGL)

1.2 Basic Graphics Programming

Computer Graphics. Bing-Yu Chen National Taiwan University

OpenGL Introduction Computer Graphics and Visualization

to OpenGL Introduction Pipeline Graphics pipeline OpenGL pipeline OpenGL syntax Modeling Arrays Conclusion 1 Introduction Introduction to OpenGL

Announcement. Homework 1 has been posted in dropbox and course website. Due: 1:15 pm, Monday, September 12

Fourier Series. Given a periodic function, x(t), (-T <t <T): + b n sin n t T. a n cos n t T. 2 a 0 + Z T. a n = 1 T. x(t) cos n t T. b n = 1 T.

Abel J. P. Gomes LAB. 1. INTRODUCTION TO OpenGL

Cameras (and eye) Ideal Pinhole. Real Pinhole. Real + lens. Depth of field

// double buffering and RGB glutinitdisplaymode(glut_double GLUT_RGBA); // your own initializations

Computer Graphics: Line Drawing Algorithms

OpenGL/GLUT Intro. Week 1, Fri Jan 12

OpenGL. White Square Code 11/4/09. OpenGL. OpenGL. OpenGL

Computer Graphics, Chapt 08

Introduction to OpenGL Week 1

Objectives. Image Formation Revisited. Physical Approaches. The Programmer s Interface. Practical Approach. Introduction to OpenGL Week 1

2 Transformations and Homogeneous Coordinates

CS418 OpenGL & GLUT Programming Tutorial (I) Presented by : Wei-Wen Feng 1/30/2008

Display Lists in OpenGL

COS340A Assignment 1 I Pillemer Student# March 25 th 2007 p1/15

Chapter 13 Selection and Feedback

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

1/12/11. Basic Graphics Programming. What is OpenGL. OpenGL is cross-platform. How does OpenGL work. How does OpenGL work (continued) The result

An Overview GLUT GLSL GLEW

Exercise 1 Introduction to OpenGL

Andrew Yenalavitch Homework 1 CSE Fall 2014

FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM INTERACTIVE COMPUTER GRAPHICS LAB SESSION 4. C++ - OpenGL

Computer graphics MN1

Comp 410/510 Computer Graphics Spring Programming with OpenGL Part 2: First Program

COMP 371/4 Computer Graphics Week 1

Computer graphics MN1

Interaction. CSCI 480 Computer Graphics Lecture 3

(21) OpenGL GUI. OpenGL GUI 1 UNIX MAGAZINE UNIX. SGI (Silicon Graphics Inc.) Windows PC GUI. UNIX Windows GUI. Java. 1 prefposition() X X

Drawing and Coordinate Systems

Early History of APIs. PHIGS and X. SGI and GL. Programming with OpenGL Part 1: Background. Objectives

Introduction to OpenGL

Drawing and Coordinate Systems

Transcription:

Bob s Concise Introduction to Doxygen by Robert S Laramee Visual and Interactive Computing Group Department of Computer Science Swansea University Swansea, Wales, UK 1 Comment Standard February 14, 2011 The general rules for commenting your source code are as follows: 1. File, class, and method comments go into the header (.h) files (as opposed to the implementation.cpp files). 2. Header files begin with a comment containing (a) \file the name of the file, e.g., RSL Triangle.h (b) \author the author of the file, e.g., Robert S. Laramee (c) \date the date this file was created, e.g., 29 Oct 2009, and optionally (d) \see for names of related files. (e) \brief for brief descriptions of classes. Add an empty line followed by a more detailed description of your class. 3. All multi-line comments start with the starting sequence on a line by itself and end with the terminating sequence on line by itself. Exception: single line comments. 4. All classes are accompanied by a meaningful description.of one or more sentences. The general responsibilities are given. 5. All methods have @param, and @return tags. Exception: there are no method parameters or nothing is returned. 6. Public methods appear first, then private methods, and finally private data members with explicit public: and private: identifiers at the beginning of each group. 7. Within each public and private group of methods, methods appear in alphabetical order. Exception: accessor methods (Get() and Set()) are at the top. 2 Diagrams Doxygen has the amazing ability to automatically generate class hierarchy and collaboration diagrams (also called a dependency graph) from your software. Doxygen uses a tool called dot from GraphViz to generate Started on Friday 14 Sep 2001. Prepared with L A TEX r.s.laramee at swansea.ac.uk 1

advanced diagrams and graphs. GraphViz is an open-source, cross-platform graph drawing program and can be found at: http://www.graphviz.org/. After downloading and installing the dot tool set HAVE DOT to YES in your doxygen configuration file to use it. For more details visit http://www.doxygen.org/ and click on Manual and then click on Graphs and diagrams. 3 Outputting the Source Code Doxygen provides the user with the option of outputting the source code along with the HTML output. This option is extremely useful for code reviews. Set the SOURCE BROWSER and INLINE SOURCES tags both to YES in your doxygen configuration. For more details visit http://www.doxygen.org/ and click on Manual and then click on Getting started. 4 Doxygen Examples These comment conventions are based on doxygen. Preparing source to be processed by doxygen is easy. Comment blocks delimited by and must be added before each item for which you wish to generate documentation. Summarizing, source code is documented with the following: 1. each class definition explaining the purpose of the class 2. each member function explaining what the function does 3. each member variable explaining what the variable means 4. each type definition (enums) explaining what the type represents Within a comment block you can use tags to explain function parameters, return values, and more. The three most important doxygen tags are: \param explains function parameter \return describes return value \see a reference to a function name, variable name, document, or URL. 4.1 Here is an example of how a method is commented in doxygen: Calculate the center point of a triangle. This method has been ported from the Visualization Toolkit. \see www.kitware.com, vtktriangle.h \param coord0 the 1st x,y,z coordinate of a triangle \param coord1 the 2nd x,y,z coordinate of a triangle \param coord2 the 3rd x,y,z coordinate of a triangle \return the triangle center as an x,y,z coordinate Coord3D< Float > GetTriangleCenter( const Coord3D< Float >& coord0, const Coord3D< Float >& coord1, const Coord3D< Float >& coord2); 2

4.2 Here is an example of how a class is documented in doxygen: SU Triangle is intended to provide methods to perform common operations on a triangle in 3D space. It is intended to be highly legible, highly generalized, and highly reusable. Some methods have been ported from The Visualization Toolkit. \see http://www.kitware.com class SU Triangle {... }; It is also possible to use HTML tags in the comment blocks to create elaborate lists, bold and italic text etc. 1 When documenting your code please keep in mind that other developers will have to understand what your classes and methods do by reading the documentation generated from your comments. They do not have any knowledge of your implementation, thus your comments must explain everything that helps in understanding your code. The examples show how to comment a class so that useful documentation can be generated. 1 For detailed information please see http://www.doxygen.org/. 3

4.3 A Complete Header File Example: \file hello.h \author Sitsofe Wheeler \date 29 Oct 2009 \see The OpenGL Programming Guide Fifth Edition Page 18 \brief Header file for simple "hello world" OpenGL rectangle example. A detailed description of the Hello class goes here. This is a Class to create an OpenGL triangle. It expects glutinit to have been called. class Main { public: Creates the GL window (with hello as the title) and starts the event loops. \see glutinit() \param argc -the number of parameters passed to the program. \param argv -an array of cstrings containing parameters passed to the program. First parameter is the name the program was called with. static void main(int argc, char argv); private: Initialise the OpenGL state machine. static void init(void); }; Renders the rectangle. static void display(void); 4

4.4 A Complete Class File Example: @file hello.cpp @author Sitsofe Wheeler @date 29 Oct 2009 @see hello.h for class documenation. Simple "hello world" OpenGL rectangle example. #include <GL/gl.h> #include <GL/freeglut.h> #include "hello.h" void Main::init(void) { select clearing (background) colour glclearcolor(0.0, 0.0, 0.0, 0.0); } initialize viewing values glmatrixmode(gl_projection); glloadidentity(); glortho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); void Main::display(void) { clear all pixels glclear(gl_color_buffer_bit); Draw white polygon (rectangle) with corners at (0.25, 0.25, 0.0) and (0.75, 0.75, 0.0) glcolor3f(1.0, 1.0, 1.0); glbegin(gl_polygon); glvertex3f(0.25, 0.25, 0.0); glvertex3f(0.75, 0.25, 0.0); glvertex3f(0.75, 0.75, 0.0); glvertex3f(0.25, 0.75, 0.0); glend(); } Don t wait! Start processing buffered OpenGL routines glflush(); void Main::main(int argc, char argv) { Declare initial window size, position, and display mode (single buffer and RGBA). Open window with "hello" in its title bar. Call initialization routines. Register callback function to display graphics. Enter main loop and process events. glutinit(&argc, argv); glutinitdisplaymode(glut_single GLUT_RGB); glutinitwindowsize(250, 250); glutinitwindowposition(100, 100); 5

} glutcreatewindow("hello"); init(); glutdisplayfunc(display); glutmainloop(); Program entry point. Initialise glut and call Main class. @param argc -the number of parameters passed to the program. @param argv -an array of cstrings containing parameters passed to the program. First parameter is the name the program was called with. @return -0 on success. int main(int argc, char argv) { } Main::main(argc, argv); return 0; 5 Acknowledgements Understanding undocumented code is difficult, time-consuming, and can even be impossible. Thanks to Sitsofe Wheeler for valuable discussions on this topic. Feedback on this document is not only welcome but encouraged. Please send correspondence to the first author. These code comment conventions are to be used in conjunction with the coding conventions [1]. References [1] R.S. Laramee. Bob s Concise Coding Conventions (C 3 ). Advances in Computer Science and Engineering (ACSE), 4(1):23 26, 2010. (available online). 6