Hey guys, recently I've compiled my own lua engine and I have been trying to really figure out how it all works. I'm having some problems with the stack, if any of you guys can help. I'm trying to write a function in C++ that gets all the file names in a directory and pushes a lua table containing the names onto the stack.
C++ code:
[img]http://puu.sh/Q8z0[/img]
and of course, I do lua_register(L, "GetDirectoryListing", FindInDir);.
lua code:
[img]http://puu.sh/Q8Ba[/img]
I had assumed the output would just be table: pointer, however, it prints a few values.
output:
[img]http://puu.sh/Q8C4[/img]
Anyone know what I'm doing wrong?
[editline]9th August 2012[/editline]
I guess that function is returning more values from the stack then I want. Because the function works like a charm if i call lua_pushnil( L ); twice. Does anyone see/know why it's printing 3 values from the stack?
The return value of the C++ function should be the number of values the function pushes on to the stack (the number of values to return). I think you should be returning 1, not index_count.
[QUOTE=MakeR;37153516]The return value of the C++ function should be the number of values the function pushes on to the stack (the number of values to return). I think you should be returning 1, not index_count.[/QUOTE]
Ah, that fixed it. Thanks!
[QUOTE=Meatpuppet;37152990]What did you do? What environment is that?[/QUOTE]
Reposting for new page, I don't know what's happening :(
[QUOTE=Meatpuppet;37148648]What is that?[/QUOTE]
pacman is the package manager of Arch Linux, it handles installing, removing, and updating packages on the system. In this case i'm [b]Q[/b]uerying all my packages to filter out the sfml, soil, and the glew package with grep.
[QUOTE=Meatpuppet;37152990]What did you do? What environment is that?[/QUOTE]
I copied your code, removed #define GLEW_STATIC, then translated your old sfml calls to 2.0 ones, then finally compiled and ran to see it works flawlessly. I did it all in Linux.
[QUOTE=Naelstrom;37153739]pacman is the package manager of Arch Linux, it handles installing, removing, and updating packages on the system. In this case i'm [b]Q[/b]uerying all my packages to filter out the sfml, soil, and the glew package with grep.
I copied your code, removed #define GLEW_STATIC, then translated your old sfml calls to 2.0 ones, then finally compiled and ran to see it works flawlessly. I did it all in Linux.[/QUOTE]
Do you have any idea what I'm doing wrong, then? How could the libs be bad, if I've been using them since the start and they work (heck, I even successfully rendered that rainbow triangle from the tutorial before this one)?
Does anybody know any good articles on making a 3D camera with OpenGL?
All I seem to be able to find are outdated ones that use euler angles or simply doesn't seem to work all too well.
I'm mostly interested in doing it using matrices / vectors and I've already made an attempt using my own knowledge which came out pretty well actually, except that no matter what I do, I can't get it look directly up and down properly. I do use the LookAt method to figure out my matrix though.
Here's my code if anybody has an idea as to what I can do:
[URL]http://pastebin.com/NySidigT[/URL]
Changing the clamp values of origin.y to something such as 8 does allow me to look up and down, but then the problem is that it takes forever to move the camera from 'up' to 'down'. It just feels very weird.
I'm quite aware of how unoptimized all the calls to getEyePos are, but it's simply not relevant yet. :)
Im tring to make a framework around openTK to have a basic structure like XNA works.
Part of it includes a init method in my game class in which I can set things like window size/fullscreen/vsync/fps...
The problem is that the window seems to get created in the constructor:
[csharp]public Game()
: base(800, 600, GraphicsMode.Default, "OpenTK Quick Start Sample")...[/csharp]
Is there anyway to create the window later on? or any solution to my problem?
I'm linking the project with Simple OpenGL Image Library/lib/SOIL.a (under Build Options>Linker Settings)
Under Build Options>Search Directories under Compiler I put Simple OpenGL Image Library/src.
Under Build Options>Search Directories under Linker I put Simple OpenGL Image Library/lib.
I've put #include SOIL.h in my code.
Is there anything else I need to do?
Did you actually link the .lib files? #pragma comment(lib, "libaryname.lib") and stick that in a .h/.cpp file somewhere.
[QUOTE=Lord Ned;37157440]Did you actually link the .lib files? #pragma comment(lib, "libaryname.lib") and stick that in a .h/.cpp file somewhere.[/QUOTE]
What?
You're just adding directories for it to look for libraries, you're not actually telling it to link that library with your code.
But I'm linking the project with Simple OpenGL Image Library/lib/SOIL.a (under Build Options>Linker Settings) wouldn't that mean I linked the lib with my code?
[QUOTE=Meatpuppet;37157571]But I'm linking the project with Simple OpenGL Image Library/lib/SOIL.a (under Build Options>Linker Settings) wouldn't that mean I linked the lib with my code?[/QUOTE]
Yes it does, in VS you can use the method that lord ned says but your using code::blocks right?
[QUOTE=Meatpuppet;37157571]But I'm linking the project with Simple OpenGL Image Library/lib/SOIL.a (under Build Options>Linker Settings) wouldn't that mean I linked the lib with my code?[/QUOTE]
Oops. I'm bad at reading.
Yes, I'm using code blocks. Also, after further inspection, I've found that it only renders a black rectangle (I set the bg color to red). So something is making the texture black. I wonder why this doesn't work, I can't continue in the tutorial if I don't fix this...
Do you actually have a valid png file next to the executable? When I first ran your program it was a black screen, and then I realized I didn't have the image file in it.
[QUOTE=Naelstrom;37157945]Do you actually have a valid png file next to the executable? When I first ran your program it was a black screen, and then I realized I didn't have the image file in it.[/QUOTE]
Yea, it's in OpenGL_Project1/bin/Debug, next to OpenGL_Project1.exe
[editline]9th August 2012[/editline]
[QUOTE=Meatpuppet;37157984]Yea, it's in OpenGL_Project1/bin/Debug, next to OpenGL_Project1.exe[/QUOTE]
If you're running it from within Code::Blocks, you actually need to put it in OpenGL_Project1/bin (CB sets the working directory to the parent folder so that you can use the same files for running Debug or Release)
test it by runing the program directly from bin/Debug
if this works then you need to add the image to the same directory as the project file
When I run it directly from bin/Debug, it comes up with a System Error:
The program can't start because libgcc_s_dw2-1.dll is missing from your computer. Try reinstalling the program to fix this problem.
Oh, you've a GCC with dynamic standard library, brilliant.
What does that mean, and how can I fix it?
[QUOTE=Meatpuppet;37158126]What does that mean, and how can I fix it?[/QUOTE]
Add -static-libgcc to linker options.
[url]http://www.bitstorm.org/gameoflife/[/url]
im trying to do this.
the way im trying to do is using 8192 checks for one generation, checking everything. it goes to one square(doing it for every square ofc) then looks at friends of it.
Doing this, I achieve veeeeery slow results. How can I make it faster ? get a new pc?
I think there is a faster solution that everyone in world is hiding from me ?
Take a look at [url=https://en.wikipedia.org/wiki/Hashlife]hashlife[/url].
[QUOTE=egomanyak;37164736][url]http://www.bitstorm.org/gameoflife/[/url]
im trying to do this.
the way im trying to do is using 8192 checks for one generation, checking everything. it goes to one square(doing it for every square ofc) then looks at friends of it.
Doing this, I achieve veeeeery slow results. How can I make it faster ? get a new pc?
I think there is a faster solution that everyone in world is hiding from me ?[/QUOTE]
Cellular automata are [url=https://en.wikipedia.org/wiki/Embarrassingly_parallel]embarrassingly parallel[/url].
[QUOTE=ThePuska;37165297]Cellular automata are [url=https://en.wikipedia.org/wiki/Embarrassingly_parallel]embarrassingly parallel[/url].[/QUOTE]
Basically you could run a thread for every cell and give it the previous states of the cell in question and its neighbours
Does exist optional parameter in C? I tried to make one, but didn't work for me :(
[QUOTE=Cesar Augusto;37165502]Does exist optional parameter in C? I tried to make one, but didn't work for me :([/QUOTE]
No, C does not support default arguments. There are some work arounds to achieve a similar effect involving variadic arguments and variadic macros. See [url=http://stackoverflow.com/questions/1472138/c-default-arguments]here[/url].
Sorry, you need to Log In to post a reply to this thread.