簡體   English   中英

如何在OpenGL中加載圖像

[英]how to load an image in opengl

我需要將圖片上傳到我的背景中...有人知道該怎么做嗎? 我知道我必須執行以下步驟:

1) Load image data into system memory
2) Generate a texture name with glGenTextures
3) Bind the texture name with gBindTexture
4) Set wrapping and filtering mode with glTexParameter
5) call glTexImage2D with the right parameters depending on the image nature to load image data into video memory

但我不知道如何將它們放入opengl

OpenGL支持紋理和圖像...但是用戶需要提供數據。 因此,您必須使用sme庫或其他代碼來加載數據。

我建議使用非常簡單的lib SOIL- http://www.lonesock.net/soil.html或您的SDK提供的某些庫

一般來說:

load texture bytes into pBytes;
glTexImage2D(..., ..., ..., pBytes);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM