我返回的数据不会影响void函数保护的重写的内部

问题描述

我正在将位图帧发送到下面的“加载”功能。 LoadTexture函数在GenTexture中将数据返回为“ 1”并将其设置为纹理。当我调试时,我看到纹理返回“ 1”。但这不会影响“ OnRenderFrame”函数中的数据。我必须使用带有受保护的覆盖的OnRenderFrame。

public void Load(Bitmap bitmap)
{
    texture = LoadTexture(bitmap);
}

public int LoadTexture(Bitmap file)
{
    Bitmap bitmap = file;
    int tex;

    GL.Hint(HintTarget.PerspectiveCorrectionHint,HintMode.Nicest);

    GL.GenTextures(1,out tex);
    GL.BindTexture(TextureTarget.Texture2D,tex);

    BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0,bitmap.Width,bitmap.Height),ImageLockMode.ReadOnly,System.Drawing.Imaging.PixelFormat.Format8bppIndexed);

    GL.TexImage2D(TextureTarget.Texture2D,PixelInternalFormat.Luminance,data.Width,data.Height,OpenTK.Graphics.OpenGL.PixelFormat.Luminance,PixelType.UnsignedByte,data.Scan0);
    bitmap.UnlockBits(data);


    GL.TexParameter(TextureTarget.Texture2D,TextureParameterName.TextureMinFilter,(int)TextureMinFilter.Linear);
    GL.TexParameter(TextureTarget.Texture2D,TextureParameterName.TextureMagFilter,(int)TextureMagFilter.Linear);
    GL.TexParameter(TextureTarget.Texture2D,TextureParameterName.TextureWrapS,(int)TextureWrapMode.Repeat);
    GL.TexParameter(TextureTarget.Texture2D,TextureParameterName.TextureWrapT,(int)TextureWrapMode.Repeat);
    return tex;
}


protected override void OnRenderFrame(FrameEventArgs e)
{
    Title = $"(Vsync: {VSync}) FPS: {1f / e.Time:0}";

    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

    DrawImage(texture);
    Console.WriteLine(texture);
    SwapBuffers();
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...