Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Can';在绘制的顶点上看不到纹理或颜色_C#_Opengl_Graphics_Vertex_Opentk - Fatal编程技术网

C# Can';在绘制的顶点上看不到纹理或颜色

C# Can';在绘制的顶点上看不到纹理或颜色,c#,opengl,graphics,vertex,opentk,C#,Opengl,Graphics,Vertex,Opentk,我在OpenTK中有以下代码: unsafe { Vector3* data = (Vector3*)Marshal.AllocHGlobal( Marshal.SizeOf(typeof(Vector3)) * simpleVertices.Count); Vector2* uv = (Vector2*)Marshal.AllocHGlobal(

我在OpenTK中有以下代码:

        unsafe
        {
            Vector3* data = (Vector3*)Marshal.AllocHGlobal(
                                  Marshal.SizeOf(typeof(Vector3)) * simpleVertices.Count);
            Vector2* uv = (Vector2*)Marshal.AllocHGlobal(
                                  Marshal.SizeOf(typeof(Vector2)) * simpleVertices.Count);
            for(int i = 0; i < simpleVertices.Count; i++)
            {
                ((Vector3*)data)[i] = simpleVertices[i];
                Vector2 thisuv = uvData[i];
                ((Vector2*)uv)[i] = uvData[i];

            }

            GL.BindTexture(All.Texture2D, texture.GLTexture.OpenGLName);
            GL.TexParameter(All.Texture2D, All.TextureWrapS, (int)TextureWrapMode.Repeat);
            GL.TexParameter(All.Texture2D, All.TextureWrapT, (int)TextureWrapMode.Repeat);

            byte []squareColors = new byte[simpleVertices.Count];
            Random.NextBytes(squareColors);

            GL.ColorPointer (vertices.Count, All.UnsignedByte, 0, squareColors);

            GL.VertexPointer(3, All.Float, sizeof(Vector3), new IntPtr(data));
            GL.DrawArrays(All.Triangles, 0, simpleVertices.Count);


            Marshal.FreeHGlobal((IntPtr)data);
            Marshal.FreeHGlobal((IntPtr)uv);
        }
