主题:Opengl中球体贴图
#include <Windows.h>
#include <gl/glew.h>
#include <gl/glpng.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
GLuint ima;
pngInfo info;
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glPopMatrix();
glTranslatef(0.0,0.0,-10);
glBindTexture(GL_TEXTURE_2D,ima);
GLUquadricObj* qObj=gluNewQuadric();
gluQuadricTexture(qObj,GL_TRUE);
gluSphere(qObj,1.0,20,20);
glPushMatrix();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GL_DOUBLE|GL_RGB);
glutInitWindowSize(600, 600);
glutCreateWindow("test");
#if 0
glGenTextures(1, &ima);
glBindTexture(GL_TEXTURE_2D, ima);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
if (!pngLoad("earth.png", PNG_NOMIPMAP, PNG_SOLID, &info)) {
puts("Can't load file");
exit(1);
}
#else
ima = pngBind("earth.png", PNG_NOMIPMAP, PNG_ALPHA, &info, GL_CLAMP, GL_NEAREST, GL_NEAREST);
if (ima == 0) {
puts("Can't load file");
exit(1);
}
#endif
printf("Size=%i,%i Depth=%i Alpha=%i\n", info.Width, info.Height, info.Depth, info.Alpha);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,ima);
glEnable(GL_CULL_FACE);
glColor3f(1.0,1.0,1.0);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
我这程序怎么了,编译运行后竟然报了这个错误!
pixel format with necessary capabilities not found
#include <gl/glew.h>
#include <gl/glpng.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
GLuint ima;
pngInfo info;
void display()
{
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glPopMatrix();
glTranslatef(0.0,0.0,-10);
glBindTexture(GL_TEXTURE_2D,ima);
GLUquadricObj* qObj=gluNewQuadric();
gluQuadricTexture(qObj,GL_TRUE);
gluSphere(qObj,1.0,20,20);
glPushMatrix();
glFlush();
}
int main(int argc, char** argv)
{
glutInit(&argc,argv);
glutInitDisplayMode(GL_DOUBLE|GL_RGB);
glutInitWindowSize(600, 600);
glutCreateWindow("test");
#if 0
glGenTextures(1, &ima);
glBindTexture(GL_TEXTURE_2D, ima);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
if (!pngLoad("earth.png", PNG_NOMIPMAP, PNG_SOLID, &info)) {
puts("Can't load file");
exit(1);
}
#else
ima = pngBind("earth.png", PNG_NOMIPMAP, PNG_ALPHA, &info, GL_CLAMP, GL_NEAREST, GL_NEAREST);
if (ima == 0) {
puts("Can't load file");
exit(1);
}
#endif
printf("Size=%i,%i Depth=%i Alpha=%i\n", info.Width, info.Height, info.Depth, info.Alpha);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D,ima);
glEnable(GL_CULL_FACE);
glColor3f(1.0,1.0,1.0);
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
我这程序怎么了,编译运行后竟然报了这个错误!
pixel format with necessary capabilities not found