FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Setting up OpenGL
Goto page 1, 2  Next
 
Post new topic   Reply to topic     Forum Index -> General
View previous topic :: View next topic  
Author Message
Workaphobia



Joined: 24 Jun 2004
Posts: 17

PostPosted: Fri Jun 25, 2004 7:32 pm    Post subject: Setting up OpenGL Reply with quote

Technically this is a Digital Mars compiler question and not a D one, but no one's responded on their newsgroup and I'm getting kind of impatient Wink

I'm interested in learning OpenGL for D. I figured I should crawl before I walk though, so I started with some C examples using DMC. I found that they worked fine in MSVC5 but wouldn't link under optlink because of this COFF vs OMF format war thing.

I've tried using both Borland's coff2omf and implib to create OMF files for opengl32.lib, glu32.lib, and glut32.lib, but after either method the resulting libraries were less than half as large and missing many entries. Can anyone here tell me how they got OpenGL to work under optlink, or drop me a url to someplace that has the libraries available in OMF?

I haven't tried it yet in dmd but I'm assuming since it uses the same backend compiler and linker I'll get the same problem.
_________________
"Nifty News Fifty: When news breaks, we give you the pieces."
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sat Jun 26, 2004 5:56 pm    Post subject: OpenGL and D Reply with quote

Since I don't really know C/C++ and I haven't worked with DMC, I can't answer your specific question.

But I would like to go out on a limb and suggest another way of reaching your goal of using "learning OpenGL for D". Have you considered playing around with the code for existing D projects that uses OpenGL? I think the best way to learn D is to use D. Sure, DMC and DMD share a linker and some guts, but DMD is more exciting and probably has more active newsgroups.

Here at dsource, several projects involve (or will involve) OpenGL to some extent.

unDig
http://badmama.com.au/~anderson/
Quote:
Dig is a GUI program with openGL support. The openGL section of dig is really cool as it's not just the standard openGL, it also comes with class support for things like matrices.

Derelict
http://www.dsource.org/forums/viewtopic.php?t=155
Quote:
Derelict 0.1 will now include OpenGL, glu, and SDL.

Deliria
http://www.dsource.org/forums/viewtopic.php?t=111
From the project description:
Quote:
An OpenGL game project similar to spectre


