| @@ -72,5 +72,6 @@ test/xolotl/xolotl | |||
| tools/make-font | |||
| tutorial/01_triangle | |||
| tutorial/02_cube | |||
| tutorial/08_fbo | |||
| tutorial/11_fractal | |||
| # Our data | |||
| @@ -86,6 +86,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ToukyDemo", "..\..\games\To | |||
| EndProject | |||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BtPhysTest", "..\..\test\BtPhysTest.vcxproj", "{EE203B88-44CF-4859-9D42-7A1F43FECB52}" | |||
| EndProject | |||
| Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "08_fbo", "..\..\tutorial\08_fbo.vcxproj", "{BCEE0132-8E24-49BE-AFEB-96DAD14396BA}" | |||
| EndProject | |||
| Global | |||
| GlobalSection(SolutionConfigurationPlatforms) = preSolution | |||
| Debug|PS3 = Debug|PS3 | |||
| @@ -354,6 +356,24 @@ Global | |||
| {EE203B88-44CF-4859-9D42-7A1F43FECB52}.Release|Xbox 360.ActiveCfg = Release|Xbox 360 | |||
| {EE203B88-44CF-4859-9D42-7A1F43FECB52}.Release|Xbox 360.Build.0 = Release|Xbox 360 | |||
| {EE203B88-44CF-4859-9D42-7A1F43FECB52}.Release|Xbox 360.Deploy.0 = Release|Xbox 360 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Debug|PS3.ActiveCfg = Debug|PS3 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Debug|PS3.Build.0 = Debug|PS3 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Debug|Win32.ActiveCfg = Debug|Win32 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Debug|Win32.Build.0 = Debug|Win32 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Debug|x64.ActiveCfg = Debug|x64 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Debug|x64.Build.0 = Debug|x64 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Debug|Xbox 360.ActiveCfg = Debug|Xbox 360 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Debug|Xbox 360.Build.0 = Debug|Xbox 360 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Debug|Xbox 360.Deploy.0 = Debug|Xbox 360 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Release|PS3.ActiveCfg = Release|PS3 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Release|PS3.Build.0 = Release|PS3 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Release|Win32.ActiveCfg = Release|Win32 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Release|Win32.Build.0 = Release|Win32 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Release|x64.ActiveCfg = Release|x64 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Release|x64.Build.0 = Release|x64 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Release|Xbox 360.ActiveCfg = Release|Xbox 360 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Release|Xbox 360.Build.0 = Release|Xbox 360 | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA}.Release|Xbox 360.Deploy.0 = Release|Xbox 360 | |||
| EndGlobalSection | |||
| GlobalSection(SolutionProperties) = preSolution | |||
| HideSolutionNode = FALSE | |||
| @@ -375,6 +395,7 @@ Global | |||
| {B92ABADC-45BE-4CC5-B724-9426053123A1} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| {7B083DA2-FE08-4F6D-BFDD-195D5C2783EB} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| {6BF81B39-EDC2-4227-9992-C2D8ABEA95AF} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| {BCEE0132-8E24-49BE-AFEB-96DAD14396BA} = {E74CF679-CA2A-47E9-B1F4-3779D6AC6B04} | |||
| {32F3F8CF-D22E-45E4-BEB8-AD909E8C5515} = {33704AA4-F2B5-4138-A40D-E3E77F89ED46} | |||
| {EE203B88-44CF-4859-9D42-7A5F40FECB52} = {8C77EAA8-1077-4EF7-AE53-97C6C60A3601} | |||
| {B357514A-7881-422D-8358-161B689E7620} = {3D341D8A-E400-4B1D-BC05-B5C35487D9B5} | |||
| @@ -0,0 +1,109 @@ | |||
| // | |||
| // Lol Engine - Framebuffer Object tutorial | |||
| // | |||
| // Copyright: (c) 2012 Sam Hocevar <sam@hocevar.net> | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License, Version 2, as published by Sam Hocevar. See | |||
| // http://sam.zoy.org/projects/COPYING.WTFPL for more details. | |||
| // | |||
| #if defined HAVE_CONFIG_H | |||
| # include "config.h" | |||
| #endif | |||
| #include "core.h" | |||
| #include "loldebug.h" | |||
| using namespace std; | |||
| using namespace lol; | |||
| #if USE_SDL && defined __APPLE__ | |||
| # include <SDL_main.h> | |||
| #endif | |||
| #if defined _WIN32 | |||
| # undef main /* FIXME: still needed? */ | |||
| # include <direct.h> | |||
| #endif | |||
| extern char const *lolfx_08_fbo; | |||
| class FBO : public WorldEntity | |||
| { | |||
| public: | |||
| FBO() | |||
| { | |||
| m_vertices << vec2( 0.0, 0.8); | |||
| m_vertices << vec2(-0.8, -0.8); | |||
| m_vertices << vec2( 0.8, -0.8); | |||
| m_ready = false; | |||
| } | |||
| virtual void TickDraw(float seconds) | |||
| { | |||
| WorldEntity::TickDraw(seconds); | |||
| if (!m_ready) | |||
| { | |||
| m_shader = Shader::Create(lolfx_08_fbo); | |||
| m_coord = m_shader->GetAttribLocation("in_Position", VertexUsage::Position, 0); | |||
| m_vdecl = new VertexDeclaration(VertexStream<vec2>(VertexUsage::Position)); | |||
| m_vbo = new VertexBuffer(m_vertices.Bytes()); | |||
| void *vertices = m_vbo->Lock(0, 0); | |||
| memcpy(vertices, &m_vertices[0], m_vertices.Bytes()); | |||
| m_vbo->Unlock(); | |||
| m_fbo = new FrameBuffer(Video::GetSize()); | |||
| m_ready = true; | |||
| /* FIXME: this object never cleans up */ | |||
| } | |||
| m_fbo->Bind(); | |||
| m_shader->Bind(); | |||
| m_vdecl->SetStream(m_vbo, m_coord); | |||
| m_vdecl->Bind(); | |||
| m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 1); | |||
| m_vdecl->Unbind(); | |||
| m_shader->Unbind(); | |||
| m_fbo->Unbind(); | |||
| m_shader->Bind(); | |||
| m_vdecl->SetStream(m_vbo, m_coord); | |||
| m_vdecl->Bind(); | |||
| m_vdecl->DrawElements(MeshPrimitive::Triangles, 0, 1); | |||
| m_vdecl->Unbind(); | |||
| m_shader->Unbind(); | |||
| } | |||
| private: | |||
| Array<vec2> m_vertices; | |||
| Shader *m_shader; | |||
| ShaderAttrib m_coord; | |||
| VertexDeclaration *m_vdecl; | |||
| VertexBuffer *m_vbo; | |||
| FrameBuffer *m_fbo; | |||
| bool m_ready; | |||
| }; | |||
| int main(int argc, char **argv) | |||
| { | |||
| Application app("Tutorial 08: Framebuffer Object", ivec2(640, 480), 60.0f); | |||
| #if defined _MSC_VER && !defined _XBOX | |||
| _chdir(".."); | |||
| #elif defined _WIN32 && !defined _XBOX | |||
| _chdir("../.."); | |||
| #endif | |||
| new DebugFps(5, 5); | |||
| new FBO(); | |||
| app.Run(); | |||
| return EXIT_SUCCESS; | |||
| } | |||
| @@ -0,0 +1,36 @@ | |||
| -- GLSL.Vert -- | |||
| #version 120 | |||
| void main() | |||
| { | |||
| gl_Position = gl_Vertex; | |||
| gl_TexCoord[0] = gl_MultiTexCoord0; | |||
| } | |||
| -- GLSL.Frag -- | |||
| #version 120 | |||
| uniform sampler2D texture; | |||
| void main(void) | |||
| { | |||
| gl_FragColor = vec4(texture2D(texture, gl_TexCoord[0].xy).xyz, 1.0); | |||
| } | |||
| -- HLSL.Vert -- | |||
| void main(float2 in_Position : POSITION, | |||
| out float4 out_Position : POSITION) | |||
| { | |||
| out_Position = float4(in_Position, 0.0, 1.0); | |||
| } | |||
| -- HLSL.Frag -- | |||
| void main(out float4 out_FragColor : COLOR) | |||
| { | |||
| out_FragColor = float4(0.7, 0.2, 0.5, 1.0); | |||
| } | |||
| @@ -0,0 +1,68 @@ | |||
| <?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|PS3"> | |||
| <Configuration>Debug</Configuration> | |||
| <Platform>PS3</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Debug|Win32"> | |||
| <Configuration>Debug</Configuration> | |||
| <Platform>Win32</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Debug|x64"> | |||
| <Configuration>Debug</Configuration> | |||
| <Platform>x64</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Debug|Xbox 360"> | |||
| <Configuration>Debug</Configuration> | |||
| <Platform>Xbox 360</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Release|PS3"> | |||
| <Configuration>Release</Configuration> | |||
| <Platform>PS3</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Release|Win32"> | |||
| <Configuration>Release</Configuration> | |||
| <Platform>Win32</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Release|x64"> | |||
| <Configuration>Release</Configuration> | |||
| <Platform>x64</Platform> | |||
| </ProjectConfiguration> | |||
| <ProjectConfiguration Include="Release|Xbox 360"> | |||
| <Configuration>Release</Configuration> | |||
| <Platform>Xbox 360</Platform> | |||
| </ProjectConfiguration> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ClCompile Include="08_fbo.cpp" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <LolFxCompile Include="08_fbo.lolfx" /> | |||
| </ItemGroup> | |||
| <ItemGroup> | |||
| <ProjectReference Include="$(SolutionDir)\..\..\src\lolcore.vcxproj"> | |||
| <Project>{9e62f2fe-3408-4eae-8238-fd84238ceeda}</Project> | |||
| </ProjectReference> | |||
| </ItemGroup> | |||
| <PropertyGroup Label="Globals"> | |||
| <ProjectGuid>{BCEE0132-8E24-49BE-AFEB-96DAD14396BA}</ProjectGuid> | |||
| <ConfigurationType>Application</ConfigurationType> | |||
| <Keyword>Win32Proj</Keyword> | |||
| </PropertyGroup> | |||
| <Import Project="$(SolutionDir)\Lol.Core.Config.props" /> | |||
| <ImportGroup Label="ExtensionSettings"> | |||
| <Import Project="$(SolutionDir)\Lol.Fx.props" /> | |||
| </ImportGroup> | |||
| <ImportGroup Label="PropertySheets"> | |||
| <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> | |||
| <Import Project="$(SolutionDir)\Lol.Core.Vars.props" /> | |||
| </ImportGroup> | |||
| <PropertyGroup Label="UserMacros" /> | |||
| <Import Project="$(SolutionDir)\Lol.Core.Rules.props" /> | |||
| <ItemDefinitionGroup /> | |||
| <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> | |||
| <ImportGroup Label="ExtensionTargets"> | |||
| <Import Project="$(SolutionDir)\Lol.Fx.targets" /> | |||
| </ImportGroup> | |||
| </Project> | |||
| @@ -14,7 +14,7 @@ SUFFIXES = .lolfx | |||
| .lolfx.o: | |||
| $(LOLFX_BUILD) | |||
| noinst_PROGRAMS = 01_triangle 02_cube 11_fractal | |||
| noinst_PROGRAMS = 01_triangle 02_cube 08_fbo 11_fractal | |||
| 01_triangle_SOURCES = 01_triangle.cpp 01_triangle.lolfx | |||
| 01_triangle_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ | |||
| @@ -26,6 +26,11 @@ noinst_PROGRAMS = 01_triangle 02_cube 11_fractal | |||
| 02_cube_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ | |||
| 02_cube_DEPENDENCIES = $(top_builddir)/src/liblol.a | |||
| 08_fbo_SOURCES = 08_fbo.cpp 08_fbo.lolfx | |||
| 08_fbo_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ | |||
| 08_fbo_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ | |||
| 08_fbo_DEPENDENCIES = $(top_builddir)/src/liblol.a | |||
| 11_fractal_SOURCES = 11_fractal.cpp 11_fractal.lolfx | |||
| 11_fractal_CPPFLAGS = @LOL_CFLAGS@ @PIPI_CFLAGS@ | |||
| 11_fractal_LDFLAGS = $(top_builddir)/src/liblol.a @LOL_LIBS@ @PIPI_LIBS@ | |||