About opengl screen shot is black
-
shot.h
/*
Class Name:CTGALoader. This class loads a tga texture into this object. shot.h
*/
#ifndef CTGALOADER_H
#define CTGALOADER_H// Remember to place all your GL/system header files that you will need to run class function
class CTGALoader
{
public:
CTGALoader(); // Constructor.
~CTGALoader(); // Destructor.bool LoadTGAFile(char \*filename); // Load a .tga image file. void SaveTGAScreenShot(char \*filename, int width, int height); // Save a .tga screen shot. void FreeImage(); // Delete a image. unsigned int ID; // ID used for generating the textures in OpenGl. int imageWidth; // Width of a texture. int imageHeight; // Height of a texture.
protected:
void GenerateTexture(); // Generate a texture in OpenGL.
bool LoadTGA(char *filename); // Load a tga image.
bool WriteTGA(char *file, short int width,
short int height,
unsigned char *image); // Write a tga file.unsigned char \*image; // Texture image. bool textureExist; // This will be used if the image was loaded. int type; // Image format.
};
#endif
shot.cpp
/*
Class Name:CTGALoader. shot.h
*/
#include"shot.h"
#include
#include <./gl/GL.H>
#include <./gl/GLU.H>
#include#pragma comment(lib,"OPENGL32.LIB")
#pragma comment(lib,"Glu32.lib")CTGALoader::CTGALoader()
{
// Give everything default values.
image = 0;
textureExist = false;
type = 0;
}CTGALoader::~CTGALoader()
{
FreeImage(); // Delete all images and dynamic memory.
}bool CTGALoader::LoadTGAFile(char *file)
{
if(textureExist)
FreeImage();if(!LoadTGA(file))
return false;// Make sure the image loaded.
if(image == 0)
{
return false;
}GenerateTexture();
textureExist = true;
return true;
}void CTGALoader::GenerateTexture()
{
// Generate the texture and text the id to the images id.
glGenTextures(1, &ID);// Here we bind the texture and set up the filtering.
glBindTexture(GL_TEXTURE_2D, ID);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); -
shot.h
/*
Class Name:CTGALoader. This class loads a tga texture into this object. shot.h
*/
#ifndef CTGALOADER_H
#define CTGALOADER_H// Remember to place all your GL/system header files that you will need to run class function
class CTGALoader
{
public:
CTGALoader(); // Constructor.
~CTGALoader(); // Destructor.bool LoadTGAFile(char \*filename); // Load a .tga image file. void SaveTGAScreenShot(char \*filename, int width, int height); // Save a .tga screen shot. void FreeImage(); // Delete a image. unsigned int ID; // ID used for generating the textures in OpenGl. int imageWidth; // Width of a texture. int imageHeight; // Height of a texture.
protected:
void GenerateTexture(); // Generate a texture in OpenGL.
bool LoadTGA(char *filename); // Load a tga image.
bool WriteTGA(char *file, short int width,
short int height,
unsigned char *image); // Write a tga file.unsigned char \*image; // Texture image. bool textureExist; // This will be used if the image was loaded. int type; // Image format.
};
#endif
shot.cpp
/*
Class Name:CTGALoader. shot.h
*/
#include"shot.h"
#include
#include <./gl/GL.H>
#include <./gl/GLU.H>
#include#pragma comment(lib,"OPENGL32.LIB")
#pragma comment(lib,"Glu32.lib")CTGALoader::CTGALoader()
{
// Give everything default values.
image = 0;
textureExist = false;
type = 0;
}CTGALoader::~CTGALoader()
{
FreeImage(); // Delete all images and dynamic memory.
}bool CTGALoader::LoadTGAFile(char *file)
{
if(textureExist)
FreeImage();if(!LoadTGA(file))
return false;// Make sure the image loaded.
if(image == 0)
{
return false;
}GenerateTexture();
textureExist = true;
return true;
}void CTGALoader::GenerateTexture()
{
// Generate the texture and text the id to the images id.
glGenTextures(1, &ID);// Here we bind the texture and set up the filtering.
glBindTexture(GL_TEXTURE_2D, ID);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);Far too much code here and far too few details. Try and narrow the problem down to a specific area of code and explain what is not working.
-
shot.h
/*
Class Name:CTGALoader. This class loads a tga texture into this object. shot.h
*/
#ifndef CTGALOADER_H
#define CTGALOADER_H// Remember to place all your GL/system header files that you will need to run class function
class CTGALoader
{
public:
CTGALoader(); // Constructor.
~CTGALoader(); // Destructor.bool LoadTGAFile(char \*filename); // Load a .tga image file. void SaveTGAScreenShot(char \*filename, int width, int height); // Save a .tga screen shot. void FreeImage(); // Delete a image. unsigned int ID; // ID used for generating the textures in OpenGl. int imageWidth; // Width of a texture. int imageHeight; // Height of a texture.
protected:
void GenerateTexture(); // Generate a texture in OpenGL.
bool LoadTGA(char *filename); // Load a tga image.
bool WriteTGA(char *file, short int width,
short int height,
unsigned char *image); // Write a tga file.unsigned char \*image; // Texture image. bool textureExist; // This will be used if the image was loaded. int type; // Image format.
};
#endif
shot.cpp
/*
Class Name:CTGALoader. shot.h
*/
#include"shot.h"
#include
#include <./gl/GL.H>
#include <./gl/GLU.H>
#include#pragma comment(lib,"OPENGL32.LIB")
#pragma comment(lib,"Glu32.lib")CTGALoader::CTGALoader()
{
// Give everything default values.
image = 0;
textureExist = false;
type = 0;
}CTGALoader::~CTGALoader()
{
FreeImage(); // Delete all images and dynamic memory.
}bool CTGALoader::LoadTGAFile(char *file)
{
if(textureExist)
FreeImage();if(!LoadTGA(file))
return false;// Make sure the image loaded.
if(image == 0)
{
return false;
}GenerateTexture();
textureExist = true;
return true;
}void CTGALoader::GenerateTexture()
{
// Generate the texture and text the id to the images id.
glGenTextures(1, &ID);// Here we bind the texture and set up the filtering.
glBindTexture(GL_TEXTURE_2D, ID);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);You have to draw some graphics first.