现在在编那个opengl程序
下面是有问题的一下段 请大家帮我分析一下:
int CMyView::LoadGLTextures()
{
int Status=FALSE; // Status Indicator AUX_RGBImageRec *TextureImage[3]; // Create Storage Space For The Texture memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL if (TextureImage[0]=LoadBMP("Star.bmp"))
{
Status=TRUE; // Set The Status To TRUE glGenTextures(1, &textures[0]); // Create One Texture glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
//////
if (TextureImage[1]=LoadBMP("Star.bmp"))
{
Status=TRUE; // Set The Status To TRUE glGenTextures(1, &textures[1]); // Create One Texture glBindTexture(GL_TEXTURE_2D, textures[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[1]->data);
}
/////
if (TextureImage[2]=LoadBMP("Star.bmp"))
{
Status=TRUE; // Set The Status To TRUE glGenTextures(1, &textures[2]); // Create One Texture glBindTexture(GL_TEXTURE_2D, textures[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[2]->sizeX, TextureImage[2]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[2]->data);
}
if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
} free(TextureImage[0]); // Free The Image Structure
}
if (TextureImage[1]) // If Texture Exists
{
if (TextureImage[1]->data) // If Texture Image Exists
{
free(TextureImage[1]->data); // Free The Texture Image Memory
} free(TextureImage[1]); // Free The Image Structure
}
if(TextureImage[2])
{
if(TextureImage[2]->data)
{
free(TextureImage[2]->data);
}
free(TextureImage[2]);
}
return Status; }
每次编译的时候都有下面这个错误:
--------------------Configuration: 滚动烟花 - Win32 Debug--------------------
Compiling...
滚动烟花View.cpp
D:\vc的程序作业\滚动烟花\滚动烟花View.cpp(309) : error C2664: 'glGenTextures' : cannot convert parameter 2 from 'int *' to 'unsigned int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\vc的程序作业\滚动烟花\滚动烟花View.cpp(322) : error C2664: 'glGenTextures' : cannot convert parameter 2 from 'int *' to 'unsigned int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\vc的程序作业\滚动烟花\滚动烟花View.cpp(334) : error C2664: 'glGenTextures' : cannot convert parameter 2 from 'int *' to 'unsigned int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.滚动烟花.exe - 3 error(s), 0 warning(s)等待中谢谢!
下面是有问题的一下段 请大家帮我分析一下:
int CMyView::LoadGLTextures()
{
int Status=FALSE; // Status Indicator AUX_RGBImageRec *TextureImage[3]; // Create Storage Space For The Texture memset(TextureImage,0,sizeof(void *)*1); // Set The Pointer To NULL if (TextureImage[0]=LoadBMP("Star.bmp"))
{
Status=TRUE; // Set The Status To TRUE glGenTextures(1, &textures[0]); // Create One Texture glBindTexture(GL_TEXTURE_2D, textures[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
}
//////
if (TextureImage[1]=LoadBMP("Star.bmp"))
{
Status=TRUE; // Set The Status To TRUE glGenTextures(1, &textures[1]); // Create One Texture glBindTexture(GL_TEXTURE_2D, textures[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[1]->sizeX, TextureImage[1]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[1]->data);
}
/////
if (TextureImage[2]=LoadBMP("Star.bmp"))
{
Status=TRUE; // Set The Status To TRUE glGenTextures(1, &textures[2]); // Create One Texture glBindTexture(GL_TEXTURE_2D, textures[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[2]->sizeX, TextureImage[2]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[2]->data);
}
if (TextureImage[0]) // If Texture Exists
{
if (TextureImage[0]->data) // If Texture Image Exists
{
free(TextureImage[0]->data); // Free The Texture Image Memory
} free(TextureImage[0]); // Free The Image Structure
}
if (TextureImage[1]) // If Texture Exists
{
if (TextureImage[1]->data) // If Texture Image Exists
{
free(TextureImage[1]->data); // Free The Texture Image Memory
} free(TextureImage[1]); // Free The Image Structure
}
if(TextureImage[2])
{
if(TextureImage[2]->data)
{
free(TextureImage[2]->data);
}
free(TextureImage[2]);
}
return Status; }
每次编译的时候都有下面这个错误:
--------------------Configuration: 滚动烟花 - Win32 Debug--------------------
Compiling...
滚动烟花View.cpp
D:\vc的程序作业\滚动烟花\滚动烟花View.cpp(309) : error C2664: 'glGenTextures' : cannot convert parameter 2 from 'int *' to 'unsigned int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\vc的程序作业\滚动烟花\滚动烟花View.cpp(322) : error C2664: 'glGenTextures' : cannot convert parameter 2 from 'int *' to 'unsigned int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
D:\vc的程序作业\滚动烟花\滚动烟花View.cpp(334) : error C2664: 'glGenTextures' : cannot convert parameter 2 from 'int *' to 'unsigned int *'
Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Error executing cl.exe.滚动烟花.exe - 3 error(s), 0 warning(s)等待中谢谢!
解决方案 »
- MFC中单文档工程中关于启动视类问题?
- 关于鼠标单击消息的处理问题
- 请问什么方法可以速度最快的知道一个IP是否是通的?
- 大家谁见过这种多线程socket程序,是我没学好,还是这种模型不对
- 下午2点结帖: 硕士生惭愧请教: 在不卸载Adobet前提下,如何取消IE或Netscape直接打开PDF文件的关联?只想让它save as.
- 一个win32application应用程序和一个mfc(exe)应用程序在建立无模式对话框时有何不同?
- 谁能帮助我 --- 漂亮的界面源代码?
- 请介绍一本讲SQL语言比较好的书
- 谁告诉我哪里有关于COM的中英文资料?最好是深而全的,谢谢。
- 数据库编程的问题
- 如何查找资源泄漏?
- 请教高手:按钮控件问题
glGenTextures(1, &texture[0]);ur texture is defined as this?
GLuint textures[3];不知道为什么会这样
告诉OpenGL我们要创建三个纹理,它们将存放在texture[0], texture[1] 和 texture[2] 中。
楼主只是要加载一个纹理.我认为只要这样写就可以了啊
--------------------------------------------------------
int LoadGLTextures()
{
int Status=FALSE; // Status 状态指示器
AUX_RGBImageRec *TextureImage[1]; // 创建纹理的存储空间
memset(TextureImage,0,sizeof(void *)*1); // 将指针设为 NULL
LPCWSTR filename = _T("Star.bmp");
TextureImage[0] = auxDIBImageLoad (filename); if (TextureImage[0])
{
Status=TRUE; // 将 Status 设为 TRUE
glGenTextures(3, &texture[0]); // 创建纹理
// 创建 Nearest 滤波贴图
glBindTexture(GL_TEXTURE_2D, texture[0]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // ( 新增 )
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST); // ( 新增 )
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// 创建线性滤波纹理
glBindTexture(GL_TEXTURE_2D, texture[1]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, 0, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data);
// 创建 MipMapped 纹理
glBindTexture(GL_TEXTURE_2D, texture[2]);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST); // ( 新增 )
gluBuild2DMipmaps(GL_TEXTURE_2D, 3, TextureImage[0]->sizeX, TextureImage[0]->sizeY, GL_RGB, GL_UNSIGNED_BYTE, TextureImage[0]->data); //( 新增 )
}
if (TextureImage[0]) // 纹理是否存在
{
if (TextureImage[0]->data) // 纹理图像是否存在
{
free(TextureImage[0]->data); // 释放纹理图像占用的内存
}
free(TextureImage[0]); // 释放图像结构
}
return Status; }
glGenTextures(2, &textures[1]);
glGenTextures(3, &textures[2]);