MSVCR90.dll isn't found {was:[Solved] C++ File Inclusion :(}

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

MSVCR90.dll isn't found {was:[Solved] C++ File Inclusion :(}

Post by RandomDever »

Here's my dilemma.

I have an engine class which stores all me requisite variables( video, input etc. )
but all the classes contained in the engine must include the engine in order to know what the engine is
int order to do things like debugging( which is handle by a debug class in engine ). Mainly just debugging. Because right now I use an extern statement to always have access to the engine object which is declared in main.cpp. I'm wondering if there's some way to easily fix this or
if I'm going to have to figure out... *gulp* the 'singleton technique'?
Last edited by RandomDever on Thu Aug 02, 2012 3:50 pm, edited 2 times in total.
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: C++ File Inclusion :(

Post by Nokurn »

Don't use a singleton. If your subsystems need a way to access the engine, give them a pointer or a reference. Better yet, isolate what parts of the engine they need access to (other subsystems, etc) and only give them pointers/references to those. Something like this would work:

Engine.hpp:

Code: Select all

#pragma once

#include "AudioSystem.hpp"
#include "InputSystem.hpp"
#include "VideoSystem.hpp"

class Engine {
    VideoSystem* _video;
    AudioSystem* _audio;
    InputSystem* _input;

public:
    Engine();
    ~Engine();

    VideoSystem* getVideo() { return _video; }
    AudioSystem* getAudio() { return _audio; }
    InputSystem* getInput() { return _input; }
};
Engine.cpp:

Code: Select all

#include "Engine.hpp"

Engine::Engine()
{
    _video = new VideoSystem(this);
    _audio = new AudioSystem(this);
    _input = new InputSystem(this);
}

Engine::~Engine()
{
    delete _input;
    delete _audio;
    delete _input;
}
VideoSystem.hpp:

Code: Select all

#pragma once

class Engine;

class VideoSystem {
    Engine* _engine;

public:
    VideoSystem(Engine* engine);

    Engine* getEngine() { return _engine; }
};
VideoSystem.cpp:

Code: Select all

#include "VideoSystem.hpp"
#include "Engine.hpp"

VideoSystem::VideoSystem(Engine* engine) : _engine(engine)
{
    // Initialize video system...
}
AudioSystem.hpp:

Code: Select all

#pragma once

class Engine;

class AudioSystem {
    Engine* _engine;

public:
    AudioSystem(Engine* engine);

    Engine* getEngine() { return _engine; }
};
AudioSystem.cpp:

Code: Select all

#include "AudioSystem.hpp"
#include "Engine.hpp"

AudioSystem::AudioSystem(Engine* engine) : _engine(engine)
{
    // Initialize audio system...
}
InputSystem.hpp:

Code: Select all

#pragma once

class Engine;

class InputSystem {
    Engine* _engine;

public:
    VideoSystem(Engine* engine);

    Engine* getEngine() { return _engine; }
};
InputSystem.cpp:

Code: Select all

#include "InputSystem.hpp"
#include "Engine.hpp"

InputSystem::InputSystem(Engine* engine) : _engine(engine)
{
    // Initialize input system...
    // Maybe you'd use _engine->getVideo() to get an input source from the window
}
I would recommend using references instead of pointers. Pointers should only really be used when null is a possibility. You will always have an Engine in your subsystems, so you could use a reference instead. There are a few other things about this code that I wouldn't advise you follow exactly, but this is just an example to give you an idea.

My main recommendation is to pass around specific members of the Engine class whenever possible, rather than the entire thing. If a class only needs access to your texture manager, you should only give it a reference to the texture manager, not the entire engine that happens to contain a texture manager. It's a bit more work, but your code will be better for it.

Edit: I forgot to mention why this code works. It uses forward declarations to avoid a circular header dependency. If a class's declaration only contains a reference or a pointer to another class, you only need to state that the type is a class for the code to compile. You will need to include the header in which the reference/pointer's class is declared in any source files that actually use it.
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: C++ File Inclusion :(

Post by RandomDever »

Code: Select all

struct Time
{
	unsigned short int year;
	std::string month, dayOfWeek;
	unsigned short int day, hour, minute, second, millisecond;
};

Code: Select all

'struct' type redefinition
How is it possible to redefine a struct that doesn't even exist anywhere else?
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: C++ File Inclusion :(

Post by bbguimaraes »

That's probably an include guard problem. It is being redefined because you include it in more than on file.
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: C++ File Inclusion :(

Post by RandomDever »

Thank you bbguimaraes it was.
I mispelled utilities on the define. Well back to work. :mrgreen:
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: C++ File Inclusion :(

Post by RandomDever »

On a side note.
Does anyone know how to detect a window resize event for Microsoft Windows?

And handle them.
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: C++ File Inclusion :(

Post by Nokurn »

RandomDever wrote:On a side note.
Does anyone know how to detect a window resize event for Microsoft Windows?

And handle them.
WM_SIZE message:

Code: Select all

LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch (uMsg) {
    // ...
    case WM_SIZE: {
        // If you anticipate sizes of more than 65535, use GetClientRect instead
        int w = LOWORD(lParam);
        int h = HIWORD(lParam);

        // Handle the resize. Ex:
        //glViewport(0, 0, w, h);
        return 0;
    }
    // ...
    }
    return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
If you're using a library like SFML or SDL, you'll have to go through it instead.
Rebornxeno
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 85
Joined: Thu Jun 23, 2011 11:12 am

Re: C++ File Inclusion :(

Post by Rebornxeno »

I'm really confused.. I can't think of any reason a subsystem of your engine would need access to the engine for? Can you explain for me please?
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: C++ File Inclusion :(

Post by RandomDever »

I'm using SDL.
How do I make it so that it doesn't have black boxing when resizing?
User avatar
Nokurn
Chaos Rift Regular
Chaos Rift Regular
Posts: 164
Joined: Mon Jan 31, 2011 12:08 pm
Favorite Gaming Platforms: PC, SNES, Dreamcast, PS2, N64
Programming Language of Choice: Proper C++
Location: Southern California
Contact:

Re: C++ File Inclusion :(

Post by Nokurn »

RandomDever wrote:I'm using SDL.
How do I make it so that it doesn't have black boxing when resizing?
Wherever you're pumping SDL_Events:

Code: Select all

if (ev.type == SDL_VIDEORESIZE) {
    // ... use data in ev.resize ...
}
ev is an SDL_Event, ev.resize is an SDL_ResizeEvent.

I don't think there is a way to eliminate the black boxing while using SDL. It would require intercepting the WM_SIZING event and redrawing between mouse movements, which can slow things down.

Simple questions like this can be answered by using Google or RTFM. SDL 1.2 docs are at http://sdl.beuc.net/sdl.wiki/FrontPage, SDL 2.0 docs are at http://wiki.libsdl.org/moin.cgi/FrontPage.
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: C++ File Inclusion :(

Post by RandomDever »

Does anyone know where SDL sets up the window ( in the code )?
If they use the windows API I may be able to modify SDL to do my bidding.
User avatar
bbguimaraes
Chaos Rift Junior
Chaos Rift Junior
Posts: 294
Joined: Wed Apr 11, 2012 4:34 pm
Programming Language of Choice: c++
Location: Brazil
Contact:

Re: C++ File Inclusion :(

Post by bbguimaraes »

RandomDever wrote:Does anyone know where SDL sets up the window ( in the code )?
If they use the windows API I may be able to modify SDL to do my bidding.
In my experience, if you ask that question, you are not on the level to do it (no offense). Otherwise, grep is your friend.

But keep in mind you're going to loose much of the portability (if not all) that you gain by using SDL.
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: C++ File Inclusion :(

Post by RandomDever »

I have an application called PRGrep and I searched for various things within SDLs code that would be required for setting up a window.
No results.
I see SetVideoMode declared but not defined.
How exactly is that possible?
Is it in the DLLs?
In that case how am I supposed to edit it?
LATER: OK so I figured out I had to download the SDL source and dig through it to find the WndProc definition.
It's on Line 251 in SDL_sysevents.c.
So I've modified it to do my bidding *evil laugh* and rebuilt SDL.dll.
It works the way I intended except for one thing.
The window is updating slowly so if I call glClear it will clear the screen after a second but it is not perfectly filling the window (still minor black boxing).
I checked and minecraft has the same type of problem when resizing.
Does anyone know a way to fix this?
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: C++ File Inclusion :(

Post by RandomDever »

Well it's okay I'll blank the screen on resize.
Marking as solved.
RandomDever
Chaos Rift Regular
Chaos Rift Regular
Posts: 198
Joined: Thu Mar 26, 2009 8:42 pm
Current Project: My Engine
Programming Language of Choice: C++

Re: [Solved] C++ File Inclusion :(

Post by RandomDever »

Just curious if there are still people monitoring this forum.
What is a good FPS for rendering 2500 textures to the screen?
Post Reply