Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. int y = Screen.PrimaryScreen.Bounds.Height - this.PreferredSize.Height;
  2. glControl1.Location = new Point(0, y/2);
  3. private void OpenGL_SizeChanged(object sender, EventArgs e)
  4. {
  5. glControl1.Width = this.Width;
  6. glControl1.Height = this.Height/2;
  7. }
  8.  
  9. private void CreateShaders()
  10. {
  11. /***********Vert Shader********************/
  12. vertShader = GL.CreateShader(ShaderType.VertexShader);
  13. GL.ShaderSource(vertShader, @"attribute vec3 a_position;
  14. varying vec2 vTexCoordIn;
  15. //uniform float aspect;
  16. void main() {
  17. vTexCoordIn=( a_position.xy+1)/2;
  18. gl_Position = vec4(a_position,1);
  19. }");
  20. GL.CompileShader(vertShader);
  21.  
  22. /***********Frag Shader ****************/
  23. fragShader = GL.CreateShader(ShaderType.FragmentShader);
  24. GL.ShaderSource(fragShader, @"
  25. uniform sampler2D sTexture;
  26. uniform sampler2D sTexture1;
  27. uniform sampler2D sTexture2;
  28.  
  29. uniform vec2 sTexSize;
  30. uniform vec2 sTexSize1;
  31. uniform vec2 sTexSize2;
  32. varying vec2 vTexCoordIn;
  33. void main ()
  34. {
  35. vec2 vTexCoord=vec2(vTexCoordIn.x,vTexCoordIn.y);
  36. if ( vTexCoord.x < 1.0/3.0 )
  37. {
  38. vec2 uv = vec2(vTexCoord.x * 3.0, vTexCoord.y);
  39. uv.y *= sTexSize.x / sTexSize.y;
  40. if (uv.y > 1.0)
  41. discard;
  42. else
  43. gl_FragColor = texture2D(sTexture, uv);
  44. }
  45. else if ( vTexCoord.x >= 1.0/3.0 && vTexCoord.x < 2.0/3.0 )
  46. {
  47. vec2 uv = vec2(vTexCoord.x * 3.0 - 1.0, vTexCoord.y);
  48. uv.y *= sTexSize1.x / sTexSize1.y;
  49. if (uv.y > 1.0)
  50. discard;
  51. else
  52. gl_FragColor = texture2D(sTexture1, uv);
  53. }
  54. else if ( vTexCoord.x >= 2.0/3.0 )
  55. {
  56. vec2 uv = vec2(vTexCoord.x * 3.0 - 2.0, vTexCoord.y);
  57. uv.y *= sTexSize2.x / sTexSize2.y;
  58. if (uv.y > 1.0)
  59. discard;
  60. else
  61. gl_FragColor = texture2D(sTexture2, uv);
  62. }
  63. }");
  64. GL.CompileShader(fragShader);
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement