[英]How to add an image file in opengl using Texture?
#include <stdio.h>
#include <glut.h>
void display() {
glClear(GL_COLOR_BUFFER_BIT);
int initlist=glGenLists(1);
glNewList(initlist,GL_COMPILE);
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
//GLuint texture = loa // load an image file directly as a new OpenGL texture
glBindTexture(GL_TEXTURE_2D,texture);
glPushMatrix();
glTranslatef(0,0,0);
glBegin(GL_POLYGON);
glEnd();
glPopMatrix();
glEndList();
glFlush();
}
我不知道如何為紋理 生成 圖像位置 代碼 。 我想使用道路圖像,並打算將該圖像用作高速公路。但是我無法獲得圖像位置。 我如何獲得該位置並將其用於glBindTexture()函數 ?
您必須使用glTextImage2D傳遞圖像原始數據,您可以使用外部庫加載圖像。 有很多圖書館。 我個人喜歡SFML 。
編輯:必須使用glGenTexture創建紋理並獲取“紋理位置”。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.