(I'm sorry if I left someone out.)
Back to top
View user's profile Send private message AIM Address
Workaphobia



Joined: 24 Jun 2004
Posts: 17

PostPosted: Sat Jun 26, 2004 9:02 pm    Post subject: Reply with quote

Oh yes, I agree about D being more exciting and having a more active community, and I wouldn't be interested in DMC were it not the only console C++ compiler I have (though I know that could be remedied). More importantly, it's not like there are any D tutorials that specifically relate to opengl (at least to my knowledge), while there are plenty for C.

I tried a while back to use Dig - or maybe it was another project, whichever one it was that was created by Burton Radons. Unfortunately I came across it after some major spec changes rendered it obsolete and the project fell into neglect. It didn't help at all that I couldn't compile the updated version - not because of some syntax problems, but because the self-compile command line was too long for windows 98 to handle, and required xp. At that point I just gave up on using any D GUI until someone releases a stable, well-maintained, easy to compile library.

These current projects for D, do they include everything necessary for opengl in their own libraries or do they need opengl32.lib on top?

I'm really not experienced enough to dissect a real project in any language and learn it from the source - excluding something trivial like finding a function overload.
_________________
"Nifty News Fifty: When news breaks, we give you the pieces."
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sat Jun 26, 2004 10:02 pm    Post subject: Reply with quote

Workaphobia wrote:
More importantly, it's not like there are any D tutorials that specifically relate to opengl (at least to my knowledge), while there are plenty for C.
You're definitely right on that one.

Workaphobia wrote:
I tried a while back to use Dig - or maybe it was another project, whichever one it was that was created by Burton Radons. Unfortunately I came across it after some major spec changes rendered it obsolete and the project fell into neglect. It didn't help at all that I couldn't compile the updated version - not because of some syntax problems, but because the self-compile command line was too long for windows 98 to handle, and required xp. At that point I just gave up on using any D GUI until someone releases a stable, well-maintained, easy to compile library.
It sounds like you tried the old Dig version on opend.org. Have you tried "unDig", too? I'm not sure if it'll compile on Win98, but it might. I've changed the makefile so that it doesn't rely so much on Digc (the Dig compilation tool).

Workaphobia wrote:
These current projects for D, do they include everything necessary for opengl in their own libraries or do they need opengl32.lib on top?
I think it depends on the project. UnDig does use libs (which come in the package). Derelict doesn't use .lib's:
From the Derelict forum:
Quote:
This little project is an effort to collate several modules which interface with various multimedia-related libraries. Each package will be self contained, eliminating the need for import lib dependencies - all shared libraries will be loaded dynamically by the modules.


Workaphobia wrote:
I'm really not experienced enough to dissect a real project in any language and learn it from the source - excluding something trivial like finding a function overload.
Well, I suspose I rarely do things the "easy" way. I don't know what complexities come into play with OpenGL, but D is often quite similar to C/C++. Perhaps, it wouldn't be that hard to convert existing C/C++ OpenGL examples into D (but taking hints from an existing D OpenGL project).

Not convinced? Neither am I. Sad

Back to the original question
Since you still want to go the DMC route, how exactly does your problem manifest? Do you get an error when you go to link the files?

If so, you might just need to create a .lib file by running Digital Mars's implib.exe on the .dll's in question (a .def file might be required, too, since you said you're missing entries).
Back to top
View user's profile Send private message AIM Address
Workaphobia



Joined: 24 Jun 2004
Posts: 17

PostPosted: Sat Jun 26, 2004 10:13 pm    Post subject: Reply with quote

I haven't tried undig yet, mostly because the old dig turned me against D GUIs for a while. If I ever get the hang of OpenGL the proper C++ way, I may use such tools rather than continue to do things the hard way - I just want to know the way things are really done before I get some utility to make things easy for me.

I get a link error. Without the libraries in the lib folder, it's obviously a missing library error. When I add the libraries as downloaded and unmodified, I get a invalid library error. When using implib (Borland's, not DMC's since I don't have the commercial CD version), the file is smaller and I get a couple dozen unresolved external symbol errors. Roughly the same thing happens with coff2omf. I'm not really sure how impdef would help - there were no def files in the opengl zip I downloaded, unless I'm missing something.

But people have gotten this to work with both DMC and Borland, and I want to know how. Since I'm using the same utility as Borland users, you'd think the library output would be the same as theirs - Outside of the errors specific to optlink, it's very obvious that something's wrong before attempting to compile, just judging by the file size. It can't possibly be just me. I hope. Wink
_________________
"Nifty News Fifty: When news breaks, we give you the pieces."
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sat Jun 26, 2004 10:32 pm    Post subject: Reply with quote

Workaphobia wrote:
I haven't tried undig yet, mostly because the old dig turned me against D GUIs for a while. If I ever get the hang of OpenGL the proper C++ way, I may use such tools rather than continue to do things the hard way - I just want to know the way things are really done before I get some utility to make things easy for me.
Fair enough. Dig has never been an exercise in minialistic programming. Smile

Workaphobia wrote:
I get a link error. Without the libraries in the lib folder, it's obviously a missing library error. When I add the libraries as downloaded and unmodified, I get a invalid library error. When using implib (Borland's, not DMC's since I don't have the commercial CD version), the file is smaller and I get a couple dozen unresolved external symbol errors.
Digital Mars's implib is part of the "Basic Utilies" package (freely available from DM). I don't think Borland's implib will work.

Workaphobia wrote:
I'm not really sure how impdef would help - there were no def files in the opengl zip I downloaded, unless I'm missing something.
You might not need a .def file at all. If you do need one, they're not that hard to create (I'll help if it comes to that). They can be tedious, but the linker usually gives good hints.

