Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int y = Screen.PrimaryScreen.Bounds.Height - this.PreferredSize.Height;
- glControl1.Location = new Point(0, y/2);
- private void OpenGL_SizeChanged(object sender, EventArgs e)
- {
- glControl1.Width = this.Width;
- glControl1.Height = this.Height/2;
- }
- private void CreateShaders()
- {
- /***********Vert Shader********************/
- vertShader = GL.CreateShader(ShaderType.VertexShader);
- GL.ShaderSource(vertShader, @"attribute vec3 a_position;
- varying vec2 vTexCoordIn;
- //uniform float aspect;
- void main() {
- vTexCoordIn=( a_position.xy+1)/2;
- gl_Position = vec4(a_position,1);
- }");
- GL.CompileShader(vertShader);
- /***********Frag Shader ****************/
- fragShader = GL.CreateShader(ShaderType.FragmentShader);
- GL.ShaderSource(fragShader, @"
- uniform sampler2D sTexture;
- uniform sampler2D sTexture1;
- uniform sampler2D sTexture2;
- uniform vec2 sTexSize;
- uniform vec2 sTexSize1;
- uniform vec2 sTexSize2;
- varying vec2 vTexCoordIn;
- void main ()
- {
- vec2 vTexCoord=vec2(vTexCoordIn.x,vTexCoordIn.y);
- if ( vTexCoord.x < 1.0/3.0 )
- {
- vec2 uv = vec2(vTexCoord.x * 3.0, vTexCoord.y);
- uv.y *= sTexSize.x / sTexSize.y;
- if (uv.y > 1.0)
- discard;
- else
- gl_FragColor = texture2D(sTexture, uv);
- }
- else if ( vTexCoord.x >= 1.0/3.0 && vTexCoord.x < 2.0/3.0 )
- {
- vec2 uv = vec2(vTexCoord.x * 3.0 - 1.0, vTexCoord.y);
- uv.y *= sTexSize1.x / sTexSize1.y;
- if (uv.y > 1.0)
- discard;
- else
- gl_FragColor = texture2D(sTexture1, uv);
- }
- else if ( vTexCoord.x >= 2.0/3.0 )
- {
- vec2 uv = vec2(vTexCoord.x * 3.0 - 2.0, vTexCoord.y);
- uv.y *= sTexSize2.x / sTexSize2.y;
- if (uv.y > 1.0)
- discard;
- else
- gl_FragColor = texture2D(sTexture2, uv);
- }
- }");
- GL.CompileShader(fragShader);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement