Archive for the 'OpenGL' Category

Compile a OpenGL program in Windows (Visual Studio)

febrero 27, 2012

SOURCE: http://www.divms.uiowa.edu/~cwyman/classes/common/howto/winGLUT.html

Compiling OpenGL Progams at Home Using Visual Studio

Windows does not include GLUT standard, like the lab machines in MLH 301 do. Thus, getting your OpenGL programs to compile and run at home is slightly more difficult. However by following the following steps, you should be able to figure out how to make it work:

Download GLUT
Unzip the file.
Put the file «glut32.dll» into the system path.
This can be in the same directory as your executable file.
On Windows XP or earlier, this can be in «C:\WINDOWS\system32»
Or you can create a directory like «C:\DLLs», put the file in this directory and change your system path to include this new directory.
Do this by opening Control Panel -> System, clicking on «Advanced System Settings», followed by «Environment Variables», and editing the «Path» variable.
Put the file «glut.h» into the standard Visual C++ include directoy
(For Visual Studio 2010, this should be: «C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\gl»)
(For Visual Studio 2008, this should be: «C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include\gl»)
(For Visual Studio 2005, this should be: «C:\Program Files\Microsoft Visual Studio.NET\Vc7\PlatformSDK\Include\gl»)
You’ve got the right directory if you see a copy of «gl.h»
Put the file «glut32.lib» into the standard Visual C++ library directory
(For Visual Studio 2010, this should be: «C:\Program Files\Microsoft SDKs\Windows\v7.0A\Lib»)
(For Visual Studio 2008, this should be: «C:\Program Files\Microsoft SDKs\Windows\v6.0A\Lib»)
(For Visual Studio 2005, this should be: «C:\Program Files\Microsoft Visual Studio.NET\Vc7\PlatformSDK\lib»)
There should be lots of .lib files here, including «opengl32.lib» and «glu32.lib».
Make sure your Visual C++ project links in the GLUT/gl/glu libraries (see also this page). This is located in:
Menu: «Project -> (your-project-name) Properties»
Tab: «Configuration Properties -> Linker -> Input»
Under «Additional Dependancies», add «glut32.lib glu32.lib opengl32.lib»
#include in your program.
Note: This needs to come after you #include and .
Note: This needs to come before you #include .
Also note that glut.h includes gl.h for you (so you need not explicitly #include ).
You should not include windows.h or any other Windows-specific header files, no matter what you may read on random forum postings!
If you get compilation errors because of multiple conflicting definitions of «exit()», then «stdio.h» and «glut.h» have been #include’d in the wrong order. You may fix this by:
Reordering your #include files (see step #7). This is the «right» way.
Add «#define GLUT_DISABLE_ATEXIT_HACK» to glut.h on the line immediately after the first «#if defined(_WIN32)».
If you happen to have a 64-bit version of Windows and Visual Studio, make sure you compile a 32-bit executable.
NOTE: Later in the course, you may also need to install GLEW. Follow the same directions: install the DLLs into the system directory, the header files in the include directory, and the library files into the lib directory.

Last Modified: Friday, August 28, 2009

Chris Wyman (cwyman@cs.uiowa.edu)

Text in OpenGL

marzo 21, 2010

There are various ways for including text in a OpenGL.
Some of them are discussed here:
http://www.opengl.org/resources/features/fontsurvey/

HDRI High Dynamic Range Imaging (Alto Rango Dinámico)

marzo 2, 2007

HDR es una tècnica de iluminaciòn que emula el funcionamiento del iris del ojo humano. El primer «paper» es de Paul Devec y se puede encontrar aqui (1998), y un paper de HDRTM (2001, texture Mapping) aqui. Tambien han escrito un libro (2005) aqui. Esta tecnica fue utilizada en Half Life 2 y es notable la mejora de realismo en las escenas. En fotografia se puede aplicar tomando 3 fotos con diferentes intensidades (una normal, una con menor y otra con mayor) y haciendo una combinacion.

Implementaciones: Maya, OpenGL/SDL

First OpenGL progam in Linux

diciembre 24, 2006

same as the last post (only taking care of the «»), and compile using

gcc hello.c -lglut -lGL -lGLU -lX11
-lX11 is not needed

First OpenGL program in Mac

diciembre 22, 2006

#include <GL/glut.h>

void display()
{
glClear(GL_COLOR_BUFFER_BIT);

glBegin(GL_POLYGON);
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f(0.5, 0.5);
glVertex2f(0.5, -0.5);
glEnd();

glFlush();
}

int main (int argc, char** argv) {
glutInit(&argc,argv);
glutCreateWindow(«simple»);
glutDisplayFunc(display);
glutMainLoop();
}

compilar con:

gcc -framework OpenGL -framework GLUT -framework Foundation hello.c

si aparece:

«GL/glut.h: No such file or directory»

desde la carpeta «/usr/local/include/» hay que crear un link simbolico:

%sudo ln -s /System/Library/Frameworks/GLUT.framework/Versions/Current/Headers/glut.h ./

%./a.out