conworlds
changeset 15:9b0db7dbde6e
hmmm doesn't work properly yes
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 24 Aug 2014 14:36:00 +0300 |
parents | 423d4e6728cb |
children | 7a2041ddb7e7 e4257df067a1 |
files | conworlds.vcxproj conworlds.vcxproj.filters src/game.cc |
diffstat | 3 files changed, 184 insertions(+), 25 deletions(-) [+] |
line diff
1.1 --- a/conworlds.vcxproj Sun Aug 24 09:43:58 2014 +0300 1.2 +++ b/conworlds.vcxproj Sun Aug 24 14:36:00 2014 +0300 1.3 @@ -58,7 +58,7 @@ 1.4 <Link> 1.5 <SubSystem>Console</SubSystem> 1.6 <GenerateDebugInformation>true</GenerateDebugInformation> 1.7 - <AdditionalDependencies>opengl32.lib;freeglutd.lib;glew32.lib;libvmath.lib;libimago2.lib;jpeglib.lib;libpng.lib;zlib.lib;libovrd.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> 1.8 + <AdditionalDependencies>opengl32.lib;freeglutd.lib;glew32.lib;libvmath.lib;libanim.lib;libimago2.lib;jpeglib.lib;libpng.lib;zlib.lib;libovrd.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> 1.9 </Link> 1.10 </ItemDefinitionGroup> 1.11 <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> 1.12 @@ -78,17 +78,28 @@ 1.13 <GenerateDebugInformation>true</GenerateDebugInformation> 1.14 <EnableCOMDATFolding>true</EnableCOMDATFolding> 1.15 <OptimizeReferences>true</OptimizeReferences> 1.16 - <AdditionalDependencies>opengl32.lib;freeglut.lib;glew32.lib;libvmath.lib;libimago2.lib;jpeglib.lib;libpng.lib;zlib.lib;libovr.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> 1.17 + <AdditionalDependencies>opengl32.lib;freeglut.lib;glew32.lib;libvmath.lib;libanim.lib;libimago2.lib;jpeglib.lib;libpng.lib;zlib.lib;libovr.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> 1.18 </Link> 1.19 </ItemDefinitionGroup> 1.20 <ItemGroup> 1.21 + <ClCompile Include="src\assload.cc" /> 1.22 <ClCompile Include="src\camera.cc" /> 1.23 <ClCompile Include="src\game.cc" /> 1.24 + <ClCompile Include="src\gameopt.cc" /> 1.25 + <ClCompile Include="src\geom.cc" /> 1.26 <ClCompile Include="src\image.cc" /> 1.27 + <ClCompile Include="src\light.cc" /> 1.28 + <ClCompile Include="src\logger.cc" /> 1.29 <ClCompile Include="src\main.cc" /> 1.30 + <ClCompile Include="src\material.cc" /> 1.31 + <ClCompile Include="src\mesh.cc" /> 1.32 + <ClCompile Include="src\object.cc" /> 1.33 <ClCompile Include="src\opengl.cc" /> 1.34 + <ClCompile Include="src\scene.cc" /> 1.35 <ClCompile Include="src\sdr.c" /> 1.36 + <ClCompile Include="src\shader.cc" /> 1.37 <ClCompile Include="src\texture.cc" /> 1.38 + <ClCompile Include="src\unistate.cc" /> 1.39 <ClCompile Include="src\vr\mathutil.c" /> 1.40 <ClCompile Include="src\vr\opt.c" /> 1.41 <ClCompile Include="src\vr\rbtree.c" /> 1.42 @@ -97,21 +108,38 @@ 1.43 <ClCompile Include="src\vr\vr_modules.c" /> 1.44 <ClCompile Include="src\vr\vr_null.c" /> 1.45 <ClCompile Include="src\vr\vr_openhmd.c" /> 1.46 + <ClCompile Include="src\xform_node.cc" /> 1.47 </ItemGroup> 1.48 <ItemGroup> 1.49 + <ClInclude Include="src\assload.h" /> 1.50 <ClInclude Include="src\camera.h" /> 1.51 + <ClInclude Include="src\dataset.h" /> 1.52 <ClInclude Include="src\game.h" /> 1.53 + <ClInclude Include="src\gameopt.h" /> 1.54 + <ClInclude Include="src\geom.h" /> 1.55 <ClInclude Include="src\image.h" /> 1.56 + <ClInclude Include="src\light.h" /> 1.57 + <ClInclude Include="src\logger.h" /> 1.58 + <ClInclude Include="src\material.h" /> 1.59 + <ClInclude Include="src\mesh.h" /> 1.60 + <ClInclude Include="src\object.h" /> 1.61 <ClInclude Include="src\opengl.h" /> 1.62 + <ClInclude Include="src\scene.h" /> 1.63 <ClInclude Include="src\sdr.h" /> 1.64 + <ClInclude Include="src\shader.h" /> 1.65 <ClInclude Include="src\texture.h" /> 1.66 + <ClInclude Include="src\unistate.h" /> 1.67 <ClInclude Include="src\vr\mathutil.h" /> 1.68 <ClInclude Include="src\vr\opt.h" /> 1.69 <ClInclude Include="src\vr\rbtree.h" /> 1.70 <ClInclude Include="src\vr\vr.h" /> 1.71 <ClInclude Include="src\vr\vr_impl.h" /> 1.72 + <ClInclude Include="src\xform_node.h" /> 1.73 + </ItemGroup> 1.74 + <ItemGroup> 1.75 + <None Include="src\dataset.inl" /> 1.76 </ItemGroup> 1.77 <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> 1.78 <ImportGroup Label="ExtensionTargets"> 1.79 </ImportGroup> 1.80 -</Project> 1.81 +</Project> 1.82 \ No newline at end of file
2.1 --- a/conworlds.vcxproj.filters Sun Aug 24 09:43:58 2014 +0300 2.2 +++ b/conworlds.vcxproj.filters Sun Aug 24 14:36:00 2014 +0300 2.3 @@ -55,6 +55,42 @@ 2.4 <ClCompile Include="src\vr\mathutil.c"> 2.5 <Filter>src\vr</Filter> 2.6 </ClCompile> 2.7 + <ClCompile Include="src\assload.cc"> 2.8 + <Filter>src</Filter> 2.9 + </ClCompile> 2.10 + <ClCompile Include="src\gameopt.cc"> 2.11 + <Filter>src</Filter> 2.12 + </ClCompile> 2.13 + <ClCompile Include="src\geom.cc"> 2.14 + <Filter>src</Filter> 2.15 + </ClCompile> 2.16 + <ClCompile Include="src\light.cc"> 2.17 + <Filter>src</Filter> 2.18 + </ClCompile> 2.19 + <ClCompile Include="src\logger.cc"> 2.20 + <Filter>src</Filter> 2.21 + </ClCompile> 2.22 + <ClCompile Include="src\material.cc"> 2.23 + <Filter>src</Filter> 2.24 + </ClCompile> 2.25 + <ClCompile Include="src\mesh.cc"> 2.26 + <Filter>src</Filter> 2.27 + </ClCompile> 2.28 + <ClCompile Include="src\object.cc"> 2.29 + <Filter>src</Filter> 2.30 + </ClCompile> 2.31 + <ClCompile Include="src\scene.cc"> 2.32 + <Filter>src</Filter> 2.33 + </ClCompile> 2.34 + <ClCompile Include="src\shader.cc"> 2.35 + <Filter>src</Filter> 2.36 + </ClCompile> 2.37 + <ClCompile Include="src\unistate.cc"> 2.38 + <Filter>src</Filter> 2.39 + </ClCompile> 2.40 + <ClCompile Include="src\xform_node.cc"> 2.41 + <Filter>src</Filter> 2.42 + </ClCompile> 2.43 </ItemGroup> 2.44 <ItemGroup> 2.45 <ClInclude Include="src\camera.h"> 2.46 @@ -90,5 +126,49 @@ 2.47 <ClInclude Include="src\vr\mathutil.h"> 2.48 <Filter>src\vr</Filter> 2.49 </ClInclude> 2.50 + <ClInclude Include="src\assload.h"> 2.51 + <Filter>src</Filter> 2.52 + </ClInclude> 2.53 + <ClInclude Include="src\dataset.h"> 2.54 + <Filter>src</Filter> 2.55 + </ClInclude> 2.56 + <ClInclude Include="src\gameopt.h"> 2.57 + <Filter>src</Filter> 2.58 + </ClInclude> 2.59 + <ClInclude Include="src\geom.h"> 2.60 + <Filter>src</Filter> 2.61 + </ClInclude> 2.62 + <ClInclude Include="src\light.h"> 2.63 + <Filter>src</Filter> 2.64 + </ClInclude> 2.65 + <ClInclude Include="src\logger.h"> 2.66 + <Filter>src</Filter> 2.67 + </ClInclude> 2.68 + <ClInclude Include="src\material.h"> 2.69 + <Filter>src</Filter> 2.70 + </ClInclude> 2.71 + <ClInclude Include="src\mesh.h"> 2.72 + <Filter>src</Filter> 2.73 + </ClInclude> 2.74 + <ClInclude Include="src\object.h"> 2.75 + <Filter>src</Filter> 2.76 + </ClInclude> 2.77 + <ClInclude Include="src\scene.h"> 2.78 + <Filter>src</Filter> 2.79 + </ClInclude> 2.80 + <ClInclude Include="src\shader.h"> 2.81 + <Filter>src</Filter> 2.82 + </ClInclude> 2.83 + <ClInclude Include="src\unistate.h"> 2.84 + <Filter>src</Filter> 2.85 + </ClInclude> 2.86 + <ClInclude Include="src\xform_node.h"> 2.87 + <Filter>src</Filter> 2.88 + </ClInclude> 2.89 + </ItemGroup> 2.90 + <ItemGroup> 2.91 + <None Include="src\dataset.inl"> 2.92 + <Filter>src</Filter> 2.93 + </None> 2.94 </ItemGroup> 2.95 </Project> 2.96 \ No newline at end of file
3.1 --- a/src/game.cc Sun Aug 24 09:43:58 2014 +0300 3.2 +++ b/src/game.cc Sun Aug 24 14:36:00 2014 +0300 3.3 @@ -1,3 +1,4 @@ 3.4 +#include <math.h> 3.5 #include "game.h" 3.6 #include "gameopt.h" 3.7 #include "opengl.h" 3.8 @@ -8,6 +9,9 @@ 3.9 static void game_render_eye(int eye); 3.10 static void draw_scene(); 3.11 static bool setup_rtarg(int x, int y); 3.12 +static void draw_box(float sz); 3.13 +static void draw_pyramid(float basesz, float height); 3.14 + 3.15 3.16 static Texture *rtarg; 3.17 static unsigned int fbo, rtarg_depth; 3.18 @@ -143,9 +147,11 @@ 3.19 if(eye == 0 || !vr_view_matrix(eye < 0 ? 0 : 1, mat)) { 3.20 glLoadIdentity(); 3.21 } else { 3.22 - glLoadMatrixf(mat); 3.23 + glLoadIdentity(); 3.24 + //glLoadMatrixf(mat); 3.25 } 3.26 glMultTransposeMatrixf(view_matrix[0]); 3.27 + glMultMatrixf(mat); 3.28 3.29 draw_scene(); 3.30 } 3.31 @@ -258,27 +264,7 @@ 3.32 for(int i=0; i<4; i++) { 3.33 glPushMatrix(); 3.34 glTranslatef(i & 1 ? -10 : 10, 0, i & 2 ? -10 : 10); 3.35 - glScalef(2.0, 2.0, 2.0); 3.36 - 3.37 - glBegin(GL_TRIANGLES); 3.38 - glNormal3f(0, 1, 1); 3.39 - glVertex3f(-1, 0, 1); 3.40 - glVertex3f(1, 0, 1); 3.41 - glVertex3f(0, 1.75, 0); 3.42 - glNormal3f(1, 1, 0); 3.43 - glVertex3f(1, 0, 1); 3.44 - glVertex3f(1, 0, -1); 3.45 - glVertex3f(0, 1.75, 0); 3.46 - glNormal3f(0, 1, -1); 3.47 - glVertex3f(1, 0, -1); 3.48 - glVertex3f(-1, 0, -1); 3.49 - glVertex3f(0, 1.75, 0); 3.50 - glNormal3f(-1, 1, 0); 3.51 - glVertex3f(-1, 0, -1); 3.52 - glVertex3f(-1, 0, 1); 3.53 - glVertex3f(0, 1.75, 0); 3.54 - glEnd(); 3.55 - 3.56 + draw_pyramid(2.0, 2.0); 3.57 glPopMatrix(); 3.58 } 3.59 } 3.60 @@ -314,3 +300,68 @@ 3.61 printf("created render target %dx%d (texture: %dx%d)\n", x, y, tex_width, tex_height); 3.62 return true; 3.63 } 3.64 + 3.65 +static void draw_box(float sz) 3.66 +{ 3.67 + float hsz = sz / 2.0; 3.68 + 3.69 + glBegin(GL_QUADS); 3.70 + glNormal3f(0, 0, 1); 3.71 + glVertex3f(-hsz, -hsz, hsz); 3.72 + glVertex3f(hsz, -hsz, hsz); 3.73 + glVertex3f(hsz, hsz, hsz); 3.74 + glVertex3f(-hsz, hsz, hsz); 3.75 + glNormal3f(1, 0, 0); 3.76 + glVertex3f(hsz, -hsz, hsz); 3.77 + glVertex3f(hsz, -hsz, -hsz); 3.78 + glVertex3f(hsz, hsz, -hsz); 3.79 + glVertex3f(hsz, hsz, hsz); 3.80 + glNormal3f(0, 0, -1); 3.81 + glVertex3f(hsz, -hsz, -hsz); 3.82 + glVertex3f(-hsz, -hsz, -hsz); 3.83 + glVertex3f(-hsz, hsz, -hsz); 3.84 + glVertex3f(hsz, hsz, -hsz); 3.85 + glNormal3f(-1, 0, 0); 3.86 + glVertex3f(-hsz, -hsz, -hsz); 3.87 + glVertex3f(-hsz, -hsz, hsz); 3.88 + glVertex3f(-hsz, hsz, hsz); 3.89 + glVertex3f(-hsz, hsz, -hsz); 3.90 + glNormal3f(0, 1, 0); 3.91 + glVertex3f(-hsz, hsz, hsz); 3.92 + glVertex3f(hsz, hsz, hsz); 3.93 + glVertex3f(hsz, hsz, -hsz); 3.94 + glVertex3f(-hsz, hsz, -hsz); 3.95 + glNormal3f(0, -1, 0); 3.96 + glVertex3f(-hsz, -hsz, -hsz); 3.97 + glVertex3f(hsz, -hsz, -hsz); 3.98 + glVertex3f(hsz, -hsz, hsz); 3.99 + glVertex3f(-hsz, -hsz, hsz); 3.100 + glEnd(); 3.101 +} 3.102 + 3.103 +static void draw_pyramid(float basesz, float height) 3.104 +{ 3.105 + float hsz = basesz / 2.0; 3.106 + float theta = atan(hsz / height); 3.107 + float nx = cos(theta); 3.108 + float ny = sin(theta); 3.109 + 3.110 + glBegin(GL_TRIANGLES); 3.111 + glNormal3f(0, ny, nx); 3.112 + glVertex3f(-hsz, 0, hsz); 3.113 + glVertex3f(hsz, 0, hsz); 3.114 + glVertex3f(0, height, 0); 3.115 + glNormal3f(nx, ny, 0); 3.116 + glVertex3f(hsz, 0, hsz); 3.117 + glVertex3f(hsz, 0, -hsz); 3.118 + glVertex3f(0, height, 0); 3.119 + glNormal3f(0, ny, -nx); 3.120 + glVertex3f(hsz, 0, -hsz); 3.121 + glVertex3f(-hsz, 0, -hsz); 3.122 + glVertex3f(0, height, 0); 3.123 + glNormal3f(-nx, ny, 0); 3.124 + glVertex3f(-hsz, 0, -hsz); 3.125 + glVertex3f(-hsz, 0, hsz); 3.126 + glVertex3f(0, height, 0); 3.127 + glEnd(); 3.128 +} 3.129 \ No newline at end of file