oculus1
changeset 25:9dc19419f52b
merged
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Fri, 04 Oct 2013 14:50:50 +0300 |
parents | 8419d8a13cee ef4c9d8eeca7 |
children | 75ab0d4ce2bb |
files | src/main.cc |
diffstat | 4 files changed, 813 insertions(+), 43 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/oculus1.sln Fri Oct 04 14:50:50 2013 +0300 1.3 @@ -0,0 +1,20 @@ 1.4 + 1.5 +Microsoft Visual Studio Solution File, Format Version 10.00 1.6 +# Visual Studio 2008 1.7 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "oculus1", "oculus1.vcproj", "{BF4DEBD4-BA07-4DEF-82A7-ACAF8F20110B}" 1.8 +EndProject 1.9 +Global 1.10 + GlobalSection(SolutionConfigurationPlatforms) = preSolution 1.11 + Debug|Win32 = Debug|Win32 1.12 + Release|Win32 = Release|Win32 1.13 + EndGlobalSection 1.14 + GlobalSection(ProjectConfigurationPlatforms) = postSolution 1.15 + {BF4DEBD4-BA07-4DEF-82A7-ACAF8F20110B}.Debug|Win32.ActiveCfg = Debug|Win32 1.16 + {BF4DEBD4-BA07-4DEF-82A7-ACAF8F20110B}.Debug|Win32.Build.0 = Debug|Win32 1.17 + {BF4DEBD4-BA07-4DEF-82A7-ACAF8F20110B}.Release|Win32.ActiveCfg = Release|Win32 1.18 + {BF4DEBD4-BA07-4DEF-82A7-ACAF8F20110B}.Release|Win32.Build.0 = Release|Win32 1.19 + EndGlobalSection 1.20 + GlobalSection(SolutionProperties) = preSolution 1.21 + HideSolutionNode = FALSE 1.22 + EndGlobalSection 1.23 +EndGlobal
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/oculus1.vcproj Fri Oct 04 14:50:50 2013 +0300 2.3 @@ -0,0 +1,575 @@ 2.4 +<?xml version="1.0" encoding="Windows-1252"?> 2.5 +<VisualStudioProject 2.6 + ProjectType="Visual C++" 2.7 + Version="9.00" 2.8 + Name="oculus1" 2.9 + ProjectGUID="{BF4DEBD4-BA07-4DEF-82A7-ACAF8F20110B}" 2.10 + RootNamespace="oculus1" 2.11 + Keyword="Win32Proj" 2.12 + TargetFrameworkVersion="196613" 2.13 + > 2.14 + <Platforms> 2.15 + <Platform 2.16 + Name="Win32" 2.17 + /> 2.18 + </Platforms> 2.19 + <ToolFiles> 2.20 + </ToolFiles> 2.21 + <Configurations> 2.22 + <Configuration 2.23 + Name="Debug|Win32" 2.24 + OutputDirectory="$(SolutionDir)$(ConfigurationName)" 2.25 + IntermediateDirectory="$(ConfigurationName)" 2.26 + ConfigurationType="1" 2.27 + CharacterSet="1" 2.28 + > 2.29 + <Tool 2.30 + Name="VCPreBuildEventTool" 2.31 + /> 2.32 + <Tool 2.33 + Name="VCCustomBuildTool" 2.34 + /> 2.35 + <Tool 2.36 + Name="VCXMLDataGeneratorTool" 2.37 + /> 2.38 + <Tool 2.39 + Name="VCWebServiceProxyGeneratorTool" 2.40 + /> 2.41 + <Tool 2.42 + Name="VCMIDLTool" 2.43 + /> 2.44 + <Tool 2.45 + Name="VCCLCompilerTool" 2.46 + Optimization="0" 2.47 + AdditionalIncludeDirectories=""$(SolutionDir)\libovr\Include";"$(SolutionDir)\libovr\Src";"$(SolutionDir)\libovr\Src\Kernel";"$(SolutionDir)\libovr\Src\Util"" 2.48 + PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_USE_MATH_DEFINES" 2.49 + MinimalRebuild="true" 2.50 + BasicRuntimeChecks="3" 2.51 + RuntimeLibrary="3" 2.52 + UsePrecompiledHeader="0" 2.53 + WarningLevel="3" 2.54 + DebugInformationFormat="4" 2.55 + DisableSpecificWarnings="4244;4305;4996" 2.56 + /> 2.57 + <Tool 2.58 + Name="VCManagedResourceCompilerTool" 2.59 + /> 2.60 + <Tool 2.61 + Name="VCResourceCompilerTool" 2.62 + /> 2.63 + <Tool 2.64 + Name="VCPreLinkEventTool" 2.65 + /> 2.66 + <Tool 2.67 + Name="VCLinkerTool" 2.68 + AdditionalDependencies="opengl32.lib glut32.lib glew32.lib libvmath.lib setupapi.lib" 2.69 + LinkIncremental="2" 2.70 + GenerateDebugInformation="true" 2.71 + SubSystem="1" 2.72 + TargetMachine="1" 2.73 + /> 2.74 + <Tool 2.75 + Name="VCALinkTool" 2.76 + /> 2.77 + <Tool 2.78 + Name="VCManifestTool" 2.79 + /> 2.80 + <Tool 2.81 + Name="VCXDCMakeTool" 2.82 + /> 2.83 + <Tool 2.84 + Name="VCBscMakeTool" 2.85 + /> 2.86 + <Tool 2.87 + Name="VCFxCopTool" 2.88 + /> 2.89 + <Tool 2.90 + Name="VCAppVerifierTool" 2.91 + /> 2.92 + <Tool 2.93 + Name="VCPostBuildEventTool" 2.94 + /> 2.95 + </Configuration> 2.96 + <Configuration 2.97 + Name="Release|Win32" 2.98 + OutputDirectory="$(SolutionDir)$(ConfigurationName)" 2.99 + IntermediateDirectory="$(ConfigurationName)" 2.100 + ConfigurationType="1" 2.101 + CharacterSet="1" 2.102 + WholeProgramOptimization="1" 2.103 + > 2.104 + <Tool 2.105 + Name="VCPreBuildEventTool" 2.106 + /> 2.107 + <Tool 2.108 + Name="VCCustomBuildTool" 2.109 + /> 2.110 + <Tool 2.111 + Name="VCXMLDataGeneratorTool" 2.112 + /> 2.113 + <Tool 2.114 + Name="VCWebServiceProxyGeneratorTool" 2.115 + /> 2.116 + <Tool 2.117 + Name="VCMIDLTool" 2.118 + /> 2.119 + <Tool 2.120 + Name="VCCLCompilerTool" 2.121 + Optimization="2" 2.122 + EnableIntrinsicFunctions="true" 2.123 + AdditionalIncludeDirectories=""$(SolutionDir)\libovr\Include";"$(SolutionDir)\libovr\Src";"$(SolutionDir)\libovr\Src\Kernel";"$(SolutionDir)\libovr\Src\Util"" 2.124 + PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_USE_MATH_DEFINES" 2.125 + RuntimeLibrary="2" 2.126 + EnableFunctionLevelLinking="true" 2.127 + UsePrecompiledHeader="0" 2.128 + WarningLevel="3" 2.129 + DebugInformationFormat="3" 2.130 + DisableSpecificWarnings="4244;4305;4996" 2.131 + /> 2.132 + <Tool 2.133 + Name="VCManagedResourceCompilerTool" 2.134 + /> 2.135 + <Tool 2.136 + Name="VCResourceCompilerTool" 2.137 + /> 2.138 + <Tool 2.139 + Name="VCPreLinkEventTool" 2.140 + /> 2.141 + <Tool 2.142 + Name="VCLinkerTool" 2.143 + AdditionalDependencies="opengl32.lib glut32.lib glew32.lib libvmath.lib setupapi.lib" 2.144 + LinkIncremental="1" 2.145 + GenerateDebugInformation="true" 2.146 + SubSystem="1" 2.147 + OptimizeReferences="2" 2.148 + EnableCOMDATFolding="2" 2.149 + TargetMachine="1" 2.150 + /> 2.151 + <Tool 2.152 + Name="VCALinkTool" 2.153 + /> 2.154 + <Tool 2.155 + Name="VCManifestTool" 2.156 + /> 2.157 + <Tool 2.158 + Name="VCXDCMakeTool" 2.159 + /> 2.160 + <Tool 2.161 + Name="VCBscMakeTool" 2.162 + /> 2.163 + <Tool 2.164 + Name="VCFxCopTool" 2.165 + /> 2.166 + <Tool 2.167 + Name="VCAppVerifierTool" 2.168 + /> 2.169 + <Tool 2.170 + Name="VCPostBuildEventTool" 2.171 + /> 2.172 + </Configuration> 2.173 + </Configurations> 2.174 + <References> 2.175 + </References> 2.176 + <Files> 2.177 + <Filter 2.178 + Name="src" 2.179 + Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx" 2.180 + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" 2.181 + > 2.182 + <File 2.183 + RelativePath=".\src\camera.cc" 2.184 + > 2.185 + </File> 2.186 + <File 2.187 + RelativePath=".\src\camera.h" 2.188 + > 2.189 + </File> 2.190 + <File 2.191 + RelativePath=".\src\main.cc" 2.192 + > 2.193 + </File> 2.194 + <File 2.195 + RelativePath=".\src\opengl.cc" 2.196 + > 2.197 + </File> 2.198 + <File 2.199 + RelativePath=".\src\opengl.h" 2.200 + > 2.201 + </File> 2.202 + <File 2.203 + RelativePath=".\src\sdr.c" 2.204 + > 2.205 + </File> 2.206 + <File 2.207 + RelativePath=".\src\sdr.h" 2.208 + > 2.209 + </File> 2.210 + <File 2.211 + RelativePath=".\src\vr.cc" 2.212 + > 2.213 + </File> 2.214 + <File 2.215 + RelativePath=".\src\vr.h" 2.216 + > 2.217 + </File> 2.218 + <File 2.219 + RelativePath=".\src\vr_impl.h" 2.220 + > 2.221 + </File> 2.222 + <File 2.223 + RelativePath=".\src\vr_sdr.h" 2.224 + > 2.225 + </File> 2.226 + </Filter> 2.227 + <Filter 2.228 + Name="libovr" 2.229 + > 2.230 + <File 2.231 + RelativePath=".\libovr\Src\OVR_Device.h" 2.232 + > 2.233 + </File> 2.234 + <File 2.235 + RelativePath=".\libovr\Src\OVR_DeviceConstants.h" 2.236 + > 2.237 + </File> 2.238 + <File 2.239 + RelativePath=".\libovr\Src\OVR_DeviceHandle.cpp" 2.240 + > 2.241 + </File> 2.242 + <File 2.243 + RelativePath=".\libovr\Src\OVR_DeviceHandle.h" 2.244 + > 2.245 + </File> 2.246 + <File 2.247 + RelativePath=".\libovr\Src\OVR_DeviceImpl.cpp" 2.248 + > 2.249 + </File> 2.250 + <File 2.251 + RelativePath=".\libovr\Src\OVR_DeviceImpl.h" 2.252 + > 2.253 + </File> 2.254 + <File 2.255 + RelativePath=".\libovr\Src\OVR_DeviceMessages.h" 2.256 + > 2.257 + </File> 2.258 + <File 2.259 + RelativePath=".\libovr\Src\OVR_HIDDevice.h" 2.260 + > 2.261 + </File> 2.262 + <File 2.263 + RelativePath=".\libovr\Src\OVR_HIDDeviceBase.h" 2.264 + > 2.265 + </File> 2.266 + <File 2.267 + RelativePath=".\libovr\Src\OVR_HIDDeviceImpl.h" 2.268 + > 2.269 + </File> 2.270 + <File 2.271 + RelativePath=".\libovr\Src\OVR_JSON.cpp" 2.272 + > 2.273 + </File> 2.274 + <File 2.275 + RelativePath=".\libovr\Src\OVR_JSON.h" 2.276 + > 2.277 + </File> 2.278 + <File 2.279 + RelativePath=".\libovr\Src\OVR_LatencyTestImpl.cpp" 2.280 + > 2.281 + </File> 2.282 + <File 2.283 + RelativePath=".\libovr\Src\OVR_LatencyTestImpl.h" 2.284 + > 2.285 + </File> 2.286 + <File 2.287 + RelativePath=".\libovr\Src\OVR_Profile.cpp" 2.288 + > 2.289 + </File> 2.290 + <File 2.291 + RelativePath=".\libovr\Src\OVR_Profile.h" 2.292 + > 2.293 + </File> 2.294 + <File 2.295 + RelativePath=".\libovr\Src\OVR_SensorFilter.cpp" 2.296 + > 2.297 + </File> 2.298 + <File 2.299 + RelativePath=".\libovr\Src\OVR_SensorFilter.h" 2.300 + > 2.301 + </File> 2.302 + <File 2.303 + RelativePath=".\libovr\Src\OVR_SensorFusion.cpp" 2.304 + > 2.305 + </File> 2.306 + <File 2.307 + RelativePath=".\libovr\Src\OVR_SensorFusion.h" 2.308 + > 2.309 + </File> 2.310 + <File 2.311 + RelativePath=".\libovr\Src\OVR_SensorImpl.cpp" 2.312 + > 2.313 + </File> 2.314 + <File 2.315 + RelativePath=".\libovr\Src\OVR_SensorImpl.h" 2.316 + > 2.317 + </File> 2.318 + <File 2.319 + RelativePath=".\libovr\Src\OVR_ThreadCommandQueue.cpp" 2.320 + > 2.321 + </File> 2.322 + <File 2.323 + RelativePath=".\libovr\Src\OVR_ThreadCommandQueue.h" 2.324 + > 2.325 + </File> 2.326 + <Filter 2.327 + Name="Kernel" 2.328 + > 2.329 + <File 2.330 + RelativePath=".\libovr\Src\Kernel\OVR_Alg.cpp" 2.331 + > 2.332 + </File> 2.333 + <File 2.334 + RelativePath=".\libovr\Src\Kernel\OVR_Alg.h" 2.335 + > 2.336 + </File> 2.337 + <File 2.338 + RelativePath=".\libovr\Src\Kernel\OVR_Allocator.cpp" 2.339 + > 2.340 + </File> 2.341 + <File 2.342 + RelativePath=".\libovr\Src\Kernel\OVR_Allocator.h" 2.343 + > 2.344 + </File> 2.345 + <File 2.346 + RelativePath=".\libovr\Src\Kernel\OVR_Array.h" 2.347 + > 2.348 + </File> 2.349 + <File 2.350 + RelativePath=".\libovr\Src\Kernel\OVR_Atomic.cpp" 2.351 + > 2.352 + </File> 2.353 + <File 2.354 + RelativePath=".\libovr\Src\Kernel\OVR_Atomic.h" 2.355 + > 2.356 + </File> 2.357 + <File 2.358 + RelativePath=".\libovr\Src\Kernel\OVR_Color.h" 2.359 + > 2.360 + </File> 2.361 + <File 2.362 + RelativePath=".\libovr\Src\Kernel\OVR_ContainerAllocator.h" 2.363 + > 2.364 + </File> 2.365 + <File 2.366 + RelativePath=".\libovr\Src\Kernel\OVR_File.cpp" 2.367 + > 2.368 + </File> 2.369 + <File 2.370 + RelativePath=".\libovr\Src\Kernel\OVR_File.h" 2.371 + > 2.372 + </File> 2.373 + <File 2.374 + RelativePath=".\libovr\Src\Kernel\OVR_FileFILE.cpp" 2.375 + > 2.376 + </File> 2.377 + <File 2.378 + RelativePath=".\libovr\Src\Kernel\OVR_Hash.h" 2.379 + > 2.380 + </File> 2.381 + <File 2.382 + RelativePath=".\libovr\Src\Kernel\OVR_KeyCodes.h" 2.383 + > 2.384 + </File> 2.385 + <File 2.386 + RelativePath=".\libovr\Src\Kernel\OVR_List.h" 2.387 + > 2.388 + </File> 2.389 + <File 2.390 + RelativePath=".\libovr\Src\Kernel\OVR_Log.cpp" 2.391 + > 2.392 + </File> 2.393 + <File 2.394 + RelativePath=".\libovr\Src\Kernel\OVR_Log.h" 2.395 + > 2.396 + </File> 2.397 + <File 2.398 + RelativePath=".\libovr\Src\Kernel\OVR_Math.cpp" 2.399 + > 2.400 + </File> 2.401 + <File 2.402 + RelativePath=".\libovr\Src\Kernel\OVR_Math.h" 2.403 + > 2.404 + </File> 2.405 + <File 2.406 + RelativePath=".\libovr\Src\Kernel\OVR_RefCount.cpp" 2.407 + > 2.408 + </File> 2.409 + <File 2.410 + RelativePath=".\libovr\Src\Kernel\OVR_RefCount.h" 2.411 + > 2.412 + </File> 2.413 + <File 2.414 + RelativePath=".\libovr\Src\Kernel\OVR_Std.cpp" 2.415 + > 2.416 + </File> 2.417 + <File 2.418 + RelativePath=".\libovr\Src\Kernel\OVR_Std.h" 2.419 + > 2.420 + </File> 2.421 + <File 2.422 + RelativePath=".\libovr\Src\Kernel\OVR_String.cpp" 2.423 + > 2.424 + </File> 2.425 + <File 2.426 + RelativePath=".\libovr\Src\Kernel\OVR_String.h" 2.427 + > 2.428 + </File> 2.429 + <File 2.430 + RelativePath=".\libovr\Src\Kernel\OVR_String_FormatUtil.cpp" 2.431 + > 2.432 + </File> 2.433 + <File 2.434 + RelativePath=".\libovr\Src\Kernel\OVR_String_PathUtil.cpp" 2.435 + > 2.436 + </File> 2.437 + <File 2.438 + RelativePath=".\libovr\Src\Kernel\OVR_StringHash.h" 2.439 + > 2.440 + </File> 2.441 + <File 2.442 + RelativePath=".\libovr\Src\Kernel\OVR_SysFile.cpp" 2.443 + > 2.444 + </File> 2.445 + <File 2.446 + RelativePath=".\libovr\Src\Kernel\OVR_SysFile.h" 2.447 + > 2.448 + </File> 2.449 + <File 2.450 + RelativePath=".\libovr\Src\Kernel\OVR_System.cpp" 2.451 + > 2.452 + </File> 2.453 + <File 2.454 + RelativePath=".\libovr\Src\Kernel\OVR_System.h" 2.455 + > 2.456 + </File> 2.457 + <File 2.458 + RelativePath=".\libovr\Src\Kernel\OVR_Threads.h" 2.459 + > 2.460 + </File> 2.461 + <File 2.462 + RelativePath=".\libovr\Src\Kernel\OVR_Timer.cpp" 2.463 + > 2.464 + </File> 2.465 + <File 2.466 + RelativePath=".\libovr\Src\Kernel\OVR_Timer.h" 2.467 + > 2.468 + </File> 2.469 + <File 2.470 + RelativePath=".\libovr\Src\Kernel\OVR_Types.h" 2.471 + > 2.472 + </File> 2.473 + <File 2.474 + RelativePath=".\libovr\Src\Kernel\OVR_UTF8Util.cpp" 2.475 + > 2.476 + </File> 2.477 + <File 2.478 + RelativePath=".\libovr\Src\Kernel\OVR_UTF8Util.h" 2.479 + > 2.480 + </File> 2.481 + </Filter> 2.482 + <Filter 2.483 + Name="Util" 2.484 + > 2.485 + <File 2.486 + RelativePath=".\libovr\Src\Util\Util_LatencyTest.cpp" 2.487 + > 2.488 + </File> 2.489 + <File 2.490 + RelativePath=".\libovr\Src\Util\Util_LatencyTest.h" 2.491 + > 2.492 + </File> 2.493 + <File 2.494 + RelativePath=".\libovr\Src\Util\Util_MagCalibration.cpp" 2.495 + > 2.496 + </File> 2.497 + <File 2.498 + RelativePath=".\libovr\Src\Util\Util_MagCalibration.h" 2.499 + > 2.500 + </File> 2.501 + <File 2.502 + RelativePath=".\libovr\Src\Util\Util_Render_Stereo.cpp" 2.503 + > 2.504 + </File> 2.505 + <File 2.506 + RelativePath=".\libovr\Src\Util\Util_Render_Stereo.h" 2.507 + > 2.508 + </File> 2.509 + </Filter> 2.510 + <Filter 2.511 + Name="win32" 2.512 + > 2.513 + <File 2.514 + RelativePath=".\libovr\Src\win32\OVR_ThreadsWinAPI.cpp" 2.515 + > 2.516 + </File> 2.517 + <File 2.518 + RelativePath=".\libovr\Src\win32\OVR_Win32_DeviceManager.cpp" 2.519 + > 2.520 + </File> 2.521 + <File 2.522 + RelativePath=".\libovr\Src\win32\OVR_Win32_DeviceManager.h" 2.523 + > 2.524 + </File> 2.525 + <File 2.526 + RelativePath=".\libovr\Src\win32\OVR_Win32_DeviceStatus.cpp" 2.527 + > 2.528 + </File> 2.529 + <File 2.530 + RelativePath=".\libovr\Src\win32\OVR_Win32_DeviceStatus.h" 2.531 + > 2.532 + </File> 2.533 + <File 2.534 + RelativePath=".\libovr\Src\win32\OVR_Win32_HIDDevice.cpp" 2.535 + > 2.536 + </File> 2.537 + <File 2.538 + RelativePath=".\libovr\Src\win32\OVR_Win32_HIDDevice.h" 2.539 + > 2.540 + </File> 2.541 + <File 2.542 + RelativePath=".\libovr\Src\win32\OVR_Win32_HMDDevice.cpp" 2.543 + > 2.544 + </File> 2.545 + <File 2.546 + RelativePath=".\libovr\Src\win32\OVR_Win32_HMDDevice.h" 2.547 + > 2.548 + </File> 2.549 + <File 2.550 + RelativePath=".\libovr\Src\win32\OVR_Win32_SensorDevice.cpp" 2.551 + > 2.552 + </File> 2.553 + <File 2.554 + RelativePath=".\libovr\Src\win32\OVR_Win32_SensorDevice.h" 2.555 + > 2.556 + </File> 2.557 + </Filter> 2.558 + </Filter> 2.559 + <Filter 2.560 + Name="sdr" 2.561 + > 2.562 + <File 2.563 + RelativePath=".\sdr\phong.p.glsl" 2.564 + > 2.565 + </File> 2.566 + <File 2.567 + RelativePath=".\sdr\phong.v.glsl" 2.568 + > 2.569 + </File> 2.570 + <File 2.571 + RelativePath=".\sdr\sdr.glsl" 2.572 + > 2.573 + </File> 2.574 + </Filter> 2.575 + </Files> 2.576 + <Globals> 2.577 + </Globals> 2.578 +</VisualStudioProject>
3.1 --- a/src/main.cc Fri Oct 04 14:50:26 2013 +0300 3.2 +++ b/src/main.cc Fri Oct 04 14:50:50 2013 +0300 3.3 @@ -500,26 +500,6 @@ 3.4 { 3.5 width = x; 3.6 height = y; 3.7 - 3.8 - if(!use_vr) { 3.9 - rtarg_width = width; 3.10 - rtarg_height = height; 3.11 - 3.12 - int new_tex_width = next_pow2(width); 3.13 - int new_tex_height = next_pow2(height); 3.14 - 3.15 - if(new_tex_width != rtarg_tex_width || new_tex_height != rtarg_tex_width) { 3.16 - // TODO 3.17 - exit(1); 3.18 - } 3.19 - 3.20 - rtarg_tex_width = new_tex_width; 3.21 - rtarg_tex_height = new_tex_height; 3.22 - 3.23 - tex_scale_x = (float)rtarg_width / (float)rtarg_tex_width; 3.24 - tex_scale_y = (float)rtarg_height / (float)rtarg_tex_height; 3.25 - 3.26 - } 3.27 } 3.28 3.29 static void keyb(unsigned char key, int x, int y) 3.30 @@ -535,6 +515,13 @@ 3.31 case 'f': 3.32 toggle_fullscreen(); 3.33 break; 3.34 + 3.35 + case '\\': 3.36 + { 3.37 + extern bool dbg_enable; 3.38 + dbg_enable = !dbg_enable; 3.39 + } 3.40 + break; 3.41 } 3.42 3.43 keystate[key] = true;
4.1 --- a/src/vr.cc Fri Oct 04 14:50:26 2013 +0300 4.2 +++ b/src/vr.cc Fri Oct 04 14:50:50 2013 +0300 4.3 @@ -4,13 +4,46 @@ 4.4 #include "vr_impl.h" 4.5 #include "vr_sdr.h" 4.6 4.7 +#ifndef WIN32 4.8 +#include <alloca.h> 4.9 +#else 4.10 +#include <malloc.h> 4.11 +#endif 4.12 + 4.13 +#define USUB 28 4.14 +#define VSUB 40 4.15 + 4.16 +/* these are just used for the shaderless precomputed distortion method */ 4.17 +struct Mesh { 4.18 + int prim; 4.19 + int num_verts, num_faces; 4.20 + unsigned int vbo; 4.21 + unsigned int ibo; 4.22 +}; 4.23 +struct Vertex { 4.24 + float x, y, z; 4.25 + float tx, ty; 4.26 +}; 4.27 + 4.28 + 4.29 static void init_ctx(); 4.30 static bool init_ovr(); 4.31 static bool init_sdr(); 4.32 4.33 +static Mesh gen_view_mesh(int usub, int vsub, float aspect, float lens_center_offset, 4.34 + float scale, const float *dist_factors, float tex_scale_x, float tex_scale_y); 4.35 +static void distort_texcoords(float *tc, float aspect, float lens_center_offset, float scale, const float *dist_factors); 4.36 +static float barrel_scale(float rad, const float *k); 4.37 + 4.38 VRContext vr_ctx; 4.39 static unsigned int sdrprog; 4.40 4.41 +static Mesh wrapmesh[2]; 4.42 +static bool mesh_valid; 4.43 + 4.44 +bool dbg_enable; 4.45 + 4.46 + 4.47 extern "C" int vr_init(enum vr_init_mode mode) 4.48 { 4.49 glewInit(); 4.50 @@ -332,49 +365,204 @@ 4.51 {-1, -1, 0, 1}, 4.52 {0, -1, 1, 1} 4.53 }; 4.54 + static const float quad_trans[3] = {0, -1, 1}; 4.55 + static const float quad_scale[3] = {1, 0.5, 0.5}; 4.56 static const float offs_scale[3] = {0.0, -1.0, 1.0}; 4.57 + static int prev_tex_scale_x, prev_tex_scale_y; 4.58 4.59 glPushAttrib(GL_ENABLE_BIT); 4.60 glDisable(GL_DEPTH_TEST); 4.61 glDisable(GL_LIGHTING); 4.62 - glEnable(GL_TEXTURE_2D); 4.63 + glDisable(GL_CULL_FACE); 4.64 + 4.65 + glMatrixMode(GL_PROJECTION); 4.66 + glPushMatrix(); 4.67 + glLoadIdentity(); 4.68 4.69 glMatrixMode(GL_MODELVIEW); 4.70 glPushMatrix(); 4.71 glLoadIdentity(); 4.72 4.73 - glMatrixMode(GL_PROJECTION); 4.74 - glPushMatrix(); 4.75 - glLoadIdentity(); 4.76 + if(!dbg_enable) { 4.77 + glUseProgram(sdrprog); 4.78 4.79 - glUseProgram(sdrprog); 4.80 + if(sdrprog) { 4.81 + int loc; 4.82 + if((loc = glGetUniformLocation(sdrprog, "lens_center_offset")) != -1) { 4.83 + float offset = vr_ctx.info.lens_center_offset * offs_scale[eye]; 4.84 + glUniform1f(loc, offset); 4.85 + } 4.86 4.87 - if(sdrprog) { 4.88 - int loc; 4.89 - if((loc = glGetUniformLocation(sdrprog, "lens_center_offset")) != -1) { 4.90 - float offset = vr_ctx.info.lens_center_offset * offs_scale[eye]; 4.91 - glUniform1f(loc, offset); 4.92 + if((loc = glGetUniformLocation(sdrprog, "tex_scale")) != -1) { 4.93 + glUniform2f(loc, tex_scale_x, tex_scale_y); 4.94 + } 4.95 } 4.96 4.97 - if((loc = glGetUniformLocation(sdrprog, "tex_scale")) != -1) { 4.98 - glUniform2f(loc, tex_scale_x, tex_scale_y); 4.99 + glBindTexture(GL_TEXTURE_2D, tex); 4.100 + glBegin(GL_QUADS); 4.101 + glColor4f(1, 1, 1, 1); 4.102 + glTexCoord2f(0, 0); glVertex2f(rects[eye][0], rects[eye][1]); 4.103 + glTexCoord2f(1, 0); glVertex2f(rects[eye][2], rects[eye][1]); 4.104 + glTexCoord2f(1, 1); glVertex2f(rects[eye][2], rects[eye][3]); 4.105 + glTexCoord2f(0, 1); glVertex2f(rects[eye][0], rects[eye][3]); 4.106 + glEnd(); 4.107 + 4.108 + glUseProgram(0); 4.109 + 4.110 + } else { 4.111 + 4.112 + if(!mesh_valid || tex_scale_x != prev_tex_scale_x || tex_scale_y != prev_tex_scale_y) { 4.113 + for(int i=0; i<2; i++) { 4.114 + int eye = i + VR_EYE_LEFT; 4.115 + 4.116 + if(wrapmesh[i].vbo) { 4.117 + glDeleteBuffers(1, &wrapmesh[i].vbo); 4.118 + } 4.119 + if(wrapmesh[i].ibo) { 4.120 + glDeleteBuffers(1, &wrapmesh[i].ibo); 4.121 + } 4.122 + 4.123 + float aspect = vr_ctx.info.aspect / 2.0; 4.124 + float offset = vr_ctx.info.lens_center_offset * offs_scale[eye]; 4.125 + wrapmesh[i] = gen_view_mesh(USUB, VSUB, aspect, offset, vr_ctx.info.scale, vr_ctx.info.distort, 4.126 + tex_scale_x, tex_scale_y); 4.127 + } 4.128 + mesh_valid = true; 4.129 + prev_tex_scale_x = tex_scale_x; 4.130 + prev_tex_scale_y = tex_scale_y; 4.131 } 4.132 + 4.133 + glScalef(quad_scale[eye], 1.0, 1.0); 4.134 + glTranslatef(quad_trans[eye], 0, 0); 4.135 + 4.136 + glUseProgram(0); 4.137 + glBindTexture(GL_TEXTURE_2D, tex); 4.138 + glEnable(GL_TEXTURE_2D); 4.139 + 4.140 + glColor3f(1, 1, 1); 4.141 + 4.142 + glEnableClientState(GL_VERTEX_ARRAY); 4.143 + glEnableClientState(GL_TEXTURE_COORD_ARRAY); 4.144 + 4.145 + int meshidx = eye - VR_EYE_LEFT; 4.146 + glBindBuffer(GL_ARRAY_BUFFER, wrapmesh[meshidx].vbo); 4.147 + glVertexPointer(3, GL_FLOAT, sizeof(Vertex), 0); 4.148 + glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), (void*)offsetof(Vertex, tx)); 4.149 + 4.150 + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, wrapmesh[meshidx].ibo); 4.151 + glDrawElements(GL_TRIANGLES, wrapmesh[meshidx].num_faces * 3, GL_UNSIGNED_INT, 0); 4.152 + 4.153 + glBindBuffer(GL_ARRAY_BUFFER, 0); 4.154 + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); 4.155 + 4.156 + glDisableClientState(GL_VERTEX_ARRAY); 4.157 + glDisableClientState(GL_TEXTURE_COORD_ARRAY); 4.158 } 4.159 4.160 - glBindTexture(GL_TEXTURE_2D, tex); 4.161 - glBegin(GL_QUADS); 4.162 - glColor4f(1, 1, 1, 1); 4.163 - glTexCoord2f(0, 0); glVertex2f(rects[eye][0], rects[eye][1]); 4.164 - glTexCoord2f(1, 0); glVertex2f(rects[eye][2], rects[eye][1]); 4.165 - glTexCoord2f(1, 1); glVertex2f(rects[eye][2], rects[eye][3]); 4.166 - glTexCoord2f(0, 1); glVertex2f(rects[eye][0], rects[eye][3]); 4.167 - glEnd(); 4.168 - 4.169 - glUseProgram(0); 4.170 - 4.171 + glMatrixMode(GL_PROJECTION); 4.172 glPopMatrix(); 4.173 glMatrixMode(GL_MODELVIEW); 4.174 glPopMatrix(); 4.175 4.176 glPopAttrib(); 4.177 } 4.178 + 4.179 +static Mesh gen_view_mesh(int usub, int vsub, float aspect, float lens_center_offset, 4.180 + float scale, const float *dist_factors, float tex_scale_x, float tex_scale_y) 4.181 +{ 4.182 + int uverts = usub + 1; 4.183 + int vverts = vsub + 1; 4.184 + 4.185 + int num_verts = uverts * vverts; 4.186 + int num_quads = usub * vsub; 4.187 + int num_tris = num_quads * 2; 4.188 + 4.189 + Vertex *varr = new Vertex[num_verts]; 4.190 + unsigned int *iarr = new unsigned int[num_tris * 3]; 4.191 + 4.192 + float du = 1.0 / (float)usub; 4.193 + float dv = 1.0 / (float)vsub; 4.194 + 4.195 + Vertex *vptr = varr; 4.196 + for(int i=0; i<vverts; i++) { 4.197 + float v = (float)i * dv; 4.198 + float y = 2.0 * v - 1.0; 4.199 + 4.200 + for(int j=0; j<uverts; j++) { 4.201 + float u = (float)j * du; 4.202 + float x = 2.0 * u - 1.0; 4.203 + float tc[2] = {u, v}; 4.204 + 4.205 + distort_texcoords(tc, aspect, lens_center_offset, scale, dist_factors); 4.206 + 4.207 + vptr->x = x; 4.208 + vptr->y = y; 4.209 + vptr->z = 0; 4.210 + vptr->tx = tc[0] * tex_scale_x; 4.211 + vptr->ty = tc[1] * tex_scale_y; 4.212 + vptr++; 4.213 + } 4.214 + } 4.215 + 4.216 + unsigned int *iptr = iarr; 4.217 + for(int i=0; i<vsub; i++) { 4.218 + for(int j=0; j<usub; j++) { 4.219 + *iptr++ = i * uverts + j; 4.220 + *iptr++ = (i + 1) * uverts + j; 4.221 + *iptr++ = (i + 1) * uverts + (j + 1); 4.222 + 4.223 + *iptr++ = i * uverts + j; 4.224 + *iptr++ = (i + 1) * uverts + (j + 1); 4.225 + *iptr++ = i * uverts + (j + 1); 4.226 + } 4.227 + } 4.228 + 4.229 + unsigned int buf[2]; 4.230 + glGenBuffers(2, buf); 4.231 + glBindBuffer(GL_ARRAY_BUFFER, buf[0]); 4.232 + glBufferData(GL_ARRAY_BUFFER, num_verts * sizeof *varr, varr, GL_STATIC_DRAW); 4.233 + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, buf[1]); 4.234 + glBufferData(GL_ELEMENT_ARRAY_BUFFER, num_tris * 3 * sizeof *iarr, iarr, GL_STATIC_DRAW); 4.235 + 4.236 + delete [] varr; 4.237 + delete [] iarr; 4.238 + 4.239 + Mesh mesh; 4.240 + mesh.prim = GL_TRIANGLES; 4.241 + mesh.num_verts = num_verts; 4.242 + mesh.num_faces = num_tris; 4.243 + mesh.vbo = buf[0]; 4.244 + mesh.ibo = buf[1]; 4.245 + return mesh; 4.246 +} 4.247 + 4.248 +static void distort_texcoords(float *tc, float aspect, float lens_center_offset, float scale, const float *dist_factors) 4.249 +{ 4.250 + // map tc [0, 1] -> [-1, 1] 4.251 + float ptx = tc[0] * 2.0 - 1.0; 4.252 + float pty = tc[1] * 2.0 - 1.0; 4.253 + 4.254 + ptx += lens_center_offset * 2.0; 4.255 + pty /= aspect; // correct for aspect ratio 4.256 + 4.257 + float rad = barrel_scale(ptx * ptx + pty * pty, dist_factors); 4.258 + ptx *= rad; // scale the point by the computer distortion radius 4.259 + pty *= rad; 4.260 + 4.261 + ptx /= scale; 4.262 + pty /= scale; 4.263 + 4.264 + pty *= aspect; 4.265 + ptx -= lens_center_offset * 2.0; 4.266 + 4.267 + // map back to range [0, 1] 4.268 + tc[0] = ptx * 0.5 + 0.5; 4.269 + tc[1] = pty * 0.5 + 0.5; 4.270 +} 4.271 + 4.272 +static float barrel_scale(float rad, const float *k) 4.273 +{ 4.274 + float radsq = rad * rad; 4.275 + float radquad = radsq * radsq; 4.276 + return k[0] + k[1] * radsq + k[2] * radquad + k[3] * radquad * radsq; 4.277 +}