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

DerelictGL is owning me :(
Goto page 1, 2  Next
 
Post new topic   Reply to topic     Forum Index -> Derelict
View previous topic :: View next topic  
Author Message
smr



Joined: 07 Jun 2005
Posts: 5

PostPosted: Wed Jun 28, 2006 11:21 pm    Post subject: DerelictGL is owning me :( Reply with quote

Derelict is kicking my ass right now Sad I'm having some of the most peculiar problems I've ever experienced. I am trying to port the simple opengl example 2 downloadable from the sdl website.

Here's the location of the D file:
dsg.d
And the C file which I'm porting:
lesson2.c

First problem:
Code:

void InitOpenGlState(int width, int height)
{
   glViewport(0, 0, width, height);
   glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   glClearDepth(1.0);
   glDepthFunc(GL_LESS);
   glEnable(GL_DEPTH_TEST);
       
        // enabling this line produces Divide by zero error with GL_FLAT and GL_SMOOTH
   glShadeModel(GL_FLAT);
        // enabling this line also produces divide by zero
   //glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluPerspective(45.0f, width / height, 0.1f, 100.0f);
   glMatrixMode(GL_MODELVIEW);
   x += 1;
   return;
}


Changing the function to this produces a linker error. All I've done is commented out all calls in the function
Code:

static int x;
void InitOpenGlState(int width, int height)
{
   /*
   glViewport(0, 0, width, height);
   glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
   glClearDepth(1.0);
   glDepthFunc(GL_LESS);
   glEnable(GL_DEPTH_TEST);
   //glShadeModel(GL_FLAT);
   //glMatrixMode(GL_PROJECTION);
   glLoadIdentity();
   gluPerspective(45.0f, width / height, 0.1f, 100.0f);
   glMatrixMode(GL_MODELVIEW);
   */
   x += 1;
   return;
}


C:\Dev\Dsg\Dsg\OBJECT~1\Dsg.obj(Dsg)
Error 42: Symbol Undefined _D8derelict4util6loader141__T13GenericLoaderVG9aa9_676c7533322e646c6cVG9aa9_6c6962474c552e736fVG0aa0_S62_D8derelict6opengl3glu4loadFC8derelict4util6loader9SharedLibZvZ13GenericLoader4loadFAaZv

As you can see I've added an operation to a static global which I print later. I was curious if the linker or the optimizer was being too aggressive and omitting object code because it had no effect. Why the undefined symbol seems to be on GenericLoader instead of InitOpenGlState is beyond me.

Produces access violation:
Code:

void Render()
{
   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
   /*
   glLoadIdentity();
   
   glBegin(GL_POLYGON);
   glVertex3f(0.0f, 1.0f, 0.0f);
   glVertex3f(1.0f, -1.0f, 0.0f);
   glVertex3f(-1.0f, -1.0f, 0.0f);
   glEnd();
   */
   SDL_GL_SwapBuffers();
}



I really don't know whats going on! It seems like DerelictGL is having some issues on my machine. Would it be possible to receive a prebuilt DerelictGL tree from someone with a working installation? I've been fighting this thing all night.
Back to top
View user's profile Send private message
Crispy



Joined: 26 Nov 2005
Posts: 67

PostPosted: Thu Jun 29, 2006 3:29 am    Post subject: Reply with quote

What arguments are you passing to build/dmd to compile your project? Make sure you are actually linking in Derelict.

The access violation is occurring because you haven't called DerelictGL.load() before executing glClear(). So the symbol "glClear" (which is just a function pointer in Derelict, rather than the actual function itself) evaluates to null. So when you try and call it, boom! Access violation.
Back to top
View user's profile Send private message
smr



Joined: 07 Jun 2005
Posts: 5

PostPosted: Thu Jun 29, 2006 6:54 am    Post subject: Reply with quote

I am just using the build script to build it. I'm not providing any additional options.

I am linking in derelictgl.lib, derelictglu.lib, derelictsdl.lib and derelictutil.lib.

DerelictGL.load() is being called in Setup(). I actually make some successful opengl calls before the call to glClear().
Back to top
View user's profile Send private message
smr



Joined: 07 Jun 2005
Posts: 5

PostPosted: Thu Jun 29, 2006 11:23 am    Post subject: Reply with quote

Ok. I've redownloaded the derelict source code and rebuilt it from scratch with the build utility and script. Now Here's the linker error I receive:

Error 42: Symbol Undefined _D8derelict4util6loader149__T13GenericLoaderVG12aa12_6f70656e676c33322e646c6cVG8aa8_6c6962474c2e736fVG0aa0_S64_D8derelict6opengl2gl7loadAllFC8derelict4util6loader9SharedLibZvZ13GenericLoader4loadFAaZv

Is there a specific order in which I must link the files or something?
Back to top
View user's profile Send private message
Deewiant



Joined: 26 Dec 2005
Posts: 21
Location: Finland

PostPosted: Thu Jun 29, 2006 11:36 am    Post subject: Reply with quote

Somebody else already posted about this in the thread "First application problem". The situation was bypassed but I reraised the concerns after this threw me off, too - see the (currently) last two messages of that thread.

The problem is that the compiled .lib files don't work due to the GenericLoaders being templates and something beyond my understanding regarding how templates aren't compiled into object files, or some such. Essentially, this means that building the Derelict libraries is currently useless: the way to get your Derelict code to compile is to have Build (or you can do it manually, too, though it's a bit tedious) compile the original Derelict modules along with your project.

Which, in turn, usually means moving the "derelict" directories from under each package in the Derelict source to your dmd/src directory, and making sure -Xderelict isn't thrown when you compile your app with Build. Manually, you'd have to pass each relevant Derelict module to DMD yourself.
Back to top
View user's profile Send private message
smr



Joined: 07 Jun 2005
Posts: 5

PostPosted: Thu Jun 29, 2006 11:48 am    Post subject: Reply with quote

Great! Thanks. It works now. I just included all of the derelict source files in my build. Not ideal I guess, but it works.
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Thu Jun 29, 2006 3:54 pm    Post subject: Reply with quote

Try with the .lib approach again. I've just commited a modification to Derelict's library loading procedures.
Back to top
View user's profile Send private message MSN Messenger
smr



Joined: 07 Jun 2005
Posts: 5

PostPosted: Thu Jun 29, 2006 5:49 pm    Post subject: Reply with quote

I've updated svn then rebuilt. The changes work great. Thanks!
Back to top
View user's profile Send private message
Deewiant



Joined: 26 Dec 2005
Posts: 21
Location: Finland

PostPosted: Fri Jun 30, 2006 4:48 am    Post subject: Reply with quote

I, on the other hand, get even more errors with this latest change. The libraries build fine, but any attempt at linking them into anything causes a cascade of errors; it seems that no symbol at all is defined. The following program, for instance:
Code:
import derelict.sdl.sdl;

void main() {
   DerelictSDL.load();
}

Building it without libraries linked in, "dmd asdf.d", gives the following two errors, as expected:
Code:
asdf.obj(asdf)
 Error 42: Symbol Undefined _D8derelict3sdl3sdl11DerelictSDLS8derelict4util6loader13GenericLoader
asdf.obj(asdf)
 Error 42: Symbol Undefined _D8derelict4util6loader13GenericLoader4loadFAaZv

Linking in a freshly built DerelictUtil.lib, "dmd asdf.d DerelictUtil.lib", changes the situation a bit:
Code:
asdf.obj(asdf)
 Error 42: Symbol Undefined _D8derelict3sdl3sdl11DerelictSDLS8derelict4util6loader13GenericLoader
DerelictUtil.lib(loader)
 Error 42: Symbol Undefined _D8derelict4util9exception22SharedLibLoadException5_ctorFAaZC8derelict4util9exception22SharedLibLoadException
DerelictUtil.lib(loader)
 Error 42: Symbol Undefined __Class_8derelict4util9exception22SharedLibLoadException


Adding DerelictSDL.lib changes OptLink's errorlevel from 3 to 189: every single SDL symbol appears to be undefined. Building the libraries in debug or release mode makes no difference.

Building directly from the Derelict *.d files works, as usual.
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Fri Jun 30, 2006 7:12 am    Post subject: Reply with quote

I'm unable to reproduce your results. Could you make sure that all libraries are rebuilt and DMD links with the correct ones ? If it still doesn't work, please post the process you're going through so we can do something about it ? The following command works for me without any problems:

dmd dtest.d -Iderelict/DerelictSDL -Iderelict/DerelictUtil DerelictUtil.lib DerelictSDL.lib

where dtest.d is your simple test program and the 'derelict' lib is the svn trunk directory of Derelict.
Back to top
View user's profile Send private message MSN Messenger
Deewiant



Joined: 26 Dec 2005
Posts: 21
Location: Finland

PostPosted: Fri Jun 30, 2006 8:40 am    Post subject: Reply with quote

I can't find an error in what I'm doing:

  • Ensure a clean start: remove dmd/src/derelict and Derelict*.lib from dmd/lib.
  • Get Derelict from http://158.75.59.9/~h3/tmp/getDerelict.zip.spy
  • Extract the resulting Derelict.zip into dmd/, creating dmd/Derelict.
  • Run "dmd -run buildme.d" in dmd/Derelict. No errors result.
  • Copy 405 KiB worth of .lib files from dmd/Derelict/lib to dmd/lib.
  • Take each subdirectory named "derelict" in the various Derelict packages' directories and copy them to dmd/src.
  • Try compiling the above with "dmd asdf.d DerelictUtil.lib DerelictSDL.lib". Get errorlevel 189 from OptLink.
Back to top
View user's profile Send private message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Fri Jun 30, 2006 8:46 am    Post subject: Reply with quote

There you go Smile

Don't put the downloaded Derelict sources in the dmd directory tree. Build skips these dirs by default, so it doesn't really compile everything. If you put Derelict somewhere else than the dmd dir, libs should weigh 1.24MB
Back to top
View user's profile Send private message MSN Messenger
Deewiant



Joined: 26 Dec 2005
Posts: 21
Location: Finland

PostPosted: Fri Jun 30, 2006 9:53 am    Post subject: Reply with quote

h3r3tic wrote:
There you go Smile

Don't put the downloaded Derelict sources in the dmd directory tree. Build skips these dirs by default, so it doesn't really compile everything.

Shocked Since which version? It used to work fine. Is there a switch that can be thrown to bypass this restriction?

If not, I'll have to take this change up with Derek. Twisted Evil

FWIW, I tried to throw -V to Build so that it would show me exactly what it's doing, but it never noticed the flag... Is that a bug in new versions of Build (I'm using 3.02, but 2.10 handles it correctly) or does this work with you, too? Confused

EDIT: posted too soon. I moved the Derelict directory to an entirely different partition of my hard drive and the libs still weigh only around 405 KiB when compiled. I'll see what Build 2.10 has to say.

EDIT 2:

Got it. There's a bug in buildme.d: it misses the last line in each of the build_*.txt files. Hence the "--Xderelict" wasn't getting through and the -Xderelict I have in my build.cfg made Build refuse to build anything. I added a blank line to the end of build_common.txt and Derelict was built fine.

I didn't take a detailed look at the code, but it should be easy to fix.

Quote:
If you put Derelict somewhere else than the dmd dir, libs should weigh 1.24MB

My libs weigh in at 1.50 MiB now, ha! Cool
Back to top
View user's profile Send private message
Deewiant



Joined: 26 Dec 2005
Posts: 21
Location: Finland

PostPosted: Fri Jul 07, 2006 1:56 pm    Post subject: Bug fixed Reply with quote

Alright, I went through buildme.d and found the problematic code.
Code:
--- buildme_old.d   2006-06-28 12:23:20.000000000 +0300
+++ buildme.d   2006-07-07 22:45:16.939614000 +0300
@@ -158,14 +158,14 @@
    if(exists(commonTxt))
    {
       // read it in and assign it to the brf buffer
-      brfBuf = "\n" ~ cast(char[])read(commonTxt);
+      brfBuf = cast(char[])read(commonTxt);
    }
    
    // if a build configuration file is present...
    if(exists(configTxt))
    {
       // ... read it in and append it to the buffer
-      brfBuf ~= cast(char[])read(configTxt);
+      brfBuf ~= "\n" ~ cast(char[])read(configTxt);
    }
 }
 

In essence, the extra line break was being put in at the wrong place, and thusly the last line of commonTxt ended up on the same line as the first line of configTxt --- both lines were thus out of commission.
Back to top
View user's profile Send private message
aldacron



Joined: 05 May 2004
Posts: 1322
Location: Seoul, South Korea

PostPosted: Sun Jul 09, 2006 6:41 pm    Post subject: Reply with quote

Thanks, Deewiant. Just wanted to let you know I'm not ignoring you. I'll get around to fixing this a soon as I can.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Derelict 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