[interfacekit] Re: App Server Startup procedures and question
- From: Erik Jakowatz <erik@xxxxxxxxxxxxxx>
- To: interfacekit@xxxxxxxxxxxxx
- Date: Mon, 17 Sep 2001 15:23:13 -0700
OK, here's a really cheesy example that will, hopefully, show you what
I'm talking about. The control_graphics_card function pointer in
TGraphicsDevice is the closest we'll ever get to actually linking to
that symbol -- in fact, I only called it that just to make the example
more clear; we could've called it "foo", just as long as the signature
was the same.
It sounds to me like you're trying to link directly to a graphics
driver; you'll want to stop that. ;) Since all the drivers are loaded
as app_server addons, we don't link directly with *any* of them, we just
load them at run time. Additionally, if you're working with
BWindowScreen (for the prototype you're building), there's no need to
worry about all this anyway -- BWindowScreen takes care of all this
stuff for you. Eventually, of course, we'll have to take care of
loading the graphic driver addons, and that's what the example code
below is trying to illustrate. For now, however, we don't need to worry
about it.
e
// GraphicsDevice.h
class TGraphicsDevice {
public:
...
status_t Init();
...
private:
image_id deviceLibId;
int32 (*control_graphics_card)(uint32 opcode, void *data);
};
// GraphicsDevice.cpp
status_t TGraphicsDevice::Init()
{
for (;;)
{
deviceLibId = load_add_on("/path/to/graphics/driver/here");
if (deviceLibId < 0)
break;
get_image_symbol(deviceLibId, "control_graphics_card",
B_SYMBOL_TYPE_TEXT, (void**)control_graphics_card);
if (B_OK != control_graphics_card(B_OPEN_GRAPHICS_CARD, ...)
{
control_graphics_card(B_CLOSE_GRAPHICS_CARD, ...);
unload_add_on(deviceLibId);
deviceLibId = B_ERROR;
}
else
{
// configure the card as necessary
break;
}
}
if (deviceLibId < 0)
{
// print error message here
}
}
DarkWyrm wrote:
>
> >Wow, this is great stuff. The Layer stuff you posted the other night
> >was really good as well.
> >
> >Regarding the linker problem, you're not going to be linking to
> >control_graphics_card at build time -- you'll load the symbol at run
> >time. So whatever code you have that's trying to link at build time
> >will need revision. Check out the docs on loading symbols from addons
> >in the Kernel Kit docs. If any of it isn't clear let me know, and I can
> >whip up an example; my main BeOS project is an addon *festival*, so I've
> >done it plenty! =P
> >
> >e
> Glad to know I'm appreciated. :) I looked at the Kernel kit docs, and I'm
> still confused about imports/exports. Moreover, how, specifically, should I
> change my code to not attempt link to link control_graphics_card()? I've
> included GraphicsCard.h, which is where it is declared.
>
> --DW
- Follow-Ups:
- References:
- [interfacekit] Re: Graphics
- From: Erik Jakowatz
- [interfacekit] App Server Startup procedures and question
- From: DarkWyrm
- [interfacekit] Re: App Server Startup procedures and question
- From: Erik Jakowatz
- [interfacekit] Re: App Server Startup procedures and question
- From: DarkWyrm
Other related posts:
- » [interfacekit] App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- » [interfacekit] Re: App Server Startup procedures and question
- [interfacekit] Re: Graphics
- From: Erik Jakowatz
- [interfacekit] App Server Startup procedures and question
- From: DarkWyrm
- [interfacekit] Re: App Server Startup procedures and question
- From: Erik Jakowatz
- [interfacekit] Re: App Server Startup procedures and question
- From: DarkWyrm