OpenGL en CodeBlock
OpenGL en CodeBlock
OpenGL en CodeBlock
9Share
On my old blog, CodieCode, I wrote a tutorial on how to set up an OpenGL, C++ and
GLUT environment using the CodeBlocks IDE and MinGW compiler on a Windows XP
and Vista machine. En mi antiguo blog, CodieCode, escribí un tutorial sobre cómo
configurar una OpenGL, C + + y el medio ambiente GLUT con el IDE y el compilador
MinGW Codeblocks en una máquina Windows XP y Vista. This was a popular post which
seemed to help quite a few people. Este era un puesto popular que parecía ayudar a bastante
gente. However time moves on, software updates and operating systems change. Sin
embargo el tiempo pasa, actualizaciones de software y el cambio de los sistemas
operativos. I've decided to update this tutorial with Windows 7 (though this should still
work fine on XP and Vista) and the latest version of CodeBlocks and MinGW. He decidido
actualizar este tutorial con Windows 7 (aunque esto aún debe trabajar muy bien en XP y
Vista) y la última versión de codeblocks y MinGW. Hope it helps Espero que ayude
——— ---
If you're interesting in coding in OpenGL and C++ a great way to start is by using
GLUT. GLUT takes care of a lot of the difficulties in setting up an OpenGL project and
lets you get started on your project quick and easily. Si usted es interesante en la
codificación en OpenGL y C + + una gran manera de comenzar es mediante el uso de
GLUT. GLUT se encarga de muchas de las dificultades para implantar un proyecto de
OpenGL y le permite empezar a trabajar en su proyecto rápida y fácilmente. In this tutorial
I will guide you through installing and setting up the software you'll need (CodeBlocks,
MinGW and GLUT). En este tutorial te guiará a través de la instalación y la configuración
del software que usted necesitará (Codeblocks, MinGW y GLUT).
Before you can start you're going to need a few things: Antes de empezar vas a necesitar un
par de cosas:
Windows – I've updated the steps below to run on Windows 7, Windows XP and Vista, If
you manage to get this working on other operating systems, let me know Windows - He
actualizado los siguientes pasos para ejecutar en Windows 7, Windows XP y Vista, Si
logras que esto funcione en otros sistemas operativos, que me haga saber
OpenGL – I'm not going to go into how to install OpenGL in this tutorial as most people
will be using Windows XP or later and OpenGL comes ready in these operating systems.
OpenGL - No voy a entrar en cómo instalar OpenGL en este tutorial como la mayoría de la
gente va a usar Windows XP o posterior y OpenGL viene listo en estos sistemas operativos.
GLUT – To download the GLUT files you'll need click here and download 'glut.zip'. GLUT
- Para descargar el GLUT archivos que usted necesitará hacer clic aquí y descargar
"glut.zip.
IDE (Integrated Development Environment) – While it's possible to use an editor (such as
Notepad++) and makefiles. IDE (Integrated Development Environment) - Si bien es posible
utilizar un editor (como Bloc de notas + +) y los makefiles. I find the easiest and most
efficient way to code is using a good IDE (be careful there's some not-so-good IDE's out
there). Me parece la manera más fácil y más eficiente para el código utiliza un buen IDE
(tenga cuidado de que hay algunas no tan buenas IDE está allí). The best that I've come
across is CodeBlocks (I'm not a fan of using Visual Studio for OpenGL but you can use that
too if you wish) and it's this IDE that we'll be setting up today. Lo mejor que he encontrado
es codeblocks (yo no soy un fan de la utilización de Visual Studio para OpenGL, pero usted
puede utilizar que también si lo desea) y es esta IDE que nos va a configurar en la
actualidad.
C++ Compiler – The compiler I'll be using is MinGW, there are many advantages to using
this but I wont go into these here. Compilador C + + - El compilador usaré es MinGW, hay
muchas ventajas de usar este pero no me van en estas aquí.
So without further ado, lets start: Así que sin más preámbulos, comencemos:
Step 1 Paso 1
Download CodeBlocks and MinGW from the CodeBlocks website . Descargar Codeblocks
y MinGW desde el sitio web Codeblocks . Be sure to select the binary installer (.exe file)
which comes with the MinGW compiler. Asegúrese de seleccionar el instalador binario (.
Exe) que viene con el compilador MinGW. As of writing this tutorial the file you need is:
'codeblocks-10.05mingw-setup.exe' (found by clicking on 'Downloads' > 'Download the
binary release'). Al escribir este tutorial el archivo que necesitas es: "codeblocks-
10.05mingw-setup.exe" (pulsando en '>' Descargas 'Descargar el comunicado de binario').
Step 2 Paso 2
Download the GLUT file's you'll need by clicking here and downloading 'glut.zip'
Descargue el archivo de GLUT que usted necesitará por clic aquí y descarga de 'glut.zip'
Step 3 Paso 3
Install CodeBlocks and MinGW by running the '.exe' file you downloaded in Step 1. Instale
Codeblocks y MinGW ejecutando el '. Exe' archivo que ha descargado en el paso 1. The
default install options are sufficient. La instalación por defecto las opciones son suficientes.
Step 4 Paso 4
Extract the 'Glut.zip' file you downloaded in Step 2 and do the following:- Extraiga el
archivo Glut.zip "ha descargado en el paso 2 y haga lo siguiente: -
Copy glut.dll into your 'C:\Windows\System32′ folder (If you're using Windows 7 64-bit,
you'll need to copy this file into 'C:\Windows\sysWOW64′). glut.dll copias en su "carpeta
C: \ Windows \ System32" (Si estás utilizando Windows 7 64 bits, tendrá que copiar este
archivo en "C: \ Windows \ SysWOW64»).
Copy glut.h into the 'include\GL' folder in the MinGW compiler folder. Copia glut.h en el
'incluyen carpeta \ GL "en la carpeta del compilador MinGW. If you installed CodeBlocks
and MinGW to the default directory in Step 3, this folder will be 'C:\Program
Files\CodeBlocks\MinGW\include\GL'. Si ha instalado Codeblocks y MinGW en el
directorio predeterminado en el paso 3, esta carpeta será "C: \ Archivos de programa \
Codeblocks \ MinGW \ include \ GL.
Copy libglut32.a into the 'MinGW\lib' folder. libglut32.a Copiar en el 'MinGW \ lib'
carpeta. If you installed CodeBlocks and MinGW to the default directory in Step 3, this
folder will be 'C:\Program Files\CodeBlocks\MinGW\lib'. Si ha instalado Codeblocks y
MinGW en el directorio predeterminado en el paso 3, esta carpeta será "C: \ Archivos de
programa \ Codeblocks \ MinGW \ lib '.
Step 5 Paso 5
Now you have all the required software installed you can create a new OpenGL and GLUT
project. Ahora tienes todo el software necesario instalado, puede crear un nuevo proyecto
de OpenGL y GLUT. CodeBlocks has an option for creating a GLUT project when creating
a new project, we won't be using this option today though as I want to show you how to
link your files: Codeblocks tiene una opción para crear un proyecto GLUT al crear un
nuevo proyecto, no va a utilizar esta opción hoy en día aunque, como me quiero mostrar la
forma de vincular sus archivos:
Startup CodeBlocks and select 'File > New > Project…', in the new project window select
'Empty project' and click the 'Go' button. Inicio Codeblocks y seleccione 'Archivo> Nuevo>
Proyecto ... ", en la nueva ventana de proyecto seleccione" Vaciar proyecto y haga clic en el
botón' Ir '.
In the wizard that follows press 'Next' to the first page (the one welcoming you to the
wizard) and in the second page enter a project title name into the textbox labelled 'Project
title:' and leave the other 3 textboxes with their default properties (you can change these if
you like, it's upto you) and click 'Next'. En el asistente de prensa que sigue en "Siguiente" a
la primera página (el que le da la bienvenida al asistente) y en la segunda página escriba un
nombre de título del proyecto en el cuadro de texto como 'Título del proyecto: "y dejar los
otros 3 cuadros de texto con sus valores predeterminados propiedades (se puede cambiar
estos si se quiere, es hasta que usted) y haga clic en "Siguiente". In this final wizard page,
ensure that 'GNU GCC Compiler' is selected in the drop-down menu box labeled
'Compiler:', leave the other options with their default setting and click 'Finish'. En esta
página del asistente, asegúrese de que 'compilador GNU GCC "es seleccionado en el
cuadro de menú desplegable' Compilador: ', deje las otras opciones con su configuración
por defecto y haga clic en" Finalizar ".
Once your project has been created, right click on the project in the Workspace explorer
frame on the left of the screen and select 'Build options…'. Una vez que su proyecto ha sido
creado, click derecho sobre el proyecto en el marco explorador de área a la izquierda de la
pantalla y selecciona "opciones de configuración ...". In this options window select your
project name in the tree to the left of the window ( do not select either Debug or Release)
and open the 'Linker settings' tab. En esta ventana seleccione las opciones el nombre del
proyecto en el árbol a la izquierda de la ventana (no seleccione Debug o Release) y abrir la
"Configuración de la ficha del vinculador.
In this tab, click the 'Add' button below the 'Link libraries:' text box and in the textbox next
to 'File:' enter 'opengl32′ (without the quotes) and click 'OK'. En esta ficha, haga clic en el
botón "Añadir" debajo de la bibliotecas de vínculos ':' cuadro de texto y en el cuadro de
texto junto a "archivo: 'enter' opengl32 '(sin las comillas) y haga clic en' Aceptar '. (See
Picture 1.1 Below) (Ver Cuadro 1.1 abajo)
Picture 1.1 - add 'opengl32' to the linker Imagen 1.1 - añadir 'opengl32 para el enlazador
Do the same again, this time entering 'glu32′. Haga lo mismo nuevamente, esta vez se
introduce "glu32. And once again entering 'glut32′. Y una vez más se introduce "glut32.
(See Picture 1.2 Below) (Ver Cuadro 1.2)
Picture 1.2 - your linker settings should look like this Imagen 1.2 - La configuración del
vinculador debería tener este aspecto
You now have a project setup for OpenGL and GLUT. Ahora tiene un proyecto de
instalación para OpenGL y GLUT. Let's create a simple program to check everything
works. Vamos a crear un programa sencillo para comprobar que todo funciona.
Step 6 Paso 6
Download my simple glut c++ file by clicking here and downloading 'GlutTutorial-
Main.zip'. Descargar mi exceso de simple c + + por archivo haciendo clic aquí y descarga
de 'GlutTutorial-Main.zip. This application will draw a lit sphere to a window with a black
background. Esta aplicación dibujar una esfera iluminada a una ventana con un fondo
negro.
Extract the .zip file and open up the main.cpp file in Notepad. Extraiga el archivo. Zip y
abrir el archivo main.cpp en Bloc de notas. Select all the text and click 'Edit > Copy'
Selecciona todo el texto y haga clic en "Editar> Copiar '
In CodeBlocks select 'File > New > File…', in the new file window select 'Empty File' and
click the 'Go' button. En Codeblocks seleccione 'Archivo> Nuevo> Archivo ... ", en la
ventana de archivo nuevo seleccione' Go 'Vacío' Archivo 'y haga clic en el botón". In the
wizard that opens select 'Next', then enter 'main.cpp' for the filename and click 'Save'. En el
asistente que aparece, seleccione "Siguiente", luego introduzca "main.cpp" como nombre
de archivo y haga clic en "Guardar". (See Picture 1.3 Below) (Ver Cuadro 1.3)
Picture 1.3 - Enter 'main.cpp' for the file name Imagen 1.3 - Enter 'main.cpp' el nombre del
archivo
Put a tick in the tickboxes next to 'Debug' and 'Release' and then click the 'OK' button. Pon
una cruz en la casillas de verificación junto a "depurar" y "salida" y luego haga clic en el
botón 'Aceptar'. (See Picture 1.4 Below) (Ver Cuadro 1.4)
Picture 1.5 - Select both debug and release Imagen 1.5 - Seleccione depuración y liberación
This should create a new empty file. Esto debería crear un archivo nuevo vacío. Now click
'Edit > Paste' to copy in the code from the file above. Ahora haga clic en "Editar> Pegar
'para copiar en el código del archivo de arriba.
You're now ready to compile and run. Ya está listo para compilar y ejecutar. Simply select
'Build > Build' to compile, hopefully if you followed all the steps above you should have no
build errors. To run select 'Build > Run'. Sólo tiene que seleccionar "Build> Build para
recopilar, espero que si has seguido todos los pasos anteriores no debería tener errores de
generación. Para ejecutar seleccione 'Build> Ejecutar". (See Picture 1.5 Below) (Ver
Cuadro 1.5)