C++ - OpenGL - Setting up Visual Studio

Similar documents
Lecture 3. Understanding of OPenGL programming

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

Bob s Concise Introduction to Doxygen

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

Using OpenGL with CUDA

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

LECTURE 02 OPENGL API

CSE4030 Introduction to Computer Graphics

OpenGL and GLUT. COMP413 Computer Graphics. School of Computer Sci. & Eng. Kyungpook National University, Korea. Spring Semester, 2016

Announcements OpenGL. Computer Graphics. Spring CS4815

Announcements OpenGL. Computer Graphics. Autumn 2009 CS4815

Check the Desktop development with C++ in the install options. You may want to take 15 minutes to try the Hello World C++ tutorial:

Introduction to MS Visual C/C++

CS 432 Interactive Computer Graphics

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

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

Computer Graphics. OpenGL

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

COMPUTER GRAPHICS LAB # 3

Computer Graphics. Making Pictures. Computer Graphics CSC470 1

Assignment 1. Simple Graphics program using OpenGL

Drawing Primitives. OpenGL basics

Programming with OpenGL Part 3: Three Dimensions

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

Programming using OpenGL: A first Introduction

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

First, let's make sure we have all of the starter code downloaded. MAC (Go to the second part of the tutorial if you are using windows)

GL_COLOR_BUFFER_BIT, GL_PROJECTION, GL_MODELVIEW

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

CS 380 Introduction to Computer Graphics. LAB (1) : OpenGL Tutorial Reference : Foundations of 3D Computer Graphics, Steven J.

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

Introduction to OpenGL: Part 2

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2003

OpenGL Basics I. Seoul National University Graphics & Media Lab

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

GLUT Tutorial. Keyboard

Graphics Programming

Draw the basic Geometry Objects. Hanyang University

Basic Graphics Programming

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

Lab 1: First Steps in C++ - Eclipse

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2005

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

Lectures OpenGL Introduction

Opening Microsoft Visual Studio. On Microsoft Windows Vista and XP to open the visual studio do the following:

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

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

Introduction to Computer Graphics. Hardware Acceleration Review

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

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

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

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

OpenGL refresher. Advanced Computer Graphics 2012

CS Computer Graphics: Intro to OpenGL

CS Computer Graphics: Intro to OpenGL

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

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

GLUT Tutorial. John Tsiombikas (Nuclear / The Lab Demos) May 6, Introduction to GLUT (OpenGL Utility Toolkit)

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

Display Lists in OpenGL

Lab 1: Introduction to C Programming. (Creating a program using the Microsoft developer Studio, Compiling and Linking)

Graphics Hardware and OpenGL

EECE.2160: ECE Application Programming Spring 2018 Programming Assignment #1: A Simple C Program Due Monday, 1/29/18, 11:59:59 PM

Computer Graphics. Bing-Yu Chen National Taiwan University

Compiling MapleSim C-Code in Visual C Express

Introduction. Key features and lab exercises to familiarize new users to the Visual environment

Getting Started with Visual Studio

CST8152 Compilers Creating a C Language Console Project with Microsoft Visual Studio.Net 2010

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


OpenGL Introduction Computer Graphics and Visualization

Philip Calderon CSE 520 Lab 3 Color Shader

Programming with OpenGL Part 1: Background

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

CS 4204 Computer Graphics

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

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

Computer Graphics: Line Drawing Algorithms

ECE QNX Real-time Lab

An Overview GLUT GLSL GLEW

Precept 2 Aleksey Boyko February 18, 2011

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

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

TREX Set-Up Guide: Creating a TREX Executable File for Windows

Tutorial : creating a Max/MSP external project for Windows using Visual Studio

Visual C++ Tutorial. For Introduction to Programming with C++ By Y. Daniel Liang

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

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.

2. EXERCISE SHEET, RETURN DATE MAY 7/8TH 2015, INDIVIDUALLY. to the compiler options. I also suggest you to use the options

Document Revision No.: 1 Revised: 03/12/09 RIT KGCOE MSD Program. P09027 Upper Extremity Motion Capture System. Software Manual

CS Computer Graphics: OpenGL, Continued

