summaryrefslogtreecommitdiff
path: root/client2.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2015-03-16 19:01:02 +0100
committerFlorian Jung <flo@windfisch.org>2015-03-16 19:19:45 +0100
commit81d4cdb0de47a001e0498e8ad144cb25cabd09c4 (patch)
tree82ec7a4dedae48b55a970ce92fa4038841a8d7a9 /client2.cpp
parent7d501170124f0cd0b8c1d66d7ee996db84b77267 (diff)
spherical projection II
Diffstat (limited to 'client2.cpp')
-rw-r--r--client2.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/client2.cpp b/client2.cpp
index 65b123d..0f1f1ac 100644
--- a/client2.cpp
+++ b/client2.cpp
@@ -61,7 +61,7 @@ const char* drawOnCanvasFragmentSource =
"uniform float cam_roll;\n"
"const float CAM_XRES=1280;\n"
"const float CAM_YRES=720;\n"
- "const float CAM_XDEG=82/180.*3.141592654;\n"
+ "const float CAM_XDEG=70/180.*3.141592654;\n"
"const float CAM_FX=CAM_XRES/2.0 / tan(CAM_XDEG/2.0);\n"
//"const float CAM_FX=1;\n"
"const mat3 cam_cal = transpose(mat3(CAM_FX, 0, CAM_XRES/2, 0, CAM_FX, CAM_YRES/2, 0,0,1));\n"
@@ -71,8 +71,8 @@ const char* drawOnCanvasFragmentSource =
"void main()\n"
"{\n"
" // cam_rot rotates a pixel FROM world TO cam frame\n"
- " // mat3 cam_rot = transpose(mat3(1,0,0, 0,cos(cam_roll),sin(cam_roll), 0,-sin(cam_roll),cos(cam_roll))) * transpose(mat3(cos(cam_pitch),0,-sin(cam_pitch), 0,1,0, sin(cam_pitch),0,cos(cam_pitch))) * transpose(mat3(cos(cam_yaw),sin(cam_yaw),0,-sin(cam_yaw),cos(cam_yaw),0,0,0,1));\n"
- " mat3 cam_rot = transpose(mat3(1,0,0, 0,1,0, 0,0,1));\n"
+ " mat3 cam_rot = transpose(mat3(1,0,0, 0,cos(cam_roll),sin(cam_roll), 0,-sin(cam_roll),cos(cam_roll))) * transpose(mat3(cos(cam_pitch),0,-sin(cam_pitch), 0,1,0, sin(cam_pitch),0,cos(cam_pitch))) * transpose(mat3(cos(cam_yaw),sin(cam_yaw),0,-sin(cam_yaw),cos(cam_yaw),0,0,0,1));\n"
+// " mat3 cam_rot = transpose(mat3(1,0,0, 0,1,0, 0,0,1));\n"
" // Texcoord.xy is yaw/pitch in the unit sphere\n"
" vec3 point_in_world_frame = vec3( cos(Texcoord.x)*cos(Texcoord.y), sin(Texcoord.x)*cos(Texcoord.y), -sin(Texcoord.y) );\n"
// " if ((0.2< abs(point_in_world_frame.z)) && (abs(point_in_world_frame.z) < 0.3)) outColor=vec4(1,1,1,1); else outColor=vec4(0,0,0,1); return;"
@@ -85,7 +85,7 @@ const char* drawOnCanvasFragmentSource =
" outColor = texture(texVideo, vec2(1.0,1.0)-point_in_cam_pic/vec2(CAM_XRES,CAM_YRES));\n"
//" outColor = vec4(point_in_cam_pic/vec2(CAM_XRES,CAM_YRES),-point_in_cam_pic_uniform.z/1000,1);\n"
" else\n"
- " outColor = vec4(1.0,0.0,1.0,0.1);"
+ " outColor = vec4(0.0,0.0,0.0,0.00);"
"}\n";
const char* justDrawASpriteFragmentSource =
@@ -432,7 +432,9 @@ int main(int argc, const char** argv)
GLuint quadShaderProgram = justDrawASpriteShaderProgram(vaoQuad, vboQuad);
GLuint oculusShaderProgram = newOculusShaderProgram(vaoWholescreenQuad, vboWholescreenQuad);
GLuint drawOnCanvasProgram = newCanvasShaderProgram(vaoCanvas, vboCanvas);
-
+ GLint uniCamYaw = glGetUniformLocation(drawOnCanvasProgram, "cam_yaw");
+ GLint uniCamPitch = glGetUniformLocation(drawOnCanvasProgram, "cam_pitch");
+ GLint uniCamRoll = glGetUniformLocation(drawOnCanvasProgram, "cam_roll");
// texture
GLuint texVideo;
@@ -623,6 +625,10 @@ glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glUseProgram(drawOnCanvasProgram);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, texVideo);
+
+ glUniform1f(uniCamYaw,(float)total_x/virtual_canvas_width*2*PI);
+ glUniform1f(uniCamPitch,-(float)total_y/px_per_deg/180.*PI);
+ glUniform1f(uniCamRoll,-total_rot/180.*PI);
glDrawArrays(GL_TRIANGLES, 0, 6);