Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Glu Header porting(declaring struct identifiers)
#1
A while ago, I asked Marzec how to implement temporary structs in FB. After some time he was able to point me to the right direction by advising me to make a dummy struct of the same name. After 2 days of reasearch and thinking about it on my own, I finally understand how GLUnurbs, GLUtesselators, and GLUquadrics structs are implemented. That is "hidden" from the user. Now I would like to clarify some things before starting the port.

Notice: All codes untestested!

In C/C++, you can do this:

Code:
typedef struct point3d;  //This is a valid declaration of a struct

Then hide the struct itself in a compiled program such as a LIB/OBJ.

Actual Struct code hidden:

Code:
typedef struct
{
    float x;
    float y;
    float z;
}point3d;

After that, declare it like so in the header file:

Code:
void myfunk(point3d *blah)  //pass byref as pointer to above struct

Now this is fine and dandy in C/C++ as this is how coders hide implementation of code. I'm wondering if this could be done in FB.

As Marzec and I discussed this is supposed to work:

Code:
type point3d
    dummy as integer        'make a dummy struct
end type

Since we only need a pointer:
Code:
declare sub myfunk(byref blah as point3d)

One problem I see with is is the fact that in C/C++, you can just declare a structure and make a pointer to point to that struct but we have to declare a structure with a dummy member in FB.

Now what I'm really not sure is, since point3d is actually hidden from the user, and pointers in FB and C/C++ are identical (dword address?), would the above work around be valid?

In case you're all wondering, I'm porting the GLU header file and if I have time some other headers for SDL and GL but I only have till tonight to finish it or wait another week.

Thanks in advance!!!

Ps. v1c: Would it be possible for FB to have these funks?

1. LOWORD
2. HIWORD

I have just seen zydons windows example and he had to do an AND to extract what is required of Lparam/Wparam. having those funks would certainly make code more readable and understandable.
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#2
It should be done with byval arguments declare as any ptr, much simpler..

Say, GLU will return/allocate the point3d for you, right? So you can have:

Code:
#define point3d any

declare function somefunc () as point3d ptr

declare sub somesub( byval arg as point3d ptr )

dim p as point3d ptr

p = somefunc
somesub p

Makes more sense, byref arguments don't really mix most of time with libraries made for C.

LOWORD are HIWORD would be better implemented as macros (when FB get those), more reserved words = bad, imo.
Reply
#3
Thanks!!!
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#4
didn't think of the pp, really a lot better that way
quote="NecrosIhsan"]
[Image: yagl1.png]
[/quote]
Reply
#5
v1c: Check your PM.

BTW, what is the max possible code length in one line in BI files?

I need to change my glasses.

I was almost sure I saw:

#define Blah as bleh

instead of

#define Blah bleh


Sorry
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#6
Finished!!!

GLU Nurbs and Quadrics tested!!!

Will test the others on Saturday.

http://qh2.qbtk.com/111-d
y smiley is 24 bit.
[Image: anya2.jpg]

Genso's Junkyard:
http://rel.betterwebber.com/
Reply
#7
Cool!!! I started doing it, but I really only needed gluBuildMipMaps and gluLookAt. I'll start testing them now. Tongue
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)