Jump to content
  • Advertisement
Sign in to follow this  

error C1010

This topic is 4641 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

Im getting this error and I really cant figure out what Ive done wrong. SdlWrapper.cpp(125) : fatal error C1010: unexpected end of file while looking for precompiled header directive I looked up the error code inte MSDN, it says it cant find some kind of precompiled header directive. Im not good enough to make out what I should do. :P Sorry. Heres the source if thats matter: SdlWrapper.cpp
#include "SdlWrapper.h"

SdlWrapper::SdlWrapper(int resolutionX, int resolutionY, int depth) {
	// set the screen properties
	screen = SDL_SetVideoMode(resolutionX, resolutionY, depth, SDL_HWSURFACE|SDL_DOUBLEBUF);

	ResX = resolutionX;		// store the resolution in the class variables
	ResY = resolutionY;
}

SdlWrapper::~SdlWrapper() {
	SDL_Quit();
}

void SdlWrapper::DrawImg(std::string img, int x, int y) {	// draws the image at those coordinates on the screen
	SDL_Rect dest;
	dest.x = x;
	dest.y = y;
	SDL_BlitSurface(Bmp[img], NULL, screen, &dest);
}

void SdlWrapper::DrawImg(char CharRef, int x, int y) {	// draws the image at those coordinates on the screen
	std::string image = BmpRef[CharRef];
	DrawImg(image, x, y);
}

bool SdlWrapper::LoadBmp(std::string filename) {
	std::stringstream str;
	str << "Sdl: Loading file " << filename << ".bmp";

	Bmp[filename] = SDL_LoadBMP( ("Bmp\\" + filename + ".bmp").c_str() );	// attempt to load the texture

	if(Bmp[filename] == NULL) {	// NULL, no image is there
		str << " FAILED: unable to load bmp file";
		Log::Write(str.str().c_str());
		return false;
	} // the image was loaded successfully, go on

	// setting transparency
	SDL_SetColorKey(Bmp[filename], SDL_SRCCOLORKEY, SDL_MapRGB(Bmp[filename]->format, 255, 0, 255));

	// Look in the txt file which char represents this image
	std::stringstream txt;
	txt << "Bmp\\" << filename << ".txt";
	std::ifstream infofile(txt.str().c_str());

	if(!infofile.is_open()) {		// cant read txt file
		str << " FAILED: unable to load info txt file";
		Log::Write(str.str().c_str());
		return false;
	}
	
	char RefChar = infofile.get();	// read the char
	BmpRef[RefChar] = filename;		// make the link between a char and the stringname

	str << "\tRefChar is " << RefChar;
	Log::Write(str.str().c_str());		// then report to log

	infofile.close();
	return true;
}

void SdlWrapper::DrawPixel(SDL_Surface *screen, int x, int y, Uint8 R, Uint8 G, Uint8 B) {
	// lock the screen if we have to
	Slock(screen);

	Uint32 color = SDL_MapRGB(screen->format, R, G, B);
	switch (screen->format->BytesPerPixel) {
		case 1: // Assuming 8-bpp 
		{
			Uint8 *bufp;
			bufp = (Uint8 *)screen->pixels + y*screen->pitch + x;
			*bufp = color;
		}
		break;
		case 2: // Probably 15-bpp or 16-bpp 
		{
			Uint16 *bufp;
			bufp = (Uint16 *)screen->pixels + y*screen->pitch/2 + x;
			*bufp = color;
		}
		break;
		case 3: // Slow 24-bpp mode, usually not used 
		{
			Uint8 *bufp;
			bufp = (Uint8 *)screen->pixels + y*screen->pitch + x * 3;
			if(SDL_BYTEORDER == SDL_LIL_ENDIAN)
			{
			bufp[0] = color;
			bufp[1] = color >> 8;
			bufp[2] = color >> 16;
			} else {
			bufp[2] = color;
			bufp[1] = color >> 8;
			bufp[0] = color >> 16;
			}
		}
		break;
		case 4: // Probably 32-bpp 
		{
			Uint32 *bufp;
			bufp = (Uint32 *)screen->pixels + y*screen->pitch/4 + x;
			*bufp = color;
		}
		break;
	}

	// unlock if we did lock the screen
	Sunlock(screen);
}

void SdlWrapper::Slock(SDL_Surface *screen) {
	if ( SDL_MUSTLOCK(screen) ) {
		if ( SDL_LockSurface(screen) < 0 ) {
		return;
		}
	}
}

void SdlWrapper::Sunlock(SDL_Surface *screen) {
	if ( SDL_MUSTLOCK(screen) ) {
		SDL_UnlockSurface(screen);
	}
}

SdlWrapper.h
#ifndef _SDL_WRAPPER
#define _SDL_WRAPPER

#include <SDL.h>
#include <conio.h>
#include <vector>
#include <string>
#include <sstream>
#include <iostream>
#include <map>
#include <fstream>

#include "Log.h"

class SdlWrapper {
private:
	void	Slock(SDL_Surface *screen);	// lock and unlock
	void	Sunlock(SDL_Surface *screen);

	std::map	<std::string, SDL_Surface*> Bmp;	// holds all the texture
	std::map	<char, std::string> BmpRef;			// so we know which string(texture) is represented by which char

	SDL_Surface *screen;	// the visible screen

	int		ResX; 
	int		ResY;		// the screen resolution

public:
	SdlWrapper(int resolutionX, int resolutionY, int depth);

	// bmp handling functions
	bool			LoadBmp(std::string filename);	// adds a texture to the texture map, return false on failure	
	SDL_Surface*	GetBmp(std::string texture)		{return Bmp[texture];}	// returns a texture
		
	void	DrawPixel(SDL_Surface *screen, int x, int y, Uint8 R, Uint8 G, Uint8 B);	// draw a single pixel
	
	void	DrawImg(std::string img, int x, int y);		// draws the image at those coordinates on the screen
	void	DrawImg(char img, int x, int y);			// so we can call it with just the tile char to 
	void	DrawBG()	{DrawImg("Background", 0, 0);}	// draws the background onto the screen
	void	Flip()		{SDL_Flip(screen);}				// flips and updates the entire screen	
};

#endif

Could it be something with the SDL library it cant find?

Share this post


Link to post
Share on other sites
Advertisement
You have to disable precompiled headers in Visual Studio (project settings).

That is:
Project Settings -> C/C++ -> Precompiled Headers -> Not Using Precompiled headers

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!