不安全
{
Vector3*数据=(Vector3*)Marshall.AllocHGlobal(
Marshal.SizeOf(typeof(Vector3))*simpleVertices.Count);
Vector2*uv=(Vector2*)Marshal.AllocHGlobal(
Marshal.SizeOf(typeof(Vector2))*simpleVertices.Count);
for(int i=0;i
我知道为顶点和UV提供的数据是正确的(至少它们在我的XNA渲染器中工作良好),我看到的是在屏幕上正确绘制了白色多边形

从上面的代码中,我应该看到各种颜色,因为我用随机字节数填充SquareColor(我已经验证SquareColor是用随机字节填充的),但我没有,顶点都被绘制为白色

我还尝试绑定纹理(通过GL.BindTexture),但也失败了

你知道为什么这样不行吗

编辑:当我添加到启用颜色时(请参阅本文的第一条评论),应用程序崩溃,输出如下:

堆栈跟踪:

at(包装器管理为本机) OpenTK.Graphics.ES11.GL/Core.drawArray (OpenTK.Graphics.ES11.All,int,int)在 OpenTK.Graphics.ES11.GL.drawArray (OpenTK.Graphics.ES11.All,int,int) [0x00000]英寸 /Users/plasma/Source/iphone/monotouch/OpenGLES/OpenTK/Graphics/ES11.iphone/GL.cs:1326 在Jabber.J3D.Shape.Draw_IOS()处 [0x00171]英寸 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/MyCode/Engine/J3D/Shape_iOS.cs:136 位于Jabber.J3D.Shape.Draw()[0x00000] 在里面 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/MyCode/Engine/J3D/Shape.cs:255 在Jabber.J3D.PhysicShape.Draw()上 [0x00000]英寸 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/MyCode/Engine/J3D/PhysicShape.cs:46 在Jabber.Scene.gamesence.Draw()中 [0x0001d]英寸 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/MyCode/Engine/Scene/gamesence.cs:299 在 Jabber.GameScreenManager.Screen.Draw ()[0x0001f]英寸 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/MyCode/Engine/GameScreenManager/Screen.cs:150 在 ChicksnVixens.Screens.GameplayScreen.Draw ()[0x00000]英寸 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/MyCode/ChicksnVixens/Screens/GameplayScreen.cs:481 在 Jabber.GameScreenManager.ScreenManager.Draw ()[0x00054]英寸 /Users/ahmedhakeem/Documents/Projects/JabberEngine2/MyCode/Engine/GameScreenManager/ScreenManager.cs:92 在Jabber.BaseGame.Draw (Microsoft.Xna.Framework.GameTime) [0x0002c]英寸 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/MyCode/Engine/BaseGame.cs:95 在 ChicksnVixens.ChicksnVixensGame.Draw (Microsoft.Xna.Framework.GameTime) [0x00000]英寸 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/MyCode/ChicksnVixens/ChicksnVixensGame.cs:414 在Microsoft.Xna.Framework.Game.DoDraw (Microsoft.Xna.Framework.GameTime) [0x0001e]英寸 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/ExEn/ExEnCommon/Game/GameCommon.cs:205 在 Microsoft.Xna.Framework.ExEnEmTouchGameView.OnRenderFrame (OpenTK.FrameEventArgs)[0x0002e]位于 /Users/ahmedhakeem/Documents/Projects/jabbrengine2/ExEn/ExEnEmTouch/ExEnEmTouchGameView.cs:329 在 OpenTK.Platform.iPhoneOS.iPhoneOSGameView.RunIteration ()[0x000af]英寸 /Users/plasma/Source/iphone/monotouch/OpenGLES/OpenTK/Platform/iPhoneOS/iPhoneOSGameView.cs:592 在 单调的基础 ()[0x00000]英寸 /Users/plasma/Source/iphone/monotouch/shared/Foundation/NSAction.cs:45 在(包装器运行时调用) object.runtime\u调用\u无效\u此_ (对象,intptr,intptr,intptr)位于(包装器) 管理到本地) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr)位于 MonoTouch.UIKit.UIApplication.Main (字符串[],字符串,字符串)[0x00038]输入 /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26 在ChicksnVixens.Program.Main (字符串[])中的[0x00000] /用户/ahmedhakeem/Documents/Projects/Jabbrengine2/MyCode/ChicksnVixens/MonoTouch 程序。cs:24 at(包装器) 运行时调用) .runtime\u invoke\u void\u对象 (对象,intptr,intptr,intptr)

本机堆栈跟踪:

0个缺口
0x000c5d00单声道句柄本机sigsegv +343 1 aChicks 0x0000fce0单信号信号处理器 +322 2 libSystem.B.dylib 0x95fee48b\u sigtramp+43 3???
0xFFFFFFFF0x0+4294967295 4
格伦尼
0x08645753 gleLLVMArrayFunc+67 5
格伦尼
0x0863cba2 GledrawArraySoreElements_ExecCore+856 6格伦吉尼
0x08642bbe glDrawArrays\u IMM\u Exec+332 7个开口
0x0087c308 glDrawArrays+57 8??? 0x0c3c9b34 0x0+205298484 9???
0x0c3c9a9c 0x0+205298332 10???
0x0f0956c8 0x0+252270280 11???
0x0f0939c4 0x0+252262852 12???
0x0f09397c 0x0+252262780 13???
0x0ecdb286 0x0+2483616014???
0x0c3c709a 0x0+205287578 15
byte[] squareColors = new byte[simpleVertices.Count * 3];
Random.NextBytes(squareColors);
GL.ColorPointer (3, All.UnsignedByte, 0, squareColors);
glEnable(GL_TEXTURE_2D);