Last active
          August 29, 2015 14:20 
        
      - 
      
- 
        Save yorung/d2efea8c35c4d75aa277 to your computer and use it in GitHub Desktop. 
    make mat4 from vec4
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | uniform vec4 uniformBuffer[9]; | |
| void main() { | |
| mat4 matV = mat4(uniformBuffer[0], uniformBuffer[1], uniformBuffer[2], uniformBuffer[3]); | |
| mat4 matP = mat4(uniformBuffer[4], uniformBuffer[5], uniformBuffer[6], uniformBuffer[7]); | |
| float etc1 = uniformBuffer[8].x; | |
| float etc2 = uniformBuffer[8].y; | |
| float etc3 = uniformBuffer[8].z; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | struct UniformBuffer | |
| { | |
| Mat matP, matV; | |
| float etc1, etc2, etc3, padding; | |
| }; | |
| static UniformBuffer buf; | |
| void Write() | |
| { | |
| glUniform4fv(glGetUniformLocation(shaderId, "uniformBuffer"), sizeof(buf) / (sizeof(GLfloat) * 4), (GLfloat*)&buf); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment