|
Hows it going people? I'm hanging up my PHP Enviroment for a while and having another play with C++ and Allegro. Ran into some problems tho.
I'm having an OOP problem. I'm using Dev-C++ and trying to initialize allegro in a very basic. BUT, this question doesn't require an allegro knowledge. I have 3 files (main.cpp, Device.h, Device.cpp). Now so far I have created the project, wrote the main.cpp code, then added the other two files and wrote their code. Here is the error I'm getting:
| QUOTE | Line 10: 'gfxDevice' is not a known namespace or class
|
And here is my code: main.cpp:
| CODE | #include <allegro.h> #include "Device.h"
using namespace std;
Device gfxDevice;
int main() { gfxDevice::initialize(1024, 800);
while (!key[KEY_ESC]) { /* put your code here */ }
gfxDevice::deinitialize(); return 0;
} END_OF_MAIN()
|
Device.h:
| CODE | //Device.h
#ifndef DEVICE_H #define DEVICE_H
#include <allegro.h>
class Device {
public: Device(); ~Device();
// These two functions intialize Allegro void initialize(int res_x, int res_y); void deinitialize(); private:
int depth(); int res();
};
#endif
|
Device.cpp:
| CODE | //Device.cpp #include "Device.h"
Device::Device() { }
Device::~Device() { }
void Device::initialize(int res_x, int res_y) { allegro_init(); Device::depth(); Device::res(res_x, res_y);
install_timer(); install_keyboard(); install_mouse(); }
void Device::deinitialize() { clear_keybuf(); }
int Device::depth() { depth = desktop_color_depth(); if (depth == 0) { depth = 32; } set_color_depth(depth); return 1; }
int Device::res(int res_x, int res_y) { res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, res_x, res_y, 0, 0); if (res != 0) { allegro_message(allegro_error);
exit(-1); } }
|
What am I missing? Did I not do something right? or is it my code?
Dan
--------------------
1 pwn @ll y0u l0s3rs! G0 j4ck 0ff 1n4 a cup!
|