Initial commit
This commit is contained in:
121
documents/Tesselation_Tutorial/src/Main.cpp
Normal file
121
documents/Tesselation_Tutorial/src/Main.cpp
Normal file
@@ -0,0 +1,121 @@
|
||||
/////////////////////////////////////////////
|
||||
// This source is licensed under MIT license
|
||||
/////////////////////////////////////////////
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <stdio.h>
|
||||
#include <glew.h>
|
||||
#include <wglew.h>
|
||||
#include <GL/glut.h>// Header File For The GLUT Library
|
||||
using namespace std;
|
||||
#include "glsl.h"
|
||||
///////////////////////////////////////////
|
||||
void DrawScene()
|
||||
{
|
||||
glClearDepth(1.0f);
|
||||
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
static bool init=true;
|
||||
static Shader quad_shader("Quad Shader");
|
||||
static Shader tri_shader("Triangle Shader");
|
||||
|
||||
static int VBOvert=0;
|
||||
const int num_floats=4*4;
|
||||
|
||||
if(init)
|
||||
{
|
||||
/*+++++++++++++++++++++++++++++++++++++*/
|
||||
std::cout << "GL_VERSION: " << glGetString(GL_VERSION) << std::endl; //std::cout << "GL_EXTENSIONS: " << glGetString(GL_EXTENSIONS) << std::endl;
|
||||
std::cout << "GL_RENDERER: " << glGetString(GL_RENDERER) << std::endl;
|
||||
std::cout << "GL_VENDOR: " << glGetString(GL_VENDOR) << std::endl;
|
||||
std::cout << "GLU_VERSION: " << gluGetString(GLU_VERSION) << std::endl; //std::cout << "GLU_EXTENSIONS: " << gluGetString(GLU_EXTENSIONS) << std::endl;
|
||||
std::cout << "GLUT_API_VERSION: " << GLUT_API_VERSION << std::endl;
|
||||
/*+++++++++++++++++++++++++++++++++++++*/
|
||||
quad_shader.attach(GL_VERTEX_SHADER,"../shader/tess_vs.txt");
|
||||
quad_shader.attach(GL_FRAGMENT_SHADER,"../shader/tess_frag.txt");
|
||||
quad_shader.attach(GL_GEOMETRY_SHADER,"../shader/tess_geo.txt");
|
||||
quad_shader.attach(GL_TESS_CONTROL_SHADER,"../shader/tess_quad_tcs.txt");
|
||||
quad_shader.attach(GL_TESS_EVALUATION_SHADER,"../shader/tess_quad_tes.txt");
|
||||
quad_shader.link();
|
||||
/*+++++++++++++++++++++++++++++++++++++*/
|
||||
tri_shader.attach(GL_VERTEX_SHADER,"../shader/tess_vs.txt");
|
||||
tri_shader.attach(GL_FRAGMENT_SHADER,"../shader/tess_frag.txt");
|
||||
tri_shader.attach(GL_GEOMETRY_SHADER,"../shader/tess_geo.txt");
|
||||
tri_shader.attach(GL_TESS_CONTROL_SHADER,"../shader/tess_tri_tcs.txt");
|
||||
tri_shader.attach(GL_TESS_EVALUATION_SHADER,"../shader/tess_tri_tes.txt");
|
||||
tri_shader.link();
|
||||
/*+++++++++++++++++++++++++++++++++++++*/
|
||||
float vert[num_floats] = {
|
||||
- 0.3 , -0.3 , 0 , 0.3, // upleft
|
||||
0.3 , -0.3 , 0 , 0.6, // upright
|
||||
0.3 , 0.3 , 0 , 0.4, // downright
|
||||
- 0.3 , 0.3 , 0 , 0.1 // downleft
|
||||
};
|
||||
glGenBuffers(1, (GLuint *)(&VBOvert));
|
||||
glBindBuffer(GL_ARRAY_BUFFER, VBOvert);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(float)*num_floats,vert, GL_DYNAMIC_DRAW_ARB );
|
||||
glPointSize(10);
|
||||
/*+++++++++++++++++++++++++++++++++++++*/
|
||||
init=false;
|
||||
/*+++++++++++++++++++++++++++++++++++++*/
|
||||
}
|
||||
glMatrixMode( GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glOrtho(-1.0, 1.0, -1.0, 1.0, -1.0, 1.0);
|
||||
glMatrixMode( GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
|
||||
float Projection[16];
|
||||
float Modelview[16];
|
||||
glGetFloatv(GL_PROJECTION_MATRIX, Projection); CHECK_GL_ERROR();
|
||||
glTranslatef(-0.5,0,0);
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, Modelview);
|
||||
|
||||
// Enable VBO
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, VBOvert); CHECK_GL_ERROR();
|
||||
glEnableClientState(GL_VERTEX_ARRAY); CHECK_GL_ERROR();
|
||||
glVertexPointer ( 4, GL_FLOAT,0, (char *) 0); CHECK_GL_ERROR();
|
||||
|
||||
// Quad Mesh
|
||||
quad_shader.begin();
|
||||
quad_shader.setUniformMatrix4fv("projectionMatrix", 1, 0, Projection); CHECK_GL_ERROR();
|
||||
quad_shader.setUniformMatrix4fv("modelViewMatrix", 1, 0, Modelview); CHECK_GL_ERROR();
|
||||
glPatchParameteri(GL_PATCH_VERTICES, 4);
|
||||
glDrawArrays( GL_PATCHES, 0, 4); CHECK_GL_ERROR();
|
||||
quad_shader.end();
|
||||
|
||||
glTranslatef(1,0,0);
|
||||
glGetFloatv(GL_MODELVIEW_MATRIX, Modelview);
|
||||
|
||||
// Triangle Mesh
|
||||
tri_shader.begin();
|
||||
tri_shader.setUniformMatrix4fv("projectionMatrix", 1, 0, Projection); CHECK_GL_ERROR();
|
||||
tri_shader.setUniformMatrix4fv("modelViewMatrix", 1, 0, Modelview); CHECK_GL_ERROR();
|
||||
glPatchParameteri(GL_PATCH_VERTICES, 3);
|
||||
glDrawArrays( GL_PATCHES, 0, 3); CHECK_GL_ERROR();
|
||||
tri_shader.end();
|
||||
|
||||
// Disable VBO
|
||||
glDisableClientState(GL_VERTEX_ARRAY); CHECK_GL_ERROR();
|
||||
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0); CHECK_GL_ERROR();
|
||||
|
||||
glutSwapBuffers();
|
||||
}
|
||||
///////////////////////////////////////////
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
glutInit(&argc, argv);
|
||||
glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE | GLUT_ALPHA | GLUT_DEPTH);
|
||||
glutInitWindowSize(800, 600);
|
||||
glutInitWindowPosition(0, 0);
|
||||
glutCreateWindow("Tesselation Example (c) Sven Forstmann 2011");
|
||||
glutDisplayFunc(DrawScene);
|
||||
glutIdleFunc(DrawScene);
|
||||
glewInit();
|
||||
wglSwapIntervalEXT(0);
|
||||
glutMainLoop();
|
||||
return 0;
|
||||
}
|
||||
///////////////////////////////////////////
|
||||
404
documents/Tesselation_Tutorial/src/Tesselation.vcproj
Normal file
404
documents/Tesselation_Tutorial/src/Tesselation.vcproj
Normal file
@@ -0,0 +1,404 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="Tesselation"
|
||||
ProjectGUID="{98864040-E723-43CF-9479-6FBCDF2F6C51}"
|
||||
RootNamespace="Cutscene"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="Debug"
|
||||
IntermediateDirectory="Debug"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\ext"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="0"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="strmiids.lib winmm.lib glut32.lib "
|
||||
OutputFile="..\bin32\$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="..\lib32"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\ext"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="0"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="strmiids.lib winmm.lib glut32.lib "
|
||||
OutputFile="..\bin64\$(ProjectName).exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories="..\lib64"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="Release"
|
||||
IntermediateDirectory="Release"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories="..\ext"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
TreatWChar_tAsBuiltInType="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="0"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="strmiids.lib winmm.lib glut32.lib "
|
||||
OutputFile="..\bin32\$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\lib32"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="1"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="1"
|
||||
CharacterSet="0"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
AdditionalIncludeDirectories="..\ext"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="2"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="0"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="strmiids.lib winmm.lib glut32.lib "
|
||||
OutputFile="..\bin64\$(ProjectName).exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories="..\lib64"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
OptimizeReferences="2"
|
||||
EnableCOMDATFolding="2"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="src"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\glsl.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\Main.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="ext"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\ext\glew.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ext\glew.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ext\glxew.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\ext\wglew.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="shader"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\shader\tess_frag.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\shader\tess_geo.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\shader\tess_quad_tcs.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\shader\tess_quad_tes.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\shader\tess_tri_tcs.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\shader\tess_tri_tes.txt"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\shader\tess_vs.txt"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
205
documents/Tesselation_Tutorial/src/Tesselation.vcxproj
Normal file
205
documents/Tesselation_Tutorial/src/Tesselation.vcxproj
Normal file
@@ -0,0 +1,205 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{98864040-E723-43CF-9479-6FBCDF2F6C51}</ProjectGuid>
|
||||
<RootNamespace>Cutscene</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>NotSet</CharacterSet>
|
||||
<PlatformToolset>Windows7.1SDK</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Debug\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Release\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\ext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>strmiids.lib;winmm.lib;glut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>..\bin32\$(ProjectName).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\lib32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>..\ext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>strmiids.lib;winmm.lib;glut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>..\bin64\$(ProjectName).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories>..\ext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>strmiids.lib;winmm.lib;glut32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>..\bin32\$(ProjectName).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\lib32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<AdditionalIncludeDirectories>..\ext;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>glut32.lib</AdditionalDependencies>
|
||||
<OutputFile>..\bin64\$(ProjectName).exe</OutputFile>
|
||||
<AdditionalLibraryDirectories>..\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="glsl.h" />
|
||||
<ClInclude Include="..\ext\glew.h" />
|
||||
<ClInclude Include="..\ext\glxew.h" />
|
||||
<ClInclude Include="..\ext\wglew.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp" />
|
||||
<ClCompile Include="..\ext\glew.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\shader\tess_frag.txt" />
|
||||
<None Include="..\shader\tess_geo.txt" />
|
||||
<None Include="..\shader\tess_quad_tcs.txt" />
|
||||
<None Include="..\shader\tess_quad_tes.txt" />
|
||||
<None Include="..\shader\tess_tri_tcs.txt" />
|
||||
<None Include="..\shader\tess_tri_tes.txt" />
|
||||
<None Include="..\shader\tess_vs.txt" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="src">
|
||||
<UniqueIdentifier>{0afe1f4c-a089-43f2-9880-9653e3e32383}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="ext">
|
||||
<UniqueIdentifier>{68ac1930-7cbf-408a-97bd-650bca509cb8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="shader">
|
||||
<UniqueIdentifier>{9598472a-f3af-468e-b477-a16a6fc8fb2d}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="glsl.h">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\glew.h">
|
||||
<Filter>ext</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\glxew.h">
|
||||
<Filter>ext</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\ext\wglew.h">
|
||||
<Filter>ext</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Main.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\ext\glew.cpp">
|
||||
<Filter>ext</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\shader\tess_frag.txt">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
<None Include="..\shader\tess_geo.txt">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
<None Include="..\shader\tess_quad_tcs.txt">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
<None Include="..\shader\tess_quad_tes.txt">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
<None Include="..\shader\tess_tri_tcs.txt">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
<None Include="..\shader\tess_tri_tes.txt">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
<None Include="..\shader\tess_vs.txt">
|
||||
<Filter>shader</Filter>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LocalDebuggerCommand>..\bin64\$(ProjectName).exe</LocalDebuggerCommand>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
122
documents/Tesselation_Tutorial/src/glsl.h
Normal file
122
documents/Tesselation_Tutorial/src/glsl.h
Normal file
@@ -0,0 +1,122 @@
|
||||
// GL ERROR CHECK
|
||||
#define CHECK_GL_ERROR() CheckGLError(__FILE__, __LINE__)
|
||||
// GL ERROR CHECK
|
||||
int CheckGLError(char *file, int line)
|
||||
{
|
||||
//return 0;
|
||||
GLenum glErr,glErr2;
|
||||
int retCode = 0;
|
||||
|
||||
glErr = glErr2 = glGetError();
|
||||
while (glErr != GL_NO_ERROR)
|
||||
{
|
||||
char* str1 = (char*)gluErrorString(glErr);
|
||||
if (str1)
|
||||
cout << "GL Error #" << glErr << "(" << str1 << ") " << " in File " << file << " at line: " << line << endl;
|
||||
else
|
||||
cout << "GL Error #" << glErr << " in File " << file << " at line: " << line << endl;
|
||||
retCode = 1;
|
||||
glErr = glGetError();
|
||||
}
|
||||
if (glErr2 != GL_NO_ERROR) while(1)Sleep(100);;
|
||||
|
||||
return 0;
|
||||
}
|
||||
///////////////////////////////////////////
|
||||
class Shader
|
||||
{
|
||||
public:
|
||||
Shader(std::string shadername){name=shadername;};
|
||||
void attach(int type,char* filename)
|
||||
{
|
||||
char* mem=read_file(filename);
|
||||
GLuint handle = glCreateShader(type);
|
||||
glShaderSource(handle, 1, (const GLchar**)(&mem), 0);
|
||||
CHECK_GL_ERROR();
|
||||
glCompileShader(handle);
|
||||
CHECK_GL_ERROR();
|
||||
|
||||
GLint compileSuccess=0;
|
||||
GLchar compilerSpew[256];
|
||||
|
||||
glGetShaderiv(handle, GL_COMPILE_STATUS, &compileSuccess);
|
||||
CHECK_GL_ERROR();
|
||||
if(!compileSuccess)
|
||||
{
|
||||
glGetShaderInfoLog(handle, sizeof(compilerSpew), 0, compilerSpew);
|
||||
printf("Shader %s\n%s\ncompileSuccess=%d\n",filename,compilerSpew,compileSuccess);
|
||||
CHECK_GL_ERROR();
|
||||
while(1);;
|
||||
}
|
||||
handles.push_back(handle);
|
||||
}
|
||||
void link()
|
||||
{
|
||||
program_handle = glCreateProgram();
|
||||
for (int i=0;i<handles.size();i++)
|
||||
{
|
||||
glAttachShader(program_handle, handles[i]);
|
||||
CHECK_GL_ERROR();
|
||||
}
|
||||
|
||||
glLinkProgram(program_handle);
|
||||
CHECK_GL_ERROR();
|
||||
|
||||
GLint linkSuccess;
|
||||
GLchar compilerSpew[256];
|
||||
glGetProgramiv(program_handle, GL_LINK_STATUS, &linkSuccess);
|
||||
if(!linkSuccess)
|
||||
{
|
||||
glGetProgramInfoLog(program_handle, sizeof(compilerSpew), 0, compilerSpew);
|
||||
printf("Shader Linker:\n%s\nlinkSuccess=%d\n",compilerSpew,linkSuccess);
|
||||
CHECK_GL_ERROR();
|
||||
while(1);;
|
||||
}
|
||||
printf("%s linked successful\n",name.c_str());
|
||||
CHECK_GL_ERROR();
|
||||
}
|
||||
void setUniformMatrix4fv(char* varname, GLsizei count, GLboolean transpose, GLfloat *value)
|
||||
{
|
||||
GLint loc = glGetUniformLocation(program_handle,varname);
|
||||
if (loc==-1)
|
||||
{
|
||||
printf("Variable \"%s\" in shader \"%s\" not found\n",varname,name.c_str());
|
||||
while(1);;
|
||||
};
|
||||
glUniformMatrix4fv(loc, count, transpose, value);
|
||||
CHECK_GL_ERROR();
|
||||
}
|
||||
void begin(void)
|
||||
{
|
||||
glUseProgram(program_handle);
|
||||
CHECK_GL_ERROR();
|
||||
}
|
||||
void end(void)
|
||||
{
|
||||
glUseProgram(0);
|
||||
CHECK_GL_ERROR();
|
||||
}
|
||||
private:
|
||||
std::vector<GLuint> handles;
|
||||
GLuint program_handle;
|
||||
std::string name;
|
||||
|
||||
char* read_file(char* name)
|
||||
{
|
||||
FILE * fp = fopen (name, "rb");
|
||||
|
||||
if (fp==0)
|
||||
{
|
||||
printf ("File %s NOT FOUND\n");
|
||||
while(1);;
|
||||
}
|
||||
fseek(fp, 0L, SEEK_END);
|
||||
int fsize = ftell(fp);
|
||||
fseek(fp, 0L, SEEK_SET);
|
||||
char* mem=(char*)malloc(fsize+1);
|
||||
for(int i=0;i<fsize+1;i++)mem[i]=0;
|
||||
fread (mem, 1, fsize, fp);
|
||||
fclose (fp);
|
||||
return mem;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user