使用纯 OpenGL 加载 PNG 文件 [英] Load a PNG file with pure OpenGL

查看:92
本文介绍了使用纯 OpenGL 加载 PNG 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试用 Java 制作一个简单的游戏.

I am trying to make a simple game in Java.

我想知道如何仅使用 OpenGL 库读取 PNG 文件并在游戏中使用它.

I want to know how I can read a PNG file and use it in the game using only the OpenGL library.

谁能提供任何可以实现这一点的代码?

Can anyone provide any code that could accomplish this?

推荐答案

您无法使用单个 API 调用直接加载纹理.但是,您可以通过 ImageIO 加载 BufferedImage,然后将其转换为 OpenGL 纹理.示例源代码可以在这里找到 纹理加载器

You can't load a texture directly using a single API call. You can however load a BufferedImage through ImageIO, and then convert it to an OpenGL texture. Example source code can be found here TextureLoader

这篇关于使用纯 OpenGL 加载 PNG 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