Jump to content
  • Advertisement
Sign in to follow this  
raptorstrike

it just shows a black screen

This topic is 5473 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

ok here is what im doing im just trying to load an image and render it (sound simple) ok heres the code i have and i dont know why this dosnt work it runs but its just a blank screen no image any were
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <libiberty.h>
#include "Player.h"
#include "GameEngine.h"
#include "SDL.h"





 SDL_Surface *screen = NULL;
 
static void
draw ()
{
 Player *a;
 GameEngine  *pGame;
 pGame = new GameEngine(); 
 a->SetImage("Player.bmp", a->GetImage());
 a = new Player("Player.bmp"); 
 //pGame->DrawIMG(a->GetImage(),screen, 250,250,24,32,1,1);
  SDL_Rect dest;
  dest.x = 1;
  dest.y = 1;
  SDL_Rect dest2;
  dest2.x = 1;
  dest2.y = 1;
  dest2.w = 24;
  dest2.h = 32;
  SDL_BlitSurface(a->GetImage(), &dest2, screen, &dest);
  SDL_Flip(screen);

}; 


int
main (int argc, char *argv[])
{
  
    char *msg;
    int done;

    /* Initialize SDL */
    if (SDL_Init (SDL_INIT_VIDEO) < 0)
    {
        asprintf (&msg, "Couldn't initialize SDL: %s\n", SDL_GetError ());
        MessageBox (0, msg, "Error", MB_ICONHAND);
        free (msg);
        exit (1);
    }
    atexit (SDL_Quit);

    /* Set 640x480 16-bits video mode */
    screen = SDL_SetVideoMode (640, 480, 16, SDL_SWSURFACE | SDL_DOUBLEBUF);
    if (screen == NULL)
    {
        asprintf (&msg, "Couldn't set 640x480x16 video mode: %s\n",
          SDL_GetError ());
        MessageBox (0, msg, "Error", MB_ICONHAND);
        free (msg);
        exit (2);
    }
    SDL_WM_SetCaption ("SDL MultiMedia Application", NULL);

    done = 0;
    while (!done)
    {
        SDL_Event event;

        /* Check for events */
        while (SDL_PollEvent (&event))
        {
            switch (event.type)
            {
            case SDL_KEYDOWN:
                break;
            case SDL_QUIT:
                done = 1;
                break;
            default:
                break;
            }
        }

        /* Draw to screen */
        draw ();
    }

    return 0;
}



the part that loads the bitmap is the draw() function thnks alot guys [smile]

Share this post


Link to post
Share on other sites
Advertisement
Ummm...

static void
draw ()
{
Player *a; <<<<<<<<<----- "a" is undefined
GameEngine *pGame;
pGame = new GameEngine();
a->SetImage("Player.bmp", a->GetImage()); <<<<<<------ loading image here? "a" pointer is UNDEFINED!
a = new Player("Player.bmp"); <<<<------- now its defined!

....
}

hope that helps.

Thermo/Konfu

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!