Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: problem with examples/opengl/opengl.cs @55  (Read 4019 times)

0 Members and 1 Guest are viewing this topic.

globalenemy

  • Newbie
  • *
  • Posts: 10
    • View Profile
problem with examples/opengl/opengl.cs @55
« on: March 20, 2016, 12:45:30 pm »
Hello,
I'm trying to get an sfml opengl application to run. I've built a state-engine and made it work with sfml. Now I want to add opengl functionality, so I went down to test the opengl example.

The example from the Download doesn't compile for me. (What is "Glu.Build2DMipmap.."?)
So I went to GitHub and took the example from there wich has ALOT of changes in it.

This example would compile but Visual Studio throws me the following exception at line 55, when running the code:

Quote
An unhandled exception of type 'System.AccessViolationException' occurred in OpenTK.dll

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

using (Image image = new Image("resources/texture.jpg")) {
   GL.GenTextures(1, out texture);
   GL.BindTexture(TextureTarget.Texture2D, texture);
   // Here's the line:
   GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)image.Size.X, (int)image.Size.Y, 0, PixelFormat.Rgba, PixelType.UnsignedByte, image.Pixels);
   GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
   GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
}

Note: I have no idea what I'm doing here yet. OpenGL is a complete new field for me.

To the GitHub-Page: https://github.com/SFML/SFML.Net/tree/master/examples/opengl
« Last Edit: March 20, 2016, 12:48:40 pm by globalenemy »

globalenemy

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: problem with examples/opengl/opengl.cs @55
« Reply #1 on: March 20, 2016, 01:50:14 pm »
I Managed to compile the downloaded example, which didn't work earlier.

Now Visual Studio is saying:
Quote
'Glu' is obsolete: 'Use OpenTK math functions instead.'

OpenTK.Graphics.Glu.Build2DMipmap(OpenTK.Graphics.TextureTarget.Texture2D, (int)PixelInternalFormat.Rgba, (int)image.Size.X, (int)image.Size.Y, OpenTK.Graphics.PixelFormat.Rgba, OpenTK.Graphics.PixelType.UnsignedByte, image.Pixels);

what exactly does that mean? An equivalent doesn't seem to be present in that context, so how do I do what would have been done with the 'Glu' context?
« Last Edit: March 20, 2016, 02:22:31 pm by globalenemy »

tucker87

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: problem with examples/opengl/opengl.cs @55
« Reply #2 on: April 08, 2016, 03:06:51 am »
I'm having the same problems. About to start digging through the forums for answers...

tucker87

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: problem with examples/opengl/opengl.cs @55
« Reply #3 on: April 08, 2016, 03:20:23 am »
Found a thread with a fix.

Replaced
var context = new GraphicsContext(new ContextHandle(IntPtr.Zero), null);

With
var wi = Utilities.CreateWindowsWindowInfo(window.SystemHandle);
var ctx = new GraphicsContext(GraphicsMode.Default, wi);
ctx.MakeCurrent(wi);
ctx.LoadAll();

I'm not sure this is the right way to go. But it works at least.

 

anything