Skip to content

Submission #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions Part1/PROJ_WIN/Project3.sln
Original file line number Diff line number Diff line change
@@ -1,20 +1,37 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Project3", "Project3\Project3.vcxproj", "{D7BEFF7A-4902-4B7E-922B-B0417A66864C}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "simu", "..\..\Part2\simu\simu.vcxproj", "{C654E114-94A9-4019-A56F-219613790863}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D7BEFF7A-4902-4B7E-922B-B0417A66864C}.Debug|Win32.ActiveCfg = Debug|Win32
{D7BEFF7A-4902-4B7E-922B-B0417A66864C}.Debug|Win32.Build.0 = Debug|Win32
{D7BEFF7A-4902-4B7E-922B-B0417A66864C}.Debug|x64.ActiveCfg = Debug|Win32
{D7BEFF7A-4902-4B7E-922B-B0417A66864C}.Release|Win32.ActiveCfg = Release|Win32
{D7BEFF7A-4902-4B7E-922B-B0417A66864C}.Release|Win32.Build.0 = Release|Win32
{D7BEFF7A-4902-4B7E-922B-B0417A66864C}.Release|x64.ActiveCfg = Release|Win32
{C654E114-94A9-4019-A56F-219613790863}.Debug|Win32.ActiveCfg = Debug|Win32
{C654E114-94A9-4019-A56F-219613790863}.Debug|Win32.Build.0 = Debug|Win32
{C654E114-94A9-4019-A56F-219613790863}.Debug|x64.ActiveCfg = Debug|x64
{C654E114-94A9-4019-A56F-219613790863}.Debug|x64.Build.0 = Debug|x64
{C654E114-94A9-4019-A56F-219613790863}.Release|Win32.ActiveCfg = Release|Win32
{C654E114-94A9-4019-A56F-219613790863}.Release|Win32.Build.0 = Release|Win32
{C654E114-94A9-4019-A56F-219613790863}.Release|x64.ActiveCfg = Release|x64
{C654E114-94A9-4019-A56F-219613790863}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
EndGlobal
25 changes: 19 additions & 6 deletions Part1/PROJ_WIN/Project3/Project3.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>MultiByte</CharacterSet>
<PlatformToolset>v100</PlatformToolset>
<PlatformToolset>v110</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
Expand All @@ -42,27 +42,32 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(IncludePath)</IncludePath>
<LibraryPath>$(LibraryPath)</LibraryPath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include;C:/ProgramData/NVIDIA Corporation/CUDA Samples/v5.5/common/inc;../shared/glew/includes;../shared/freeglut/includes</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>..\shared\freeglut\include;..\shared\glew\include;C:/ProgramData/NVIDIA Corporation/CUDA Samples/v5.5/common/inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>../shared/glew/lib;../shared/freeglut/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>cudart.lib; glew32.lib;glu32.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../shared/freeglut/lib;../shared/glew/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>freeglut.lib;cudart.lib;glew32.lib;glu32.lib;opengl32.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Console</SubSystem>
<EntryPointSymbol>mainCRTStartup</EntryPointSymbol>
</Link>
<CudaCompile>
<Include>C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include;C:/ProgramData/NVIDIA Corporation/CUDA Samples/v5.5/common/inc;../shared/glew/includes;../shared/freeglut/includes</Include>
<Include>
</Include>
<CompileOut>$(ProjectDir)$(Platform)/$(Configuration)/%(Filename)%(Extension).obj</CompileOut>
<GPUDebugInfo>true</GPUDebugInfo>
<GenerateLineInfo>true</GenerateLineInfo>
<HostDebugInfo>true</HostDebugInfo>
<CodeGeneration>compute_10,sm_10;compute_20,sm_20;compute_30,sm_30</CodeGeneration>
<CodeGeneration>compute_20,sm_20;compute_30,sm_30</CodeGeneration>
</CudaCompile>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
Expand All @@ -71,12 +76,19 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>..\shared\freeglut\include;..\shared\glew\include;C:/ProgramData/NVIDIA Corporation/CUDA Samples/v5.5/common/inc;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>freeglut.lib;cudart.lib;glew32.lib;glu32.lib;opengl32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>../shared/freeglut/lib;../shared/glew/lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
<CudaCompile>
<Include>C:/ProgramData/NVIDIA Corporation/CUDA Samples/v5.5/common/inc</Include>
<CodeGeneration>compute_20,sm_20</CodeGeneration>
</CudaCompile>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\src\glslUtility.cpp" />
Expand All @@ -94,6 +106,7 @@
<ClInclude Include="..\..\src\glslUtility.h" />
<ClInclude Include="..\..\src\kernel.h" />
<ClInclude Include="..\..\src\main.h" />
<ClInclude Include="..\..\src\timer.h" />
<ClInclude Include="..\..\src\utilities.h" />
</ItemGroup>
<ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions Part1/PROJ_WIN/Project3/Project3.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
<ClInclude Include="..\..\src\utilities.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\src\timer.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CudaCompile Include="..\..\src\kernel.cu">
Expand Down
Binary file added Part1/PROJ_WIN/Project3/freeglut.dll
Binary file not shown.
Binary file added Part1/PROJ_WIN/Project3/glew32.dll
Binary file not shown.
11 changes: 10 additions & 1 deletion Part1/PROJ_WIN/Project3/shaders/heightFS.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
varying float f_height;
varying vec2 v_Texcoords;

void main(void)
{
gl_FragColor = vec4(0.05,0.15,0.3,1.0);
float shade = ( 1.0 - 2.0 * sqrt( f_height ) );

float alpha = float(mod(v_Texcoords.x+0.025, 0.05) > 0.046 ||
mod(v_Texcoords.y+0.025, 0.05) > 0.046);
vec4 color = mix(vec4(0.05,0.15,0.3,1.0), vec4(0.05, 0.3, 0.4, 1.0), alpha);

gl_FragColor = shade * color;
}
14 changes: 12 additions & 2 deletions Part1/PROJ_WIN/Project3/shaders/heightVS.glsl
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
uniform mat4 u_projMatrix;
uniform sampler2D u_height;

attribute vec4 Position;
attribute vec2 Texcoords;

varying vec2 v_Texcoords;
varying float f_height;

void main(void)
{
vec4 pos = u_projMatrix * Position;
pos.z += 0.01;
v_Texcoords = Texcoords;
vec4 pos = Position;
f_height = texture2D( u_height, Texcoords ).w;
pos.z = -0.01 - clamp( f_height, 0.0, 2.0 );
pos = u_projMatrix * pos;

gl_Position = pos;
}
29 changes: 28 additions & 1 deletion Part1/PROJ_WIN/Project3/shaders/planetFS.glsl
Original file line number Diff line number Diff line change
@@ -1,4 +1,31 @@
#version 330

in vec3 WorldCoord;
in vec3 ToCam;
in vec3 Up;
in vec3 Right;
in vec2 TexCoord;
out vec4 FragColor;

void main(void)
{
gl_FragColor = vec4(1.0);
vec2 coord = 2.01 * (TexCoord - vec2(0.5));
float r = length(coord);
if (r >= 1.0)
{
discard;
}

float dist = length(WorldCoord);
if(dist <= 0.01)
{
FragColor = vec4(1.0);
return;
}

vec3 N = Right*-coord.x + Up*coord.y + ToCam*sqrt(1-r*r);
vec3 L = normalize(-WorldCoord);
float light = 0.1 + 0.9*clamp(dot(N,L),0.0, 1.0)*exp(-dist);
vec3 color = vec3(0.4, 0.1, 0.6);
FragColor = vec4(color*light,1.0);
}
40 changes: 37 additions & 3 deletions Part1/PROJ_WIN/Project3/shaders/planetGS.glsl
Original file line number Diff line number Diff line change
@@ -1,15 +1,49 @@
#version 330

uniform mat4 u_projMatrix;
uniform vec3 u_cameraPos;

layout (points) in;
layout (points) out;
layout (max_vertices = 1) out;
layout (triangle_strip) out;
layout (max_vertices = 4) out;

out vec3 WorldCoord;
out vec3 ToCam;
out vec3 Up;
out vec3 Right;
out vec2 TexCoord;

const float scale = 0.03;

void main()
{
vec3 Position = gl_in[0].gl_Position.xyz;
gl_Position = u_projMatrix * vec4(Position, 1.0);
WorldCoord = Position;

ToCam = normalize( u_cameraPos - Position );
Up = vec3( 0.0, 0.0, 1.0 );
Right = cross( ToCam, Up );
Up = cross( Right, ToCam );

vec3 Pos = Position + scale*Right - scale*Up;
gl_Position = u_projMatrix * vec4(Pos, 1.0);
TexCoord = vec2(0.0, 0.0);
EmitVertex();

Pos = Position + scale*Right + scale*Up;
gl_Position = u_projMatrix * vec4(Pos, 1.0);
TexCoord = vec2(0.0, 1.0);
EmitVertex();

Pos = Position - scale*Right - scale*Up;
gl_Position = u_projMatrix * vec4(Pos, 1.0);
TexCoord = vec2(1.0, 0.0);
EmitVertex();

Pos = Position - scale*Right + scale*Up;
gl_Position = u_projMatrix * vec4(Pos, 1.0);
TexCoord = vec2(1.0, 1.0);
EmitVertex();

EndPrimitive();
}
Binary file modified Part1/PROJ_WIN/shared/freeglut/freeglut.dll
Binary file not shown.
29 changes: 28 additions & 1 deletion Part1/PROJ_WIN/shared/freeglut/include/GL/freeglut_ext.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@
#define GLUT_KEY_NUM_LOCK 0x006D
#define GLUT_KEY_BEGIN 0x006E
#define GLUT_KEY_DELETE 0x006F
#define GLUT_KEY_SHIFT_L 0x0070
#define GLUT_KEY_SHIFT_R 0x0071
#define GLUT_KEY_CTRL_L 0x0072
#define GLUT_KEY_CTRL_R 0x0073
#define GLUT_KEY_ALT_L 0x0074
#define GLUT_KEY_ALT_R 0x0075

