GithubHelp home page GithubHelp logo

Comments (3)

theLemon505 avatar theLemon505 commented on August 26, 2024

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.

theLemon505 avatar theLemon505 commented on August 26, 2024

fixed, was not allocating the memory for the texture

from glfw-net.

ForeverZer0 avatar ForeverZer0 commented on August 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.