Changeset 22217d4 in opengl-game


Ignore:
Timestamp:
Mar 22, 2020, 10:07:01 PM (4 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
1add0ed
Parents:
0807aeb
Message:

Make the view and projection matrices instaces variables of the VulkanGame class

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • gl-shaders/ship.frag

    r0807aeb r22217d4  
    4949  vec3 Is2 = Ls * Ks * specular_factor2;
    5050
    51   frag_color = vec4((Is + Id + Ia + Is2 + Id2 + Ia2)/2, 1.0);
     51  frag_color = vec4((Is + Id + Ia + Is2 + Id2 + Ia2) / 2.0, 1.0);
    5252}
  • shaders/ship.frag

    r0807aeb r22217d4  
    5757   vec3 Is2 = Ls * Ks * specular_factor2;
    5858
    59    frag_color = vec4((Is + Id + Ia + Is2 + Id2 + Ia2)/2, 1.0);
     59   frag_color = vec4((Is + Id + Ia + Is2 + Id2 + Ia2) / 2.0, 1.0);
    6060}
  • vulkan-game.cpp

    r0807aeb r22217d4  
    568568   mat4 R_view = pitch_mat * yaw_mat;
    569569   mat4 T_view = translate(mat4(1.0f), vec3(-cam_pos.x, -cam_pos.y, -cam_pos.z));
    570    mat4 view = R_view * T_view;
    571 
    572    mat4 proj = perspective(radians(FOV_ANGLE), (float)swapChainExtent.width / (float)swapChainExtent.height, NEAR_CLIP, FAR_CLIP);
    573    proj[1][1] *= -1; // flip the y-axis so that +y is up
    574 
    575    object_VP_mats.view = view;
    576    object_VP_mats.proj = proj;
    577 
    578    ship_VP_mats.view = view;
    579    ship_VP_mats.proj = proj;
    580 
    581    asteroid_VP_mats.view = view;
    582    asteroid_VP_mats.proj = proj;
     570   viewMat = R_view * T_view;
     571
     572   projMat = perspective(radians(FOV_ANGLE), (float)swapChainExtent.width / (float)swapChainExtent.height, NEAR_CLIP, FAR_CLIP);
     573   projMat[1][1] *= -1; // flip the y-axis so that +y is up
     574
     575   object_VP_mats.view = viewMat;
     576   object_VP_mats.proj = projMat;
     577
     578   ship_VP_mats.view = viewMat;
     579   ship_VP_mats.proj = projMat;
     580
     581   asteroid_VP_mats.view = viewMat;
     582   asteroid_VP_mats.proj = projMat;
    583583}
    584584
  • vulkan-game.hpp

    r0807aeb r22217d4  
    149149
    150150      bool framebufferResized;
     151
     152      mat4 viewMat, projMat;
    151153
    152154      GraphicsPipeline_Vulkan<OverlayVertex, void*> overlayPipeline;
Note: See TracChangeset for help on using the changeset viewer.