actually i dont need to draw an entire quad transparent.let me tell it clearly first.
1)I have a blue background PNG.which i draw first.No transperancy nothing.
2)then i draw an image with buildings in that image except the buildings rest are transparent.(understood).
3)now the scene should render something like blue background beyond buildings.
I’ll post the code without blending enabled.cuz i am not sure where to add the blending code.
this is my main file.
#include "untitledGame.h"
#include "GameContainer.h"
#include "AppGame.h"
untitledGame::untitledGame(void)
{
}
void untitledGame::init() {
ss.loadImage("untitled.png");
//man.loadImage("man.png");
map.loadImage("map.png");
}
void untitledGame::update() {
}
void untitledGame::render() {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
ss.drawImage(0,0,800,600);
map.drawImage(0,0,800,600);
SDL_GL_SwapBuffers();
}
untitledGame::~untitledGame(void)
{
}
int main(int argc,char** argv) {
untitledGame ug;
AppGame apg;
apg.initializeEverything(800,600,false);
return apg.startGame(ug);
}
this is loadImage and drawImage.basically they are just making the texture and binding them to quads.
#include "Images.h"
Images::Images(void)
{
}
int Images::loadImage(const char* filename) {
glBindTexture( GL_TEXTURE_2D, texture[0] );
SDL_Surface *TextureImage[1];
if ( ( TextureImage[0] = IMG_Load(filename ) ) )
{
glGenTextures( 1, &texture[0] );
glBindTexture( GL_TEXTURE_2D, texture[0] );
glTexImage2D( GL_TEXTURE_2D, 0, 3, TextureImage[0]->w,
TextureImage[0]->h, 0, GL_RGBA,
GL_UNSIGNED_BYTE, TextureImage[0]->pixels );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
}
if ( TextureImage[0] )
SDL_FreeSurface( TextureImage[0] );
return 0;
}
int Images::drawImage(float x,float y,int width,int height) {
glBindTexture(GL_TEXTURE_2D,texture[0]);
glBegin(GL_QUADS);
glTexCoord2f( 0.0f, 1.0f ); glVertex3f( x, y, 0 );
glTexCoord2f( 1.0f, 1.0f ); glVertex3f( width, y, 0 );
glTexCoord2f( 1.0f, 0.0f ); glVertex3f( width,height, 0 );
glTexCoord2f( 0.0f, 0.0f ); glVertex3f( x,height, 0 );
glEnd();
return 0;
}
Images::~Images(void)
{
}