introduction to computer graphicscs5600/media/lecture 20 - procedural geometry ii.pdf · opengl...

8
Introduction to Computer Graphics Procedural Geometry II

Upload: others

Post on 23-Mar-2020

14 views

Category:

Documents


0 download

TRANSCRIPT

Introduction to Computer GraphicsProcedural Geometry II

OpenGL Project Setup

Create a command-line style project in Xcode 4

Select the project file and click Build Phases tab

Add OpenGL.framework and GLUT.framework to Link list

OpenGL Project Setup

Create a command-line style project in target IDE (or not...)

Install libglut3-dev and libglew-dev using a package manager

When compiling reference OpenGL, GLUT, GLEW librarieseg. gcc main.c -o a.out -I/usr/include -L/usr/lib -lglut -lGLEW -lGL

OpenGL Project SetupCreate a command-line style project in Visual Studio 2010

Download and install GLUT - http://user.xmission.com/~nate/glut.html

glut.h: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\GL\

glut32.lib: C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\

glut32.dll: C:\Windows\System32\ (or C:\Windows\SysWOW64\ for 64-bit)

Download and install GLEW - http://glew.sourceforge.net/

glew.h, glxew.h, wglew.h: C:\Program Files\Microsoft Visual Studio 10.0\VC\include\GL\

glew32.lib: C:\Program Files\Microsoft Visual Studio 10.0\VC\lib\

glew32.dll, glew32s.dll: C:\Windows\System32\ (or C:\Windows\SysWOW64\)

Add OpenGL, GLUT, and GLEW library files to project link stage (opengl32.lib, glut32.lib, glew32.lib)

Short Example Program#include <GL/glew.h> // Not needed on Mac#include <GL/glut.h> // <GLUT/glut.h> on Mac

void draw();

int main(int argc, char** argv){! glutInit(&argc, argv);! glutInitWindowSize(800, 600);! glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH);! glutCreateWindow("OpenGL");

! GLenum err = glewInit(); // Not needed on Mac! if (err != GLEW_OK)! ! ; // Output error message

! glutDisplayFunc(draw);! glutMainLoop();

! return 0;}

void draw(){! glClearColor(0.8f, 0.0f, 0.8f, 1.0f);! glClear(GL_COLOR_BUFFER_BIT);! glutSwapBuffers();}

Data read from Scene and OBJ files

OpenGL ES Primitive

ProcessingVertex Shader

OpenGL ES Rasterizer

Fragment Shader

OpenGL ES Fragment

Processing

Fragments resulting from rasterization Frame Buffer

Notes on NoiseProcedural geometry needs “smooth” randomness

Randomness should be repeatable based on inputs

1D, 2D, 3D, etc. versions of this are often called “noise”

Ken Perlin created a good basis for noise functionshttp://mrl.nyu.edu/~perlin/doc/oscar.html

http://mrl.nyu.edu/~perlin/noise/

http://www.dreamincode.net/forums/topic/66480-perlin-noise/

http://devmag.org.za/2009/04/25/perlin-noise/