migueltk's picture

Glu is really obsolete, Glu.Build2DMipmap is an exception?

Hello, ...

As implemented "Glu.Build2DMipmap" without using Glu, I know how to do it. Does anyone know how to do it? ...

Programming using "OpenTK.dll is very easy but using both" OpenTK.Compatibility.dll "is a real problem, there are constantly name collisions.

OpenTK should be limited to the creation and support of the windows, mouse, keyboard, sound, and exclude the mathematical library. When you have your own mathematical library with the most common names "Vector3", "Matrix", there are constantly name collisions.

It is my opinion.

Regards, ...


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Glu.Build2DMipmap is obsolete and has been obsolete for close to a decade:

GL.GenerateMipmap(); // for OpenGL 3.x
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); // for OpenGL 1.4-2.1

Barring (bad, obsolete) tutorials, noone should be using Glu.Build2DMipmap nowadays.

You can avoid name collisions by being more frugal with namespace imports:

// Pick one, not both, when using OpenTK.Compatibility.dll
using OpenTK.Graphics;
using OpenTK.Graphics.OpenGL;
 
// Avoid "using OpenTK" in code that uses a different math library
using OpenTK;
using MyOwnMathLibrary;

In retrospect, it was probably a mistake to move math structures to the OpenTK namespace. Oh well, live and learn, maybe this can be reevaluated for some future 2.0 release.

migueltk's picture

True "Glu.Build2DMipmap" is outdated and I had the solution in the book "OpenGL Superbible 2" Chapter 8, I've only had to replace the line

Glu.Build2DMipmap(TextureTarget.Texture2D, (int)PixelInternalFormat.Rgba, data.Width, data.Height, PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

by the following code

// Requieres OpenGL >= 1.4
GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.GenerateMipmap, 1); // 1 = True
GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

thanks for your answer, every day you learn something new ...

exe's picture

Problem: GL.GenerateMipmap(); and TextureParameterName.GenerateMipmap both don't work on Ati Radeon X1400.

Only Glu.Build2DMipmap() works. But with Glu method these lines don't work:

                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Nearest);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMaxLevel, 4);

I use them to stop creating highest levels of mipmaps which would blend together different textures in texture atlas.

Probably the only solution is to create mipmaps manually.