Original Post
I am having a problem with blending models. I am finding that when alpha is zero then that material is rendered in the glClearColor and in varying scales til it appears in the correct colour when alpha=1. My initialisation code is as follows: If anyone can suggest where the problem may lie I would love to hear your ideas. Thanks
void
FL_controller::init()
{
initSDL();
init_openGL();
scene = new Scene_manager();
scene->initScene();
glTexEnvi(GL_TEXTURE_2D, GL_TEXTURE_ENV_MODE, GL_MODULATE);
skybox = loadTexture("textures/skybox.png");
}
void
FL_controller::initSDL()
{
//initialise context
if (SDL_Init(subsystems) < 0)
{
std::cerr << "Video initialization failed: " << SDL_GetError();
SDL_Quit();
}
//get video information
const SDL_VideoInfo* info = SDL_GetVideoInfo();
if ( info == NULL)
{
std::cerr << "Video query failed: " << SDL_GetError();
SDL_Quit();
}
//set attributes
display_bit_depth = info->vfmt->BitsPerPixel;
//set vid mode
if (SDL_SetVideoMode(display_width, display_height, display_bit_depth, video_flags) == 0)
if ( info == NULL)
{
std::cerr << "Failed to set video mode : " << SDL_GetError();
SDL_Quit();
}
//use bit_depth to hold openGL state query results
GLint bit_depth;
//query openGL for RGB and depth bit size and set in SDL
glGetIntegerv(GL_RED_BITS, &bit_depth);
SDL_GL_SetAttribute( SDL_GL_RED_SIZE, bit_depth );
glGetIntegerv(GL_GREEN_BITS, &bit_depth);
SDL_GL_SetAttribute( SDL_GL_GREEN_SIZE, bit_depth );
glGetIntegerv(GL_BLUE_BITS, &bit_depth);
SDL_GL_SetAttribute( SDL_GL_BLUE_SIZE, bit_depth );
glGetIntegerv(GL_ALPHA_BITS, &bit_depth);
SDL_GL_SetAttribute( SDL_GL_ALPHA_SIZE, bit_depth );
glGetIntegerv(GL_DEPTH_BITS, &bit_depth);
SDL_GL_SetAttribute( SDL_GL_DEPTH_SIZE, bit_depth );
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
//Set the window tile and icon
SDL_WM_SetCaption("Far Light", "Far Light");
SDL_WM_SetIcon(SDL_LoadBMP("icon.bmp"), NULL);
//set cursor
setCursor();
}