|
7 | 7 | using OpenTK; |
8 | 8 | using OpenTK.Graphics; |
9 | 9 | using OpenTK.Graphics.OpenGL; |
10 | | -using OpenTK.Input; |
11 | 10 |
|
12 | 11 | namespace OpenTKTutorial8 |
13 | 12 | { |
@@ -37,7 +36,6 @@ public Game() |
37 | 36 |
|
38 | 37 | Dictionary<string, ShaderProgram> shaders = new Dictionary<string, ShaderProgram>(); |
39 | 38 | string activeShader = "default"; |
40 | | - |
41 | 39 |
|
42 | 40 | float time = 0.0f; |
43 | 41 |
|
@@ -97,12 +95,13 @@ protected override void OnRenderFrame(FrameEventArgs e) |
97 | 95 | // Draw all our objects |
98 | 96 | foreach (Volume v in objects) |
99 | 97 | { |
| 98 | + GL.ActiveTexture(TextureUnit.Texture0); |
100 | 99 | GL.BindTexture(TextureTarget.Texture2D, v.TextureID); |
101 | 100 | GL.UniformMatrix4(shaders[activeShader].GetUniform("modelview"), false, ref v.ModelViewProjectionMatrix); |
102 | 101 |
|
103 | | - if (shaders[activeShader].GetAttribute("maintexture") != -1) |
| 102 | + if (shaders[activeShader].GetUniform("maintexture") != -1) |
104 | 103 | { |
105 | | - GL.Uniform1(shaders[activeShader].GetAttribute("maintexture"), v.TextureID); |
| 104 | + GL.Uniform1(shaders[activeShader].GetUniform("maintexture"), 0); |
106 | 105 | } |
107 | 106 |
|
108 | 107 | GL.DrawElements(BeginMode.Triangles, v.IndiceCount, DrawElementsType.UnsignedInt, indiceat * sizeof(uint)); |
@@ -269,7 +268,7 @@ int loadImage(Bitmap image) |
269 | 268 | int texID = GL.GenTexture(); |
270 | 269 |
|
271 | 270 | GL.BindTexture(TextureTarget.Texture2D, texID); |
272 | | - BitmapData data = image.LockBits(new System.Drawing.Rectangle(0, 0, image.Width, image.Height), |
| 271 | + BitmapData data = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), |
273 | 272 | ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); |
274 | 273 |
|
275 | 274 | GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, |
|
0 commit comments