Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

vaneger

allegro issues

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

void draw()
	{
		//draw header

		rect(myGFX,myCoords.TL.x - 1 ,myCoords.TL.y - 1,myCoords.BR.x - 1,myCoords.BR.y - 1,makecol(0,0,255));
		rectfill(myGFX,myCoords.TL.x - 1 ,myCoords.TL.y - 1,myCoords.BR.x - 1,myCoords.BR.y - 1,makecol(0,0,255));
	}
	int onClick(){active = true;return 0;}
	inline void Ini(BITMAP *parent = NULL)
	{
		myGFX = create_sub_bitmap(parent,myCoords.TL.x,myCoords.TL.y,width(),height());
	}
this code is part of a dialog class and i have a GUI class that stores a pointer to a dialog as its AppWindow. GUI also has a BITMAP *buffer member that is blitted to the screen when the gui updates. when the gui updates it calls the AppWindow->draw() function listed above. the problem is that nothing is drawn on the screen and im not sure why.

Share this post


Link to post
Share on other sites
Advertisement

#ifndef SKOFE_COMPONENTS_H_
#define SKOFE_COMPONENTS_H_

#include<allegro.h>
#include<vector.h>
using namespace std;

struct point
{
int x,y;
};
struct Rect
{
point TL,BR;
inline int width() { return (BR.y - TL.y); }
inline int height() { return (BR.x - TL.x); }
};

class widget
{
public:
widget(){}
virtual ~widget(){}
virtual void draw(){}
virtual int onClick(){return 0;}

__inline int width() { return (myCoords.width()); }
__inline int height() { return (myCoords.height()); }

virtual __inline void Ini(BITMAP *parent){}

Rect myCoords;
bool focus;
bool isDirty;

};
typedef widget Element;

class dialog : public widget
{
public:
dialog(){}
~dialog(){}

void draw()
{
//draw header

rect(myGFX,myCoords.TL.x - 1 ,myCoords.TL.y - 1,myCoords.BR.x - 1,myCoords.BR.y - 1,makecol(0,0,255));
rectfill(myGFX,myCoords.TL.x - 1 ,myCoords.TL.y - 1,myCoords.BR.x - 1,myCoords.BR.y - 1,makecol(0,0,255));
}
int onClick(){active = true;return 0;}
__inline void Ini(BITMAP *parent )
{
myGFX = create_sub_bitmap(parent,myCoords.TL.x,myCoords.TL.y,width(),height());
}
bool active;
char* headerText;

BITMAP *myGFX;

vector<dialog*> children;
vector<widget*> controls;
};
#endif


#ifndef SKOFE_GUI
#define SKOFE_GUI
#include"SKOFE_COMPONENTS.h"

unsigned long UTIMER; //universal timer variable

unsigned long lastTick;

__inline void Tick()
{
UTIMER++;
}
END_OF_FUNCTION (Tick);

__inline unsigned long GetTicks()
{
return(UTIMER);
}

class C_GUI
{
public:
C_GUI(){}
~C_GUI(){}
dialog *AppWindow;
BITMAP *buffer;
void update()
{
AppWindow->draw();
blit(AppWindow->myGFX,buffer,0,0,AppWindow->myCoords.TL.x,AppWindow->myCoords.TL.y,AppWindow->width(),AppWindow->height());
}
void run();
};
typedef C_GUI EDITOR;
#endif


#include"SKOFE_COMPONENTS.h"
#include"SKOFE_GUI.h"

#include<fstream.h>

int main (void)
{

ofstream fout;
fout.open("testing.txt",ios::out);

allegro_init(); /* initialise the Allegro library */
install_timer(); // timer init

install_keyboard(); // keyboard init

install_mouse(); // mouse init

install_sound(DIGI_AUTODETECT,MIDI_AUTODETECT,""); // sound init

set_color_depth(16); // sets color depth

set_gfx_mode(GFX_AUTODETECT,640,480,0,0);

EDITOR window;
window.buffer = create_bitmap(640,480);//load_bitmap("SKOFEBKG.bmp",NULL);

window.AppWindow = new dialog;
window.AppWindow->headerText = "
Dialog header";
window.AppWindow->myCoords.TL.x = 200;
window.AppWindow->myCoords.TL.y = 200;
window.AppWindow->myCoords.BR.x = 300;
window.AppWindow->myCoords.BR.y = 300;
window.AppWindow->Ini(window.buffer);

UTIMER = 0;
LOCK_VARIABLE (UTIMER);
LOCK_FUNCTION (Tick);
install_int (Tick,1);

fout<<window.AppWindow->myCoords.height()<<endl;
fout<<window.AppWindow->myCoords.width()<<endl;

int exit = 1;

while(exit)
{
if(key[KEY_ESC]) exit = 0;

if(UTIMER % 10 == 0)
{
window.update();
acquire_screen();
vsync();
blit(window.buffer,screen,0,0,0,0,640,480);
release_screen();
}
}
fout.close();
allegro_exit();
return 0;
}

END_OF_MAIN()


it doesnt draw the rectangle like it should and im not sure why....

Share this post


Link to post
Share on other sites

  • 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!