[QUOTE=Meatpuppet;35750750][cpp]void TerrainWindow::Draw()
{
sf::Image dot;
dot.LoadFromFile("dot.jpg");
sf::Sprite sinWave;
sinWave.SetImage(dot);
float x, y;
for(int i = 0; i < 300; i++)
{
y = 10.0f * sin(3.0f + i);
x += i;
sinWave.SetPosition(x, y);
Wnd.Draw(sinWave);
}
}
void TerrainWindow::TerrainWindowLoop()
{
TerrainWindow::Draw();
while(GetState())
{
Wnd.Display();
}
}[/cpp]
The window opens, but then it crashes.[/QUOTE]
Holy shit, why are you loading resources every time you draw something??
[QUOTE=Superbird;35742669]Having some C trouble.
In my header I have:
[CODE]typedef struct coin
{
unsigned qty;
unsigned value; /* Stored in cents (not dollars). */
} CoinType;[/CODE]
Populating with:
[CODE]CoinType database[5];
database[0].value = 200;
database[1].value = 100;
database[2].value = 50;
database[3].value = 20;
database[4].value = 10;
database[5].value = 5;[/CODE]
When I try and print the contents of my struct in a separate function with:
[CODE]CoinType * database[5];
printf("%d\n", database[1]->value);[/CODE]
it outputs: 4199104
I am guessing this is the memory address?[/QUOTE]
[code]database[5].value = 5;[/code]
There is one problem, you declare an array for 5 places and you use 6.
[CODE]CoinType * database[5];[/CODE]
I have never seen something like that. It seems that you re-declare database.
[QUOTE=download;35753194]Text[/QUOTE]
Make sure that neither inPutString1 or inPutString2 are NULL before doing
[code]int check = inPutString1.compareTo(inPutString2);[/code]
[QUOTE=AlienCat;35754559][code]database[5].value = 5;[/code]
There is one problem, you declare an array for 5 places and you use 6.
[CODE]CoinType * database[5];[/CODE]
I have never seen something like that. It seems that you re-declare database.
Make sure that neither inPutString1 or inPutString2 are NULL before doing
[code]int check = inPutString1.compareTo(inPutString2);[/code][/QUOTE]
Lol, I'm not getting any errors now, but now my code doesn't do anything
[QUOTE=T3hGamerDK;35753596]Holy shit, why are you loading resources every time you draw something??[/QUOTE]
It's for a friend, he didn't want to post here. Can you help, either way?
[QUOTE=Meatpuppet;35756528]It's for a friend, he didn't want to post here. Can you help, either way?[/QUOTE]
Yes, but you have to move the loading out of there. Loading the same file more than 60 times a second is not good, and could eventually cause crashes.
Other than that, I'm not sure what's wrong. Are you sure it's there the error happens?
[QUOTE=T3hGamerDK;35756807]Yes, but you have to move the loading out of there. Loading the same file more than 60 times a second is not good, and could eventually cause crashes.
Other than that, I'm not sure what's wrong. Are you sure it's there the error happens?[/QUOTE]
He says he isn't loading the resources every time it draws.
[QUOTE=Meatpuppet;35756845]He says he isn't loading the resources every time it draws.[/QUOTE]
[QUOTE=Meatpuppet;35750750][cpp]void TerrainWindow::Draw()
dot.LoadFromFile("dot.jpg");
}[/cpp][/QUOTE]
Clearly it does.
He says it's a poorly named function is all.
Automerge
[QUOTE=Meatpuppet;35756890]He says it's a poorly named function is all.
Automerge[/QUOTE]
Regardless, if that doesn't cause the crash, then it doesn't crash in that part of the code. If it's not a grammar error (compiler spewing any warnings or errors?), then we'll need to see the rest of the code to solve it.
[QUOTE=WTF Nuke;35752113]I'm working on changing my game to be component based rather than inheritence based, and I'm not sure if it's supposed to look like this.
[img]http://dl.dropbox.com/u/8414553/uhisthisright.png[/img]
As in, am I supposed to have to static_cast this much and have this many classes or am I missing something?[/QUOTE]
What I do is have every GameObject contain a vector of GameComponents, with a few instance variables for common ones like graphics.
The components are instantiated by either assigning one of the built-in components, or adding to the vector.
Each GameObject has an update function which updates each GameComponent from the vector and the built-in ones.
So to answer your question, yes you will have that many classes(or close to it) but you do not need to cast for each update,
but rather let the update loop blindly update all of your components.
Yeah, I thought about why I was casting when I should just be updating (I even have the base function).
[QUOTE=Meatpuppet;35750750][cpp]void TerrainWindow::Draw()
{
sf::Image dot;
dot.LoadFromFile("dot.jpg");
sf::Sprite sinWave;
sinWave.SetImage(dot);
float x, y;
for(int i = 0; i < 300; i++)
{
y = 10.0f * sin(3.0f + i);
x += i;
sinWave.SetPosition(x, y);
Wnd.Draw(sinWave);
}
}
void TerrainWindow::TerrainWindowLoop()
{
TerrainWindow::Draw();
while(GetState())
{
Wnd.Display();
}
}[/cpp]
The window opens, but then it crashes.[/QUOTE]
You need to poll the events or windows will treat it as a non responding window.
add: (assuming your using SFML 2.0)
[cpp]sf::Event event;
while (window.pollEvent(event))
{
if (event.type == sf::Event::Closed)
window.close();
}[/cpp] inside the while loop
Also it does load the img on each draw, however judging from that code it only calls draw once so it only loads the iage once, but if he plans to change it then he should move the img loading code into the constructor or something
[QUOTE=Chris220;35733950]Similar issue to what I had before... This code acts very oddly. It opens two Open File dialogs either at the same time or one after the other. When I try and step through this code, it gets to GetOpenFileNameA() and then when I try to step over it, it jumps back up to whatever breakpoint I was going from. The next time around, it works as intended and only ONE Open File dialog opens. I have less than 5 days to get this fixed (University assignment, so any help would be GREATLY appreciated right now...)
[cpp]OPENFILENAMEA ofn;
ZeroMemory(&ofn, sizeof(OPENFILENAMEA));
char filename[MAX_PATH] = "";
ofn.lStructSize = sizeof(OPENFILENAMEA);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = "OBJ Files (*.obj)\0";
ofn.lpstrFile = filename;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
ofn.lpstrDefExt = "obj";
BOOL success = GetOpenFileNameA(&ofn);
if(success)
{
std::cout << "Loading from " << filename << std::endl;
}[/cpp][/QUOTE]
Sorry to push this but I'm despairing at not being able to fix it and it needs to be done by wednesday. [I]Any[/I] ideas right now would be appreciated. Thanks in advance...
I feel stupid for not being able to solve this for a while, but the image wouldn't return at all for some reason.
[cpp]
//function from ImageLoader.cpp
SDL_Surface *IMG_HANDLER::loadImage(std::string filename)
{
atexit(SDL_Quit);
SDL_Surface *imgSRC =NULL;
temp = SDL_LoadBMP(filename.c_str());
if (temp!=NULL)
{
imgSRC = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
printf("-IMAGE PRITNING SUCESSFUL", stdout);
exit(1);
}
if (temp==NULL)
{
printf("-Couldn't load IMG \n", stderr, SDL_GetError());
exit(1);
}
if (imgSRC == NULL)
{
printf("-Couldn't optimize image \n", stderr, SDL_GetError());
SDL_FreeSurface(imgSRC);
exit(1);
}
return imgSRC;
}
[/cpp]
Code that uses the function:
[cpp]
//prompt.cpp
#include "..\LibariesToUse.h"
#include "..\Engine\Prompt.h"
SDL_Surface *image[8];
Prompt::Prompt()
{
CONFIRM =false;
SCW=640;
SCH=480;
BBP=32;
image[0]=prompt_img.loadImage("Asset/Prompt_Window/Prompt.bmp");
image[1]=prompt_img.loadImage("Asset/Prompt_Window/directxoption.bmp");
image[2]=prompt_img.loadImage("Asset/Prompt_Window/openGLoption.bmp");
image[3]=prompt_img.loadImage("Asset/Prompt_Window/Resolution_640_option.bmp");
image[4]=prompt_img.loadImage("Asset/Prompt_Window/Resolution_1024_option.bmp");
image[5]=prompt_img.loadImage("Asset/Prompt_Window/yes_option.bmp");
image[6]=prompt_img.loadImage("Asset/Prompt_Window/no_option.bmp");
}
Prompt::~Prompt()
{
SDL_Quit();
}
}
SDL_Event PromptEvent;
void Prompt::show()
{
prompt_img.SetImage(0,0,screen,image[0],NULL);
}
void Prompt::handle_events()
{
x = 0, y = 0;
if( PromptEvent.type == SDL_MOUSEMOTION )
{
//Get the mouse offsets
x = PromptEvent.motion.x;
y = PromptEvent.motion.y;
if( PromptEvent.type == SDL_MOUSEBUTTONDOWN )
{
//If the left mouse button was pressed
if( PromptEvent.button.button == SDL_BUTTON_LEFT )
{
//Get the mouse offsets
x = PromptEvent.button.x;
y = PromptEvent.button.y;
//If the mouse is over the button
if( x= 1, y=141)
{
//Set the button sprite
prompt_img.SetImage(1,141,screen, image[1], NULL);
}
if( x= 1, y=175)
{
//Set the button sprite
prompt_img.SetImage(1,364,screen,image[2], NULL);
}
if( x= 169, y=140)
{
//Set the button sprite
prompt_img.SetImage(24,347,screen, image[3], NULL);
}
if( x= 159, y=179)
{
//Set the button sprite
prompt_img.SetImage(24,347,screen,image[4], NULL);
}
if( x= 0, y=270)
{
//Set the button sprite
prompt_img.SetImage(206,250,screen, image[5], NULL);
}
if( x= 24, y=269)
{
//Set the button sprite
prompt_img.SetImage(206,250,screen,image[6], NULL);
}
if (x=238, y=354)
{
//Init start
//start.render(choice a, choice b, choice c)
prompt_img.CleanIMG(image[0]);
prompt_img.CleanIMG(image[1]);
prompt_img.CleanIMG(image[2]);
prompt_img.CleanIMG(image[3]);
prompt_img.CleanIMG(image[4]);
prompt_img.CleanIMG(image[5]);
prompt_img.CleanIMG(image[6]);
prompt_img.CleanIMG(image[7]);
CONFIRM= true;
}
}
}
}
}
[/cpp]
I'm thinking of starting it all over again just because of how messy it is now.
Now that I'm almost done changing my client to use components, I assume I should change the server too. But how can I send info between client and server? I was thinking maybe at creation of an object it'll send the ids tied to attributes and behaviors and the values used for them, and then only send attribute values when needed (or every tick depending on the type of attribute). I don't know, this is just scaring me now.
[QUOTE=Chris220;35757324]Sorry to push this but I'm despairing at not being able to fix it and it needs to be done by wednesday. [I]Any[/I] ideas right now would be appreciated. Thanks in advance...[/QUOTE]
What I've noticed is that the first time you call GetOpenFileNameA(..), it's very slow to load. It then doesn't take so long the next time it's opened. Here's my code:
[cpp]
std::string CreateOpenFileDialog(const char *filter /*= "All Files (*.*)\0*.*\0"*/, const char *startPath /*= "."*/)
{
OPENFILENAMEA ofn;
char fileName[MAX_PATH];
memset(&ofn, 0, sizeof(OPENFILENAMEA));
memset(&fileName, 0, MAX_PATH);
ofn.lStructSize = sizeof(OPENFILENAMEA);
ofn.hwndOwner = /*g_pVideo->GetHandle()*/NULL;
ofn.lpstrFilter = filter;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = /*OFN_EXPLORER | */OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
ofn.lpstrDefExt = "";
ofn.lpstrTitle = "Open File...";
ofn.lpstrInitialDir = startPath;
std::string fileNameStr;
if(GetOpenFileNameA((LPOPENFILENAMEA)&ofn))
fileNameStr = fileName;
return fileNameStr;
}
[/cpp]
If this code makes it show up twice, then you have a problem with the code calling that function, not with the function itself.
What usually causes these errors?
[code]1>FModSoundProvider.obj : error LNK2019: unresolved external symbol "public: enum FMOD_RESULT __stdcall FMOD::System::release(void)" (?release@System@FMOD@@QAG?AW4FMOD_RESULT@@XZ) referenced in function "public: virtual __thiscall FModSoundProvider::~FModSoundProvider(void)" (??1FModSoundProvider@@UAE@XZ)
[/code]
Have you linked the correct FMOD lib?
[QUOTE=NovembrDobby;35758945]Have you linked the correct FMOD lib?[/QUOTE]
I linked E:\FMOD Programmers API Windows\api\lib in Config Properties/Linker/Additional Library Directories.
[QUOTE=Meatpuppet;35758971]I linked E:\FMOD Programmers API Windows\api\lib in Config Properties/Linker/Additional Library Directories.[/QUOTE]
What you're looking for is likely a "fmod.lib" or "fmod.def" file, if I recall correctly.
[QUOTE=T3hGamerDK;35759013]What you're looking for is likely a "fmod.lib" or "fmod.def" file, if I recall correctly.[/QUOTE]
Can't find those
[QUOTE=Meatpuppet;35758908]What usually causes these errors?
[code]1>FModSoundProvider.obj : error LNK2019: unresolved external symbol "public: enum FMOD_RESULT __stdcall FMOD::System::release(void)" (?release@System@FMOD@@QAG?AW4FMOD_RESULT@@XZ) referenced in function "public: virtual __thiscall FModSoundProvider::~FModSoundProvider(void)" (??1FModSoundProvider@@UAE@XZ)
[/code][/QUOTE]
When you declare a function but don't define it, but it could be other things I'm not sure.
[QUOTE=Lord Ned;35758276]What I've noticed is that the first time you call GetOpenFileNameA(..), it's very slow to load. It then doesn't take so long the next time it's opened. Here's my code:
[cpp]
std::string CreateOpenFileDialog(const char *filter /*= "All Files (*.*)\0*.*\0"*/, const char *startPath /*= "."*/)
{
OPENFILENAMEA ofn;
char fileName[MAX_PATH];
memset(&ofn, 0, sizeof(OPENFILENAMEA));
memset(&fileName, 0, MAX_PATH);
ofn.lStructSize = sizeof(OPENFILENAMEA);
ofn.hwndOwner = /*g_pVideo->GetHandle()*/NULL;
ofn.lpstrFilter = filter;
ofn.lpstrFile = fileName;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = /*OFN_EXPLORER | */OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR;
ofn.lpstrDefExt = "";
ofn.lpstrTitle = "Open File...";
ofn.lpstrInitialDir = startPath;
std::string fileNameStr;
if(GetOpenFileNameA((LPOPENFILENAMEA)&ofn))
fileNameStr = fileName;
return fileNameStr;
}
[/cpp]
If this code makes it show up twice, then you have a problem with the code calling that function, not with the function itself.[/QUOTE]
Although you didn't help directly with that code, you did make me finally realise what I did wrong. Thank you for that! The problem lay in my ridiculously over-engineered GUI system that meant debugging was a huge pain. Time for a bit of a rewrite of that system, methinks.
[QUOTE=AlienCat;35754559][code]database[5].value = 5;[/code]
There is one problem, you declare an array for 5 places and you use 6.
[CODE]CoinType * database[5];[/CODE]
I have never seen something like that. It seems that you re-declare database.
Make sure that neither inPutString1 or inPutString2 are NULL before doing
[code]int check = inPutString1.compareTo(inPutString2);[/code][/QUOTE]
If I don't re-declare the database (CoinType[5].value = 5;) I get a syntax error?
It's really annoying, I'm getting this error when I create big maps: [code]XNA Framework HiDef profile supports a maximum of 1048575 primitives per draw call.[/code]
I want a really big map, I found a heightmap of Deepholm, from World of Warcraft, and I want to see it in full width and height (2720x2720), but if I want to get rid of the error, I need to make the heightmap and colormap 512x512, it's really annoying, can anyone help me out?
[QUOTE=Staneh;35769097]It's really annoying, I'm getting this error when I create big maps: [code]XNA Framework HiDef profile supports a maximum of 1048575 primitives per draw call.[/code]
I want a really big map, I found a heightmap of Deepholm, from World of Warcraft, and I want to see it in full width and height (2720x2720), but if I want to get rid of the error, I need to make the heightmap and colormap 512x512, it's really annoying, can anyone help me out?[/QUOTE]
Split the mesh into multiple parts/draw-calls.
[QUOTE=Superbird;35765651]If I don't re-declare the database (CoinType[5].value = 5;) I get a syntax error?[/QUOTE]
You declared an array using "CoinType database[5];" and then you are assigning the 6th element by "CoinType[5].value = 5;". It is possible to do that in c but it led to an undefined behaviour. Remember that when you do "ValueType array[x]" it means that the first element in the array have index 0 and the last have x - 1.
[QUOTE=Lord Ned;35770175]Split the mesh into multiple parts/draw-calls.[/QUOTE]
Is there any easier way to do it than making chunks?
Sorry, you need to Log In to post a reply to this thread.