Thread overview |
---|
June 26, 2006 modules && type inheritance? | ||||
---|---|---|---|---|
| ||||
I use derelics for my sdl/opengl application and I wanted to make one module to hold all my structures. I don't know much about scope and inheritance of types and thus don't know how to make this work :( In my structures I use the OpenGL types (GLubyte etc.) What do I have to do to make these types visible to other modules? Or.. where can I read about this :) btw. Is it really necessary to use the gl types iso d types? |
June 26, 2006 Re: modules && type inheritance? | ||||
---|---|---|---|---|
| ||||
Posted in reply to MM | MM wrote:
> I use derelics for my sdl/opengl application and I wanted to make one module to
> hold all my structures. I don't know much about scope and inheritance of types
> and thus don't know how to make this work :(
> In my structures I use the OpenGL types (GLubyte etc.)
> What do I have to do to make these types visible to other modules?
> Or.. where can I read about this :)
> btw. Is it really necessary to use the gl types iso d types?
>
>
import the structures module in any module that will need to use them
<code name="structs.d">
struct foo{int i;}
</code>
<code name="other.d">
import structs;
void main()
{
foo bar;
bar.i = 3;
return;
}
</code>
|
June 26, 2006 Re: modules && type inheritance? | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS |
>import the structures module in any module that will need to use them
>
>
><code name="structs.d">
>struct foo{int i;}
></code>
>
><code name="other.d">
>import structs;
>
>void main()
>{
> foo bar;
> bar.i = 3;
> return;
>}
></code>
>
Thx for the reply, and sorry for my ambigious question :)
I import like this:
import std.string;
import std.c.stdio;
import derelict.util.exception;
import derelict.opengl.gl;
import derelict.sdl.sdl;
import derelict.sdl.image;
import derelict.opengl.glu;
import structures;
And get this error:
structures.d(19): identifier 'GLubyte' is not defined
|
June 26, 2006 Re: modules && type inheritance? | ||||
---|---|---|---|---|
| ||||
Posted in reply to MM | MM wrote:
>>import the structures module in any module that will need to use them
>>
>>
>><code name="structs.d">
>>struct foo{int i;}
>></code>
>>
>><code name="other.d">
>>import structs;
>>
>>void main()
>>{
>> foo bar;
>> bar.i = 3;
>> return;
>>}
>></code>
>>
>
> Thx for the reply, and sorry for my ambigious question :)
>
> I import like this:
>
> import std.string;
> import std.c.stdio;
>
> import derelict.util.exception;
> import derelict.opengl.gl;
> import derelict.sdl.sdl;
> import derelict.sdl.image;
> import derelict.opengl.glu;
>
> import structures;
>
> And get this error:
> structures.d(19): identifier 'GLubyte' is not defined
>
>
"structures.d" will need to import anything that it needs, so find which derelict import defines GLubyte and add an import line for it in structures.d.
|
June 26, 2006 Re: modules && type inheritance? | ||||
---|---|---|---|---|
| ||||
Posted in reply to BCS |
>"structures.d" will need to import anything that it needs, so find which derelict import defines GLubyte and add an import line for it in structures.d.
Adding
import derelict.opengl.gl;
did the trick :)
Note to self > Modules are no C Header files :D
thx.
Would you by chance know whether it is necessary/good programming to use the
opengl types iso D types? :)
|
June 27, 2006 Re: modules && type inheritance? | ||||
---|---|---|---|---|
| ||||
Posted in reply to MM | MM wrote:
> Would you by chance know whether it is necessary/good programming to use the
> opengl types iso D types? :)
Personally, I would use the OpenGL types, but there isn't really a difference.
|
Copyright © 1999-2021 by the D Language Foundation