Using Devil
I am trying to create a program that displays a quad texture on it. I try to use Devil to load images but I didnt find a good example code or any tutorial for it. What's the problem and how to fix it?
So i tried something like this:
// in WinMain
ILuint texture = 0;
ilInit();
if (!CreateWnd(800, 600, "OpenGL window")) return 0;
ilutRenderer(ILUT_OPENGL);
ilGenImages(1, &texture);
ilBindImage(texture);
ilLoadImage("keke.bmp");
glTexImage2D(GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_RGB, GL_UNSIGNED_BYTE, ilGetData());
if(ilGetError() != IL_NO_ERROR) MessageBox(NULL, "Error", "Info", MB_OK);
glViewport(0, 0, 800, 600);
glMatrixMode(GL_PROJECTION);
gluOrtho2D(0, 800, 0, 600);
glMatrixMode(GL_MODELVIEW);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, texture);
while(1)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message==WM_QUIT) break;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
else
{
glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0, 0, -5);
glBegin(GL_QUADS);
glColor3f(1, 0, 0);
glTexCoord2f(0, 0);
glVertex3f(-1, 1, 0);
glTexCoord2f(1, 0);
glVertex3f( 1, 1, 0);
glTexCoord2f(1, 1);
glVertex3f( 1, -1, 0);
glTexCoord2f(0, 1);
glVertex3f(-1, -1, 0);
glEnd();
SwapBuffers(hdc);
}
}
ilDeleteImages(1, &texture);
[Edited by - Liquid_Vision on February 8, 2005 3:02:52 PM]
Tiritomba
That texture mapping tutorial Lesson 6 on nehe.gamedev.net is also available in OpenIL(Devil) but its for Visual C++ and I tried to compile it with Dev-C++ and an error occured during the program was running. No errors when compiling. There are not so much differences between Visual C++ and Dev-C++ so i wonder if that code example works on Visual C++ either..
I would be really happy if someone tried to help me
I would be really happy if someone tried to help me
Tiritomba
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement