#include "scene.h"
scene::scene(gameScreen* parent)
{
creator = parent;
loadTexture("./water.png", backgroundID);
width = creator->width();
height = creator->height();
}
void scene::resize(int w, int h)
{
width = w;
height = h;
}
void scene::draw()
{
glEnable(GL_TEXTURE_2D);
glColor3f(1,1,1);
glBindTexture( GL_TEXTURE_2D, backgroundID );
/*QImage im("./water.png");
QImage tex = QGLWidget::convertToGLFormat(im);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.width(), tex.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, tex.bits());
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);*/
glBegin(GL_QUADS);
glTexCoord2d(0,0);glVertex3d(0,0,-1);
glTexCoord2d(1,0);glVertex3d(width,0,-1);
glTexCoord2d(1,1);glVertex3d(width,height,-1);
glTexCoord2d(0,1);glVertex3d(0,height,-1);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void scene::loadTexture (char *filename, GLuint &textureID)
{
glEnable(GL_TEXTURE_2D); // Enable texturing
glGenTextures(1, &textureID); // Obtain an id for the texture
glBindTexture(GL_TEXTURE_2D, textureID); // Set as the current texture
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.width(), tex.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, tex.bits());
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glDisable(GL_TEXTURE_2D);
}
#include "scene.h"
scene::scene(gameScreen* parent)
{
creator = parent;
loadTexture("./water.png", backgroundID);
width = creator->width();
height = creator->height();
}
void scene::resize(int w, int h)
{
width = w;
height = h;
}
void scene::draw()
{
glEnable(GL_TEXTURE_2D);
glColor3f(1,1,1);
glBindTexture( GL_TEXTURE_2D, backgroundID );
/*QImage im("./water.png");
QImage tex = QGLWidget::convertToGLFormat(im);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.width(), tex.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, tex.bits());
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);*/
glBegin(GL_QUADS);
glTexCoord2d(0,0);glVertex3d(0,0,-1);
glTexCoord2d(1,0);glVertex3d(width,0,-1);
glTexCoord2d(1,1);glVertex3d(width,height,-1);
glTexCoord2d(0,1);glVertex3d(0,height,-1);
glEnd();
glDisable(GL_TEXTURE_2D);
}
void scene::loadTexture (char *filename, GLuint &textureID)
{
glEnable(GL_TEXTURE_2D); // Enable texturing
glGenTextures(1, &textureID); // Obtain an id for the texture
glBindTexture(GL_TEXTURE_2D, textureID); // Set as the current texture
QImage im(filename);
QImage tex = QGLWidget::convertToGLFormat(im);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, tex.width(), tex.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, tex.bits());
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glDisable(GL_TEXTURE_2D);
}
To copy to clipboard, switch view to plain text mode
Bookmarks