|
Getting Started With Openlayer |
Fasine
Member #8,221
January 2007
|
Okay, I got OpenLayer working and am thus far impressed by the demo programs (I compiled them myself in the same project as this program, so know the linker is setup correctly now.) And decided to write a quick test program of my own using the new commands for practice and quickly ran into trouble. This is the code:
And this is the error I got: [EDIT]: It didn't actually return an error, just said that it failed, this is from the Compile Log. Compiler: Default compiler g++.exe: graphics test: linker input file unused because linking not done g++.exe "graphics test.o" -o "Game3.exe" -L"C:/Dev-Cpp/lib" -mwindows -lopenlayer -lglyph -lfreetype -lloadpng -lpng -lz -lagl -lalleg -luser32 -lgdi32 -lglu32 -lopengl32 g++.exe: graphics test.o: No such file or directory make.exe: *** [Game3.exe] Error 1 Execution terminated No doubt I've done something dumb again. Who can tell me what? =) PS- Do I need to set up a double buffer in OpenLayer? It looks like the GfxRend::RefreshScreen() command takes care of that, but I could be wrong, and if so: how do I go about it. Again: thanks for your replies, everyone. |
Kauhiz
Member #4,798
July 2004
|
Quote: Do I need to set up a double buffer in OpenLayer? It looks like the GfxRend::RefreshScreen() command takes care of that You don't need a double buffer. However, AFAIK you're not supposed to use GfxRend anymore. You should use Canvas instead. --- |
Fladimir da Gorf
Member #1,565
October 2001
|
Quote: if(!IsProgramSetup) There's no global variables anywhere. You should test if the setup functions return false, instead. Quote: You don't need a double buffer. However, AFAIK you're not supposed to use GfxRend anymore. You should use Canvas instead. I some of the old demos still use GfxRend. I'm changing those atm. The line should read "Canvas::Refresh()". EDIT: Now the demos don't use GfxRend anymore. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
Fasine
Member #8,221
January 2007
|
Okay, I changed the command to Canvas::Refresh(), but it still doesn't compile, unfortunately. I get the below error, accompanied by the same info in the compile log. -C:\Dev-Cpp\Makefile.win [Build Error] [Game3.exe] Error 1 Does this line indicate a problem of some sort? -g++.exe: graphics test: linker input file unused because linking not done The linker is filled out with all the fields that made the demo programs work, so I'm not sure why it's not linking. Any suggestions, and is there more info about the problem I should be providing? (And where can I find it?) Thanks, as always. |
ImLeftFooted
Member #3,935
October 2003
|
Hows OpenLayer working on windows going? Does it have a working makefile yet? |
juvinious
Member #5,145
October 2004
|
Fasine
Member #8,221
January 2007
|
Okay, I've made every (bad word) dumb mistake imagineable... It turns out that the project was failing to compile since there was a space in my filename (duh...) then it complained of a circular dependency because I forgot to suffix it with .cpp, and now it's giving me real compiler errors, saying that none of the OpenLayer commands have been declared, so I'm posting the source again, in hopes that someone can help me find the dumb mistake.
and in the linker: -lopenlayer -lglyph -lfreetype -lloadpng -lpng -lz -lagl -lalleg Roughly the same Compile Log as before, which pobably just said "failed to compile" in elaborate terms. Again, thanks for your time everyone! Perhaps we'll make a game of it: "Who can find Fasine's dumb mistake fastest?!" =P |
Fladimir da Gorf
Member #1,565
October 2001
|
Fixed the code:
OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
Fasine
Member #8,221
January 2007
|
Thanks, Fladmir, that worked beautifully. One more dumb question though: how do I set up the myTextRenderer.Print function? It keeps saying it's undeclared, and I can't seem to use the textprintf_ex(screen,...) function, since I can't pass SCREEN_BACKBUF to it, and screen apparently has no effect when passed. Thanks a ton for all your help, Fladmir and everyone else, too. I think I'm jumping in at the deep end as far as re-learning C, but I don't give up easily, and these forums are a great help. PS- "String" keeps coming up as undefined, what header file do I need to declare for it? <string.h> didn't work. Or is it within the myTextRenderer function? |
Kauhiz
Member #4,798
July 2004
|
Quote: how do I set up the myTextRenderer.Print function? That's in the manual. Quote: I can't seem to use the textprintf_ex(screen,...) function, since I can't pass SCREEN_BACKBUF to it, and screen apparently has no effect when passed. That's because SCREEN_BACKBUF isn't an allegro bitmap. And textprintf_ex works for screen, but since screen doesn't get drawn, you won't see it. Quote: "String" keeps coming up as undefined, what header file do I need to declare for it? It's actually std::string. Put using namespace std at the top of you code (like you have for ol). --- |
Fasine
Member #8,221
January 2007
|
Aha, it works now. It appears that I have to load a font to use the text functions. In case anyone else has (or will have) this problem, the working code is:
The program counts and displays the integer on the screen once per iteration, which is an overly simple way I chose to get a ballpark look at the possible framerate. Thanks for all the help, guys! (btw, it ran at around 600 fps, even with a rest(1) at the end. Huzzah for 600 frames in 400ms!!) |
Fladimir da Gorf
Member #1,565
October 2001
|
You could always use OL's FpsCounter OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
Kauhiz
Member #4,798
July 2004
|
Uhm, I'm not sure if I understood what you're trying to do, but if you want the fps, you should look in the OpenLayer manual under FpsCounter. That's a simple way to get the fps and it gives you some other cool stuff as well (namely delta timing). Edit: beaten by Flad. --- |
ImLeftFooted
Member #3,935
October 2003
|
Flad said: // Return is not a function, so no braces there But I think return(1) looks cooler.. I would totally do it if I didn't hate typing extra characters... |
|