(*info = (BITMAPINFO *)malloc(infosize)) == NULL)
this cast doesn''t work for me. I have seen alot of code examples that uses this same cast on these same variables but for me it fails any suggestions?
What''s the type of info? You might want (info = (BITMAPINFO *)malloc(infosize)) == NULL) instead.
Sorry this is what it looks like and I am getting a cast error
FILE * fp;
BITMAPFILEHEADER header;
BITMAPINFO ** info;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
GLubyte * BitmapBits[1]; /* Bitmap data */
int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing
{
int infosize,
bitsize;
fp = fopen("NeHe.bmp", "rb");
if (fp == NULL)
return (NULL);
fread(&header, sizeof(BITMAPFILEHEADER), 1, fp);
if(header.bfType != ''MB'')
{
fclose(fp);
return(NULL);
}
infosize = header.bfOffBits - sizeof(BITMAPFILEHEADER);
*info = (BITMAPINFO *)malloc(infosize);
if ((*info = (BITMAPINFO *)malloc(infosize)) == NULL)
{
/* Couldn''t allocate memory for bitmap info - return NULL... */
fclose(fp);
return (NULL);
}
fread(&info, 1, infosize, fp);
if ((bitsize = (*info)->bmiHeader.biSizeImage) == 0)
bitsize = ((*info)->bmiHeader.biWidth * (*info)->bmiHeader.biBitCount + 7 / 8 *
abs((*info)->bmiHeader.biHeight));
glViewport(0,0,Width,Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,(GLfloat)Width, 0.0, (GLfloat)Height, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glRasterPos2i(0,0);
glDrawPixels((*info)->bmiHeader.biWidth, (*info)->bmiHeader.biHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, BitmapBits);
return TRUE; // Keep Going
}
FILE * fp;
BITMAPFILEHEADER header;
BITMAPINFO ** info;
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
GLubyte * BitmapBits[1]; /* Bitmap data */
int DrawGLScene(GLvoid) // Here''s Where We Do All The Drawing
{
int infosize,
bitsize;
fp = fopen("NeHe.bmp", "rb");
if (fp == NULL)
return (NULL);
fread(&header, sizeof(BITMAPFILEHEADER), 1, fp);
if(header.bfType != ''MB'')
{
fclose(fp);
return(NULL);
}
infosize = header.bfOffBits - sizeof(BITMAPFILEHEADER);
*info = (BITMAPINFO *)malloc(infosize);
if ((*info = (BITMAPINFO *)malloc(infosize)) == NULL)
{
/* Couldn''t allocate memory for bitmap info - return NULL... */
fclose(fp);
return (NULL);
}
fread(&info, 1, infosize, fp);
if ((bitsize = (*info)->bmiHeader.biSizeImage) == 0)
bitsize = ((*info)->bmiHeader.biWidth * (*info)->bmiHeader.biBitCount + 7 / 8 *
abs((*info)->bmiHeader.biHeight));
glViewport(0,0,Width,Height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0,(GLfloat)Width, 0.0, (GLfloat)Height, -1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glRasterPos2i(0,0);
glDrawPixels((*info)->bmiHeader.biWidth, (*info)->bmiHeader.biHeight, GL_BGR_EXT, GL_UNSIGNED_BYTE, BitmapBits);
return TRUE; // Keep Going
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement