running opengl on visual studio 2005

Upload: maja-kokolanska

Post on 19-Feb-2018

245 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/23/2019 Running Opengl on Visual Studio 2005

    1/23

    RUNNING OpenGL on VISUAL STUDIO 2005

    Step 0: GLUT Installation (only needs to be done once)

    Windows comes with OpenGL, and Visual Studio comes with the OpenGL libraries, but neither of them comes with GLUT.Get the newest version of GLUT here: GLUT .!." for Windows.

    #ut the followin$ files in the followin$ locations:

    Install Glut into the following die!toies"

    glut32.dll-> C:\Windows\System or C:\WinNT\Systemglut32.lib-> C:\Program Files\Microsoft Visual Studio \VC\PlatformS!"\li#

    glut32.h-> C:\Program Files\Microsoft Visual Studio \VC\PlatformS!"\include\gl

    Note:%f &ou plan on $ivin$ &our pro$ram to friends to run usin$ Windows, &ou must also include the $lut'.dllfile. %f the& don(thave this file in the same director& as &our application or in their ):*W%+OWS*s&stemfolder, the pro$ram will not run.

    Step 1: Create a Visual Studio 200 !ro"ect

    To create an empt& console pro-ect in Visual Studio, do the followin$:

    $% )reate a new pro-ect /ile 0001 +ew 0001 0001#ro-ect

    http://www.xmission.com/~nate/glut.htmlhttp://www.xmission.com/~nate/glut.html
  • 7/23/2019 Running Opengl on Visual Studio 2005

    2/23

  • 7/23/2019 Running Opengl on Visual Studio 2005

    3/23

    '. In t#e#ro-ect T&pes: pane$ select Visual )22, Win'. T#en select Win ' )onsole 3pplication in t#eTemplates:pane%Na&e your pro"ect$ select t#e location 'or t#e pro"ect and clicO4.

  • 7/23/2019 Running Opengl on Visual Studio 2005

    4/23

    . Clic t#e3pplication Settin$s tab on t#e le't, and c#ec t#e5mpt& #ro-ect bo. T#en clic/inish button.

    Step 2: *dd Source Code

  • 7/23/2019 Running Opengl on Visual Studio 2005

    5/23

    6. Select #ro-ect, 3dd +ew %tem .

  • 7/23/2019 Running Opengl on Visual Studio 2005

    6/23

  • 7/23/2019 Running Opengl on Visual Studio 2005

    7/23

    '. In t#e)ate$ories pane$ select Visual )22, )ode. T#en select )22 /ile ,cpp7 in t#eTemplates: pane%Na&e your'ile$ and t#en clic3dd.

    . )op& and paste the code below into the file. Save &our time of t&pin$.

  • 7/23/2019 Running Opengl on Visual Studio 2005

    8/23

    89 animation and circle b& subdivision 98

    include ;stdio.h1include ;stdlib.h1include ;math.h1include ;GL8$lut.h1

    define 5S) '!define S#3)5 'int ??, Width=>??@int depth=?, circleAadius=', cnt=6@

    static float vdataB>CBC = DD6.?, ?.?, ?.?E, D?.?, 6.?, ?.?E,D06.?, ?.?, ?.?E, D?.?, 06.?, ?.?EE@

    void normaliFefloat vBC7 Dfloat d = srtvB?C9vB?C2vB6C9vB6C2vB'C9vB'C7@

    if d == ?7 DprintfHFero len$th vectorH7@return@EvB?C 8= d@ vB6C 8= d@ vB'C 8= d@E

    void drawtrian$lefloat 9v6, float 9v', float 9v7

  • 7/23/2019 Running Opengl on Visual Studio 2005

    9/23

    D$lIe$inGLJTA%3+GL5S7@$lVerteKfvv67@

    $lVerteKfvv'7@$lVerteKfvv7@$l5nd7@E

    void subdivide)ircleint radius, float 9v6, float 9v', int depth7Dfloat v66BC, v''BC, v??BC = D?, ?, ?E, v6'BC@int i@

    if depth == ?7 D$l)olorfv6B?C9v6B?C, v6B6C9v6B6C, v6B'C9v6B'C7@

    for i=?@ i;@ i227 Dv66BiC = v6BiC9radius@v''BiC = v'BiC9radius@Edrawtrian$lev66, v'', v??7@

    return@E

    v6'B?C = v6B?C2v'B?C@v6'B6C = v6B6C2v'B6C@v6'B'C = v6B'C2v'B'C@

  • 7/23/2019 Running Opengl on Visual Studio 2005

    10/23

    normaliFev6'7@

    subdivide)ircleradius, v6, v6', depth 0 67@

    subdivide)ircleradius, v6', v', depth 0 67@E

    void draw)ircleint circleAadius788 draw a circle with center at the ori$in in K& planeD

    subdivide)irclecircleAadius, vdataB?C, vdataB6C, depth7@subdivide)irclecircleAadius, vdataB6C, vdataB'C, depth7@

    subdivide)irclecircleAadius, vdataB'C, vdataBC, depth7@subdivide)irclecircleAadius, vdataBC, vdataB?C, depth7@E

    void displa&void7Dif circleAadius1Width8' circleAadius==67Dcnt=0cnt@

    depth22@depth = depth M N@E

    circleAadius2=cnt@

    $l)learGLJ)OLOAJIU//5AJI%T7@draw)irclecircleAadius7@

  • 7/23/2019 Running Opengl on Visual Studio 2005

    11/23

    $lutSwapIuffers7@E

    static void Aeshapeint w, int h7D$l)lear)olor ?.?, ?.?, ?.?, 6.?7@$l)learGLJ)OLOAJIU//5AJI%T7@

    Width = w@

  • 7/23/2019 Running Opengl on Visual Studio 2005

    12/23

    $lut%dle/uncdispla&7@EE

    int mainint ar$c, char 99ar$v7D$lut%nitRar$c, ar$v7@$lut%nitispla&odeGLUTJOUIL57@$lut%nitWindowSiFeWidth,

  • 7/23/2019 Running Opengl on Visual Studio 2005

    13/23

  • 7/23/2019 Running Opengl on Visual Studio 2005

    14/23

  • 7/23/2019 Running Opengl on Visual Studio 2005

    15/23

    Step +: ,odi'y t#e pro"ect properties

    6. Use Visual Studio(s menu #ro-ect options #ro-ect 001 raw #roperties7

  • 7/23/2019 Running Opengl on Visual Studio 2005

    16/23

  • 7/23/2019 Running Opengl on Visual Studio 2005

    17/23

    '. The raw #ropert& #a$e dialo$ will open. Once it appears, do the followin$:

    a. Select t#e )onfi$uration co&bo bo, select3ll )onfi$uration

  • 7/23/2019 Running Opengl on Visual Studio 2005

    18/23

    b. In t#e le't pane$ select t#elinQer subtree and t#en clic t#e%nput option% *dd t#e 'ollo-in. code to t#e3dditional ependencies tet in t#e ri.#t pane%

    Copy and !aste: open$l'.lib $lu'.lib $lut'.lib

    No- Visual Studio no-s -#ere to 'ind GLUT% Clic O4 button

    Step /: Co&pile and un t#e pro"ect

  • 7/23/2019 Running Opengl on Visual Studio 2005

    19/23

    a. )ompile/rom the Visual Studio(s menu Iuild option Iuild 0001 Iuild Solution7

  • 7/23/2019 Running Opengl on Visual Studio 2005

    20/23

  • 7/23/2019 Running Opengl on Visual Studio 2005

    21/23

    b. 5Kecute the pro$ram

    ro& t#e Visual Studios &enuebu$ optionebu$ 0001 Start Without ebu$$in$7

  • 7/23/2019 Running Opengl on Visual Studio 2005

    22/23

  • 7/23/2019 Running Opengl on Visual Studio 2005

    23/23

    T#AT$S ALL %OL&S' GOOD LU(& )