Skip to content

Commit

Permalink
Don't rotate up/down around, and view with initial -90 rotation
Browse files Browse the repository at this point in the history
  • Loading branch information
cedricfung committed Aug 19, 2013
1 parent 0f83d06 commit b33ae37
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 3 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -4,6 +4,12 @@ Valo
Full featured panoramic image and video viewer.


Screenshots
-----------

![Little planet view](https://o.repo.io/130819NgUw.png)


Dependencies
------------

Expand Down
1 change: 1 addition & 0 deletions include/valo/vlgl.h
Expand Up @@ -57,6 +57,7 @@ typedef struct VLGL {
mat4d m_tex;
poly_t *poly;
GLfloat vw, vh, vz;
GLfloat rotate_v;
} VLGL;

VLGL *VLGL_construct(enum poly_type type, int precision);
Expand Down
20 changes: 17 additions & 3 deletions src/vlgl.c
Expand Up @@ -184,7 +184,8 @@ VLGL *VLGL_construct(enum poly_type type, int precision)
}

gl->vw = 1; gl->vh = 1; gl->vz = 1;
gl->m_model = mat4d_identity();
gl->rotate_v = -90;
gl->m_model = mat4d_rotate(mat4d_identity(), (vec4d){.vex = {1, 0, 0}}, -90);
gl->m_proj = mat4d_ortho(45 * gl->vz, gl->vw / gl->vh, 1, 10);
gl->m_view = mat4d_look_at((vec4d){.vex = {0, 0, -1}}, (vec4d){.vex = {0}}, (vec4d){.vex = {0,1,0}});
gl->m_tex = mat4d_identity();
Expand Down Expand Up @@ -256,7 +257,19 @@ void VLGL_viewport(VLGL *gl, int w, int h)

void VLGL_rotate(VLGL *gl, double x, double y, double z, double degree)
{
gl->m_model = mat4d_rotate(gl->m_model, (vec4d){.vex = {x,y,z}}, degree);
double delta = degree;
if (x == 1 && y == 0 && z == 0) {
if (gl->rotate_v + degree > 0) {
delta = -gl->rotate_v;
gl->rotate_v = 0;
} else if (gl->rotate_v + degree < -180) {
delta = -180 - gl->rotate_v;
gl->rotate_v = -180;
} else {
gl->rotate_v += degree;
}
}
gl->m_model = mat4d_rotate(gl->m_model, (vec4d){.vex = {x,y,z}}, delta);
}

void VLGL_zoom(VLGL *gl, double inc)
Expand All @@ -273,7 +286,8 @@ void VLGL_zoom(VLGL *gl, double inc)
void VLGL_reset(VLGL *gl)
{
gl->vz = 1;
gl->m_model = mat4d_identity();
gl->rotate_v = -90;
gl->m_model = mat4d_rotate(mat4d_identity(), (vec4d){.vex = {1, 0, 0}}, -90);
gl->m_proj = mat4d_ortho(45 * gl->vz, gl->vw / gl->vh, 1, 10);
}

Expand Down

0 comments on commit b33ae37

Please sign in to comment.