Different compilers use different .lib file formats. DM's .libs are incompatible with both Borland's and Visual Studio's.
Back to top
View user's profile Send private message AIM Address
Workaphobia



Joined: 24 Jun 2004
Posts: 17

PostPosted: Sat Jun 26, 2004 10:42 pm    Post subject: Reply with quote

I didn't know borland and dmc weren't compatible, since they both use OMF. I just tried DMC's implib and it produced the same results - the libs were only slightly larger than those created with Borland's tool. What would be the point of me creating a def file though? Wouldn't I need the file from someplace else?

[edit] Oh and the error isn't Unresolved external symbol, it's Symbol undefined, if there's a difference... Which there probably isn't. *shrug*
_________________
"Nifty News Fifty: When news breaks, we give you the pieces."
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sat Jun 26, 2004 11:32 pm    Post subject: Reply with quote

Workaphobia wrote:
I didn't know borland and dmc weren't compatible, since they both use OMF. I just tried DMC's implib and it produced the same results - the libs were only slightly larger than those created with Borland's tool. What would be the point of me creating a def file though? Wouldn't I need the file from someplace else?
You seem pretty obsessed about the size of the file. Maybe DM .libs are more efficient. I think .lib files are ad hoc formats that are kind of like archives containing .obj data or stubs (stubs in this case). I've tried mix-and-matching compiler tools and it's only caused me grief. Case in point: I'm sure that Borland's make is incompatible with DM's make.

Here's an example of a .def file:
Code:
LIBRARY opengl32

EXPORTS
_glAlphaFunc@8=glAlphaFunc
_glBegin@4=glBegin
_glBindTexture@8=glBindTexture
_glBlendFunc@8=glBlendFunc
_glCallList@4=glCallList
_glClear@4=glClear
_glClearColor@16=glClearColor
_glClearDepth@8=glClearDepth
_glColor3f@12=glColor3f
_glColor4f@16=glColor4f
_glColor4ub@16=glColor4ub
_glColorMask@16=glColorMask
_glColorPointer@16=glColorPointer
_glCopyTexImage2D@32=glCopyTexImage2D
_glCullFace@4=glCullFace
_glDeleteLists@8=glDeleteLists
_glDeleteTextures@8=glDeleteTextures
_glDepthFunc@4=glDepthFunc
_glDepthMask@4=glDepthMask
_glDepthRange@16=glDepthRange
_glDisable@4=glDisable
_glDisableClientState@4=glDisableClientState
_glDrawArrays@12=glDrawArrays
_glDrawElements@16=glDrawElements
_glEnable@4=glEnable
_glEnableClientState@4=glEnableClientState
_glEnd@0=glEnd
_glEndList@0=glEndList
_glFlush@0=glFlush
_glFogf@8=glFogf
_glFogfv@8=glFogfv
_glFogi@8=glFogi
_glFogiv@8=glFogiv
_glFrontFace@4=glFrontFace
_glFrustum@48=glFrustum
_glGenLists@4=glGenLists
_glGenTextures@8=glGenTextures
_glGetBooleanv@8=glGetBooleanv
_glGetDoublev@8=glGetDoublev
_glGetError@0=glGetError
_glGetFloatv@8=glGetFloatv
_glGetIntegerv@8=glGetIntegerv
_glGetLightfv@12=glGetLightfv
_glGetLightiv@12=glGetLightiv
_glGetMaterialfv@12=glGetMaterialfv
_glGetMaterialiv@12=glGetMaterialiv
_glGetString@4=glGetString
_glGetTexEnvfv@12=glGetTexEnvfv
_glGetTexEnviv@12=glGetTexEnviv
_glGetTexImage@20=glGetTexImage
_glGetTexLevelParameterfv@16=glGetTexLevelParameterfv
_glGetTexLevelParameteriv@16=glGetTexLevelParameteriv
_glGetTexParameterfv@12=glGetTexParameterfv
_glGetTexParameteriv@12=glGetTexParameteriv
_glHint@8=glHint
_glIsEnabled@4=glIsEnabled
_glLightfv@12=glLightfv
_glLightModelf@8=glLightModelf
_glLightModelfv@8=glLightModelfv
_glLightModeli@8=glLightModeli
_glLineWidth@4=glLineWidth
_glLoadIdentity@0=glLoadIdentity
_glLogicOp@4=glLogicOp
_glMaterialf@12=glMaterialf
_glMaterialfv@12=glMaterialfv
_glMatrixMode@4=glMatrixMode
_glMultMatrixd@4=glMultMatrixd
_glMultMatrixf@4=glMultMatrixf
_glNewList@8=glNewList
_glNormal3d@24=glNormal3d
_glNormal3f@12=glNormal3f
_glNormal3fv@4=glNormal3fv
_glNormalPointer@12=glNormalPointer
_glPixelStoref@8=glPixelStoref
_glPixelStorei@8=glPixelStorei
_glPointSize@4=glPointSize
_glPolygonMode@8=glPolygonMode
_glPolygonOffset@8=glPolygonOffset
_glPopAttrib@0=glPopAttrib
_glPopMatrix@0=glPopMatrix
_glPushAttrib@4=glPushAttrib
_glPushMatrix@0=glPushMatrix
_glReadPixels@28=glReadPixels
_glRotatef@16=glRotatef
_glScaled@24=glScaled
_glScalef@12=glScalef
_glShadeModel@4=glShadeModel
_glStencilFunc@12=glStencilFunc
_glStencilOp@12=glStencilOp
_glTexCoord2f@8=glTexCoord2f
_glTexCoordPointer@16=glTexCoordPointer
_glTexEnvf@12=glTexEnvf
_glTexEnvfv@12=glTexEnvfv
_glTexEnvi@12=glTexEnvi
_glTexEnviv@12=glTexEnviv
_glTexGenfv@12=glTexGenfv
_glTexGeni@12=glTexGeni
_glTexImage2D@36=glTexImage2D
_glTexImage1D@32=glTexImage1D
_glTexParameterf@12=glTexParameterf
_glTexParameterfv@12=glTexParameterfv
_glTexParameteri@12=glTexParameteri
_glTexParameteriv@12=glTexParameteriv
_glTranslatef@12=glTranslatef
_glVertex2f@8=glVertex2f
_glVertex3d@24=glVertex3d
_glVertex3f@12=glVertex3f
_glVertex3fv@4=glVertex3fv
_glVertex4f@16=glVertex4f
_glVertexPointer@16=glVertexPointer
_glViewport@16=glViewport
_wglCreateContext@4=wglCreateContext
_wglDeleteContext@4=wglDeleteContext
_wglGetCurrentContext@0=wglGetCurrentContext
_wglGetCurrentDC@0=wglGetCurrentDC
_wglGetProcAddress@4=wglGetProcAddress
_wglMakeCurrent@8=wglMakeCurrent
The idea is that the .dll has "wglMakeCurrent", but the linker was expecting "_wglMakeCurrent@8". Whether it's needed or not (and what the particular definitions are) depends on how the .dll was compiled and how the calling code is written. I don't know how this file was created, but I've created .def files by hand in the past. The compiler tells me what it can't find and I tell it what it's looking for.

Workaphobia wrote:
[edit] Oh and the error isn't Unresolved external symbol, it's Symbol undefined, if there's a difference... Which there probably isn't. *shrug*
If you would you paste the error messages into a post, that might give me a better idea of what's going on.
Back to top
View user's profile Send private message AIM Address
Workaphobia



Joined: 24 Jun 2004
Posts: 17

PostPosted: Sun Jun 27, 2004 9:12 am    Post subject: Reply with quote

Just one of these:
Code:
Error 42: Symbol Undefined _glEnable@4