/*
* GLUT API Extension macro definitions -- behaviour when the user clicks on an "x" to close a window
Expand Down Expand Up @@ -68,7 +74,8 @@
#define GLUT_ACTION_ON_WINDOW_CLOSE 0x01F9

#define GLUT_WINDOW_BORDER_WIDTH 0x01FA
#define GLUT_WINDOW_HEADER_HEIGHT 0x01FB
#define GLUT_WINDOW_BORDER_HEIGHT 0x01FB
#define GLUT_WINDOW_HEADER_HEIGHT 0x01FB /* Docs say it should always have been GLUT_WINDOW_BORDER_HEIGHT, keep this for backward compatibility */

#define GLUT_VERSION 0x01FC

Expand All @@ -77,6 +84,8 @@

#define GLUT_FULL_SCREEN 0x01FF

#define GLUT_SKIP_STALE_MOTION_EVENTS 0x0204

/*
* New tokens for glutInitDisplayMode.
* Only one GLUT_AUXn bit may be used at a time.
Expand Down Expand Up @@ -121,6 +130,7 @@ FGAPI void FGAPIENTRY glutExit ( void );
* Window management functions, see freeglut_window.c
*/
FGAPI void FGAPIENTRY glutFullScreenToggle( void );
FGAPI void FGAPIENTRY glutLeaveFullScreen( void );

/*
* Window-specific callback functions, see freeglut_callbacks.c
Expand Down Expand Up @@ -166,6 +176,17 @@ FGAPI void FGAPIENTRY glutSolidCylinder( GLdouble radius, GLdouble height, GL
typedef void (*GLUTproc)();
FGAPI GLUTproc FGAPIENTRY glutGetProcAddress( const char *procName );

/*
* Multi-touch/multi-pointer extensions
*/

#define GLUT_HAS_MULTI 1

FGAPI void FGAPIENTRY glutMultiEntryFunc( void (* callback)( int, int ) );
FGAPI void FGAPIENTRY glutMultiButtonFunc( void (* callback)( int, int, int, int, int ) );
FGAPI void FGAPIENTRY glutMultiMotionFunc( void (* callback)( int, int, int ) );
FGAPI void FGAPIENTRY glutMultiPassiveFunc( void (* callback)( int, int, int ) );

/*
* Joystick functions, see freeglut_joystick.c
*/
Expand Down Expand Up @@ -196,6 +217,12 @@ FGAPI void FGAPIENTRY glutInitContextVersion( int majorVersion, int minorVers
FGAPI void FGAPIENTRY glutInitContextFlags( int flags );
FGAPI void FGAPIENTRY glutInitContextProfile( int profile );

/* to get the typedef for va_list */
#include <stdarg.h>

FGAPI void FGAPIENTRY glutInitErrorFunc( void (* vError)( const char *fmt, va_list ap ) );
FGAPI void FGAPIENTRY glutInitWarningFunc( void (* vWarning)( const char *fmt, va_list ap ) );

/*
* GLUT API macro definitions -- the display mode definitions
*/
Expand Down
20 changes: 15 additions & 5 deletions Part1/PROJ_WIN/shared/freeglut/include/GL/freeglut_std.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
*/

/* Define FREEGLUT_LIB_PRAGMAS to 1 to include library
* pragmas or to 1 to exclude library pragmas.
* pragmas or to 0 to exclude library pragmas.
* The default behavior depends on the compiler/platform.
*/
# ifndef FREEGLUT_LIB_PRAGMAS
Expand All @@ -57,7 +57,9 @@
# ifndef WIN32_LEAN_AND_MEAN
# define WIN32_LEAN_AND_MEAN 1
# endif
# define NOMINMAX
# ifndef NOMINMAX
# define NOMINMAX
# endif
# include <windows.h>

/* Windows static library */
Expand Down Expand Up @@ -111,14 +113,21 @@
*/
#define FREEGLUT 1
#define GLUT_API_VERSION 4
#define FREEGLUT_VERSION_2_0 1
#define GLUT_XLIB_IMPLEMENTATION 13
/* Deprecated:
cf. http://sourceforge.net/mailarchive/forum.php?thread_name=CABcAi1hw7cr4xtigckaGXB5X8wddLfMcbA_rZ3NAuwMrX_zmsw%40mail.gmail.com&forum_name=freeglut-developer */
#define FREEGLUT_VERSION_2_0 1

/*
* Always include OpenGL and GLU headers
*/
#include <GL/gl.h>
#include <GL/glu.h>
#if __APPLE__
# include <OpenGL/gl.h>
# include <OpenGL/glu.h>
#else
# include <GL/gl.h>
# include <GL/glu.h>
#endif

/*
* GLUT API macro definitions -- the special key codes:
Expand Down Expand Up @@ -531,6 +540,7 @@ FGAPI void FGAPIENTRY glutSolidIcosahedron( void );

/*
* Teapot rendering functions, found in freeglut_teapot.c
* NB: front facing polygons have clockwise winding, not counter clockwise
*/
FGAPI void FGAPIENTRY glutWireTeapot( GLdouble size );
FGAPI void FGAPIENTRY glutSolidTeapot( GLdouble size );
Expand Down
Loading