Comments (3)
here the code
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
using static OpenGL.GL;
namespace TheRaft.Core.Graphics
{
internal class Texture
{
public uint id;
public unsafe Texture(string name)
{
string path = "C:/.TheRaft/Textures/" + name;
Image i = Image.FromFile(path);
byte[] data = (byte[])(new ImageConverter()).ConvertTo(i, typeof(byte[]));
fixed (byte* p = data)
{
IntPtr ptr = (IntPtr)p;
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT);
float[] borderColor = { 1.0f, 1.0f, 0.0f, 1.0f };
fixed (float* pt = &borderColor[0]) {
glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, pt);
}
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
id = glGenTexture();
glBindTexture(GL_TEXTURE_2D, id);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, i.Width, i.Height, 0, GL_RGB, GL_UNSIGNED_BYTE, ptr);
glGenerateMipmap(GL_TEXTURE_2D);
};
}
}
}
from glfw-net.
fixed, was not allocating the memory for the texture
from glfw-net.
Glad you got it figured out, but one word of warning if you are using the OpenGL bindings from the example project:
They are not thoroughly tested nor even "officially" part of this project, were simply generated via a dirty script I wrote on a fixed GL version using the OpenGL registry, and were merely provided as convenience to test this project with. While they will likely suffice for most cases without any issue, I would not personally consider them production-ready, nor exactly the most user-friendly.
from glfw-net.
Related Issues (20)
- Glfw.GetKeyName(Keys key, int scanCode) throws internal exception when used with non-printable key HOT 2
- Unable to load shared library 'glfw' or one of its dependencies HOT 2
- AcessViolation in FileDrop event HOT 1
- Why GLFW.NET does't see the Vulkan? HOT 10
- A callback was made on a garbage collected delegate of type 'GLFW.NET!GLFW.MouseCallback::Invoke'. HOT 4
- BadImageFormatException on .NET framework 4.7.2 via NuGet and source HOT 2
- Application crashes when running on x86 HOT 11
- Build GLFW-Net in .NET 5 ? HOT 1
- GLFW doesn't initialize HOT 2
- GLFW.Exception WGL: OpenGL profile requested but WGL_ARB_create_context_profile is unavailable HOT 2
- MouseEventArgs.cs Where is Type "Point"
- GLFW Keeps calling Garbage Collected Fields HOT 2
- Resizing Problem when using Skia HOT 4
- Illegal `glfwDestroyWindow` in window close handler HOT 2
- GLFW.Exception: Cannot set swap interval without a current OpenGL or OpenGL ES context HOT 1
- Glfw SetWindowPositionCallback Bug
- Calling .Fullscreen() causes an exception.
- Update Nuget Package
- AOT - Ahead of Time | native code compiling HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from glfw-net.