CS Computer Graphics: OpenGL, Continued

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

Installing and Using Dev-C++

Computer Graphics (CS 543) Lecture 3b: Shader Setup & GLSL Introduction

Introduction to Computer Graphics with OpenGL/GLUT

Computer Graphics, Chapt 08

Programming with OpenGL Part 1: Background

Introduction to OpenGL

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

Transcription:

FAKULTI TEKNOLOGI MAKLUMAT DAN KOMUNIKASI BITM 3213 - INTERACTIVE COMPUTER GRAPHICS LAB SESSION 1 C++ - OpenGL - Setting up Visual Studio (FROM WEBSITE: http://www.badprog.com/c-opengl-setting-up-visual-studio)

C++ - OpenGL - Setting up Visual Studio Submitted by Mi-K on Sunday, July 26, 2015-7:08pm FROM WEBSITE: http://www.badprog.com/c-opengl-setting-up-visual-studio The Visual Studio version for this tutorial will be the 2015 RC. The glew version will be the 1.12.0. The freeglut version will be the 3.0.0. The glew library stands for GL Extension Wrangler. At the end of this OpenGL tutorial you will be able to display a window with a white square displayed on a black background. First of all We are going to use the 32-bit or the 64-bit version. You have the choice, and it will be specified in the tutorial. Notice that the version is only based on which platform you want to compile for. If you plan to create a program to be executed on a 32-bit platform, so use the 32- bit version. Every platform accept 32-version, so the 64-bit version is only for specific purpose only. And so the 32-bit version will work on every Windows system. glew You'll need glew headers that could be find on the sourceforge website of the OpenGL Extension Wrangler Library: http://sourceforge.net/projects/glew/files/glew/ freeglut You'll also need the freeglut version for Microsoft Visual Studio: http://www.transmissionzero.co.uk/software/freeglut-devel/

Click the link inside the part freeglut 3.0.0 MSVC Package. The name of the file you have to download is: freeglut-msvc-3.0.0-2.mp.zip. Once you have downloaded it, there is a folder named freeglut inside. Extract it and rename it to freeglut-3.0.0 in order to have exactly the same name used in this tutorial. Paths and directories for this setup The general directory for our setup will be: C:\dev The directory where projects are: C:\dev\visual-studio-c++ The directory where libraries are: C:\dev\lib Visual Studio Open it and create an empty project > File > New > Project > Templates > Visual C++ > Empty Project. Then write: Name: Shapes2D Location: C:\dev\visual-studio-c++\ Solution: Create a new solution Solution name: BadprogTutorial OK > Finish. Your Shapes2D project has been created into your BadprogTutorial solution. Let's add a main.cpp > Right click your project > Add > New Item > Visual C++ > C++ File > write the name main.cpp > Add. Setting all configurations

Right click your Shapes2D project > Properties > On the top left there is a drop down menu > Configuration > Select All Configurations (instead of Debug) Including header files (includes) Right click your Shapes2D project > Properties > Configuration Properties > C/C++ > General > Additional Include Directories > Click it. On the right there is a drop down menu, click <Edit...>. A new window has appeared: Additional Include Directories. Click the New Line icon > Click the browse button > Then select the two following folders: 1. C:\dev\lib\glew-1.12.0\include 2. C:\dev\lib\freeglut-3.0.0\include Click OK > Apply Including libraries Library folders Right click your Shapes2D project > Properties > Configuration Properties > Linker > General > Additional Library Directories > Click it. On the right there is a drop down menu, click <Edit...>. A new window has appeared: Additional Library Directories. Click the New Line icon > Click the browse button > Then select the two following folders: For the 64-bit version 1. C:\dev\lib\glew-1.12.0\lib\Release\x64 2. C:\dev\lib\freeglut-3.0.0\lib\x64 For the 32-bit version 1. C:\dev\lib\glew-1.12.0\lib\Release\Win32 2. C:\dev\lib\freeglut-3.0.0\lib Click OK > Apply

Library files Right click your Shapes2D project > Properties > Configuration Properties > Linker > Input > Additional Dependencies > Click it. On the right there is a drop down menu, click <Edit...>. A new window has appeared: Additional Dependencies. Click the white area and write: freeglut.lib (click enter to go the next line) glew32.lib Click OK > Apply > OK. Your Visual Studio IDE is now ready to play with OpenGL! Testing the setup To test the setup, let's code the most basic code HelloWorld! that you can write with OpenGL. #include <GL\glew.h> #include <GL\freeglut.h> /** * glvertex2f(float x, float y). * The point (0.0, 0.0) represents the middle of the window (not the top left corner). * The "2f" suffix means 2 values of float type (x and y). */ void displayme(void) { glclear(gl_color_buffer_bit); glbegin(gl_polygon); glvertex2f(0.0, 0.0); glvertex2f(0.5, 0.0); glvertex2f(0.5, 0.5); glvertex2f(0.0, 0.5); // bottom left // bottom right // top right // top left

glend(); glflush(); } int main(int argc, char** argv) { glutinit(&argc, argv); glutinitdisplaymode(glut_single); glutinitwindowsize(300, 300); glutinitwindowposition(500, 500); // window size // distance from the top-left screen glutcreatewindow("badprog - Hello world :D"); // message displayed on top bar window glutdisplayfunc(displayme); glutmainloop(); return 0; } On the Visual Studio's top menu there is a dropdown menu with x86 selected. Click the black tiny triangle on the right of the x86 and select Configuration Manager. A new window has appeared: Configuration Manager. On the right select x86 in the dropdown menu and click New. A new window has appeared: New Solution Platform. On the right click the the Active solution platform dropdown menu and select: Type or select the new platform: x64 Copy settings from: x86 (or Empty) Click OK. You could now close the Configuration Manager and as you can see the platform is now specified as x64. And you could easily click either x86 or x64 (depending of your libraries version). freeglut.dll and glew32.dll

Before building it, let's copy (not move!) the.dll of these two libraries: For the 64-bit version Copy: C:\dev\lib\glew-1.12.0\bin\Release\x64\glew32.dll (yes this is the right one) and C:\dev\lib\freeglut-3.0.0\bin\x64\freeglut.dll To the following directory: C:\dev\visual-studio-c++\BadprogTutorial\x64\Debug For the 32-bit version Copy: C:\dev\lib\glew-1.12.0\bin\Release\Win32\glew32.dll and C:\dev\lib\freeglut-3.0.0\bin\freeglut.dll To the following directory: C:\dev\visual-studio-c++\BadprogTutorial\Debug Building the project On the Visual Studio's top menu, select either x86 or x64 and build the project. If there is no error, right click the Shapes2D project > Debug > Start new instance. If all is OK, you should see a black window with a white square. Possible Errors If you had some errors like these ones, it's because you try to play with a different version from the one specified in the setup configuration. For example if you have set up the configuration with the 64-bit version, you have to build it with thex64 configuration. Same thing for the 32-bit version, set up with the 32-bit library version and build it as a x86configuration. So double check the paths you've just entered in the setup configuration.

Here the errors: All packages are already installed and there is nothing to restore. NuGet package restore finished. 1>------ Build started: Project: Shapes2D, Configuration: Debug Win32 ------ 1>main.obj : error LNK2019: unresolved external symbol imp glutinitwindowposition@8 referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol imp glutinitwindowsize@8 referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol imp glutinitdisplaymode@4 referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol imp glutmainloop@0 referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol imp glutdisplayfunc@4 referenced in function _main 1>main.obj : error LNK2019: unresolved external symbol imp glutinitwithexit@12 referenced in function _glutinit_atexit_hack@8 1>main.obj : error LNK2019: unresolved external symbol imp glutcreatewindowwithexit@8 referenced in function _glutcreatewindow_atexit_hack@4 1>C:\dev\lib\freeglut-3.0.0\lib\x64\freeglut.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'X86' 1>C:\dev\visual-studio-c++\BadprogTutorial\Debug\Shapes2D.exe : fatal error LNK1120: 7 unresolved externals ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== Conclusion Now that your Visual Studio has been set up, you could start creating OpenGL applications. Well done, you've made it.