Ok where to begin... I just tried tinkering around with def files but I'll need to find impdef.exe. I then saw in optlink's flag list a "impdef" feature and "implib" feature staring me in the face, but neither one helped - I have no idea what a .din file (produced with /impdef) does, and the output .lib (from /implib) is 1kb. Now you can't tell me size doesn't signify anything there Wink.
_________________
"Nifty News Fifty: When news breaks, we give you the pieces."
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sun Jun 27, 2004 11:37 am    Post subject: Reply with quote

Workaphobia wrote:
Just one of these:
Code:
Error 42: Symbol Undefined _glEnable@4
Yeah, it doesn't sound like the .lib you're using has what you need in it. Did you notice that the example has a line that says "_glEnable@4=glEnable"? That might be a clue that we're closing in on a solution.

Workaphobia wrote:
Ok where to begin... I just tried tinkering around with def files but I'll need to find impdef.exe. I then saw in optlink's flag list a "impdef" feature and "implib" feature staring me in the face, but neither one helped - I have no idea what a .din file (produced with /impdef) does, and the output .lib (from /implib) is 1kb. Now you can't tell me size doesn't signify anything there Wink.
After all of this typing, we still seem to be on different wavelengths. I don't know of a "impdef" program. I just hack together my own .def file. Then I use it like this:
Code:
implib opengl32.lib opengl32.def
where opengl.def is hand-written .def file and opengl32.lib is the file I want to create.

Since this is such a stumbling block, I just had another idea. Try using unDig's opengl32.lib (it's stored in the SVN repository). If you can't make use of a .def file or unDig's .lib, I don't know what to tell you. Maybe someone who knows something about OpenGL will jump into this thread.
Back to top
View user's profile Send private message AIM Address
Workaphobia



Joined: 24 Jun 2004
Posts: 17

PostPosted: Sun Jun 27, 2004 11:47 am    Post subject: Reply with quote

jcc7 wrote:
Yeah, it doesn't sound like the .lib you're using has what you need in it. Did you notice that the example has a line that says "_glEnable@4=glEnable"? That might be a clue that we're closing in on a solution.

Yeah, I know it was in the def. I may be a bit obtuse, but I saw it;)

jcc7 wrote:
After all of this typing, we still seem to be on different wavelengths. I don't know of a "impdef" program. I just hack together my own .def file. Then I use it like this:
Code:
implib opengl32.lib opengl32.def
where opengl.def is hand-written .def file and opengl32.lib is the file I want to create.

Apparently implib for DMC includes what borland releases as a separate tool: impdef. Thanks for the syntax clue - I made a .def for one symbol, implib'd it, and used that library. That entry then disappeared from the error list. I'll do the same for all the others I come across and see what happens at the end.

This is the part where I cross my fingers and pray a bit.
_________________
"Nifty News Fifty: When news breaks, we give you the pieces."
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sun Jun 27, 2004 12:07 pm    Post subject: Reply with quote

Workaphobia wrote:
jcc7 wrote:
Yeah, it doesn't sound like the .lib you're using has what you need in it. Did you notice that the example has a line that says "_glEnable@4=glEnable"? That might be a clue that we're closing in on a solution.

Yeah, I know it was in the def. I may be a bit obtuse, but I saw it;)
I'm not a professional programmer. When I'm working on something, I tend to start throwing stuff at the compiler and see what sticks. I thought I might have seen a clue there. Smile

Workaphobia wrote:
Apparently implib for DMC includes what borland releases as a separate tool: impdef.
I didn't realize that.

jcc7 wrote:
Thanks for the syntax clue - I made a .def for one symbol, implib'd it, and used that library. That entry then disappeared from the error list. I'll do the same for all the others I come across and see what happens at the end.

This is the part where I cross my fingers and pray a bit.
It sounds like you're on the right track. When you try to run your .exe, make sure it can find opengl32.dll. I would probably do this by dropping the .dll in the same folder as the .exe. Otherwise, you could put the .dll somewhere in your PATH.
Back to top
View user's profile Send private message AIM Address
Workaphobia



Joined: 24 Jun 2004
Posts: 17

PostPosted: Sun Jun 27, 2004 12:19 pm    Post subject: Reply with quote

Excuse me, I need to get something off my chest.


YAHHHHHHHHOOOOO! Very Happy

It compiles! I had a few missing linked import errors of some sort, due to typos in my defs, but once I got that out of the way I was able to open the exe and see the multicolored cube rotate in front of the camera. It actually works!

Now I'm betting since this particular program could not have used all the functions in openGL, that there will be plenty of other entries I'll have to add along the way to my .def file. So long as this doesn't fall apart again, I don't mind doing that. Time to experiment, I guess.

Thanks for all your help. I posted this question on both the DMC newsgroup and the opengl.org forums, and haven't gotten more than one reply from either.

[edit] By the way, my final library sizes were all below 5 kilobytes. Makes me really wonder what was in the original libraries if all you need is the dlls.
_________________
"Nifty News Fifty: When news breaks, we give you the pieces."
Back to top
View user's profile Send private message
jcc7



Joined: 22 Feb 2004
Posts: 657
Location: Muskogee, OK, USA

PostPosted: Sun Jun 27, 2004 1:35 pm    Post subject: Reply with quote

Workaphobia wrote:
YAHHHHHHHHOOOOO! Very Happy
Congratulations!

Workaphobia wrote:
Now I'm betting since this particular program could not have used all the functions in openGL, that there will be plenty of other entries I'll have to add along the way to my .def file.
I suspect the unDig .def file is pretty complete. You might be able to paste those into your .def file. In any case, whatever works is good.

Workaphobia wrote:
Thanks for all your help.
You're quite welcome. I'm glad I was able to help.

Workaphobia wrote:
[edit] By the way, my final library sizes were all below 5 kilobytes. Makes me really wonder what was in the original libraries if all you need is the dlls.
I don't know. It could be that your .lib will grow to a similar size as your add the other definitions. Or maybe DM tools are very efficient in .lib size. Or perhaps those .libs are designed so that the .dll wouldn't be required for those compilers. I'm still murky or the static linking vs. dynamic linking vs. compiling into the .exe issues.
Back to top
View user's profile Send private message AIM Address
JJR



Joined: 22 Feb 2004
Posts: 1104

PostPosted: Sun Jun 27, 2004 4:17 pm    Post subject: Reply with quote

I don't really understand why all this was necessary with dmc. dmc includes all the opengl implibs in the zip file to begin with. There should be no need to make a "def" file at all. Just comple with dmc and and link with the appropriate libs.

The only reason that you would want to implib opengl32.dll and such is if you want to work with a more recent opengl dll with more listed functions (this can happen if you update your headers for a more recent opengl version). Since there's slight conversion details necessary to make things work, there are actually a couple of options for doing this (if you search the digitalmars C++ newsgroup, you'll probably see quite a few people who have been asking about opengl; this goes way back):

1) use the openwatcom linker which supports both OMF and COFF (this simplifies the format issues) right here. These great tools are provided by Christof Meerwald, by the way, (borrowed from the openwatcom project) and likely something you will want to add to your dmc distribution eventually anyway.

or 2) use a modified version of implib provided by Jan Knepper so that compatible symbols will be generated (I can't remember how this is done or where the link is to Jan's modified version, but just do a search on C++ or C++.windows.32-bits newsgroups on implib and you should get the link)

Otherwise you should just link with the provided opengl32.lib, glaux.lib and glu32.lib. If you do link with all 3 libs, you shouldn't have any undefined symbols.

Note, I played with opengl and dmc a little over a year ago and ran into some troubles too, but it had more to do with forgetting to include all the necessary libs (well that and a corrupt opengl32.lib). I got it working eventually, though.

Even though it looks like you got things working, I just wanted to stress that you shouldn't have to go to so much trouble getting it to work if it's just a basic opengl project using basic opengl features.

Later,

John
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> General All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group