Ah, that clarifies a lot. Thank you!
[editline]15th January 2012[/editline]
Still having an issue.
The lua_pop nested in the while loop causes lua_next to crash. (Works for the first iteration)
[editline]15th January 2012[/editline]
Apparently after the lua_pop in the while loop causes the table to cease existence. Is it popping the table too?
I also did change the two lua_pops to -1 instead of 1.
-nevermind that-
I discovered that lua_pop goes by the number of indices to pop, not which index to pop.
So, I did change it back to lua_pop(s, 1) but it's still crashing.
[editline]15th January 2012[/editline]
I made a function that prints out the lua stack and I placed it before and after the lua_pop(s,1):
Before:
[code]
*** LUA STACK PRINT [00631A40] ***
[number] 1: 10
[string] 2: 1
[table] 3: 0063BBF0
[function] 4: 013C119F
[function] 5: 00000000
[table] 6: 0063A160
END OF STACK
[/code]
After:
[code]
*** LUA STACK PRINT [00631A40] ***
[string] 1: 1
[table] 2: 0063BBF0
[function] 3: 013C119F
[function] 4: 00000000
[table] 5: 0063A160
END OF STACK
[/code]
And yet it STILL crashes on the second lua_next(s, 1)
Lua error is "invalid key to next"
[QUOTE=ief014;34219681]And yet it STILL crashes on the second lua_next(s, 1)
Lua error is "invalid key to next"[/QUOTE]
Whoops :downs:
[quote]While traversing a table, do not call lua_tolstring directly on a key, unless you know that the key is actually a string. Recall that lua_tolstring changes the value at the given index; this confuses the next call to lua_next.[/quote]
That would be the lua_tostring call in the printing code.
e: You can see it from your stack dump, the key is a string when it should be a number.
[QUOTE=raBBish;34220074]Whoops :downs:
That would be the lua_tostring call in the printing code.
e: You can see it from your stack dump, the key is a string when it should be a number.[/QUOTE]
Huh, that's good to know. I guess I could use the lua_isX functions for that.
Thanks again, it's all working now!
Does anyone know how to implement FMOD in C# (XNA)?
There is surprisingly little information on implementing it in C# and XNA, as opposed to C++!
I've got the dll itself, and some header files and a .lib library file, but I'm not sure what I have use for, and how to import these into my project.
[code]
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Xml;
using System.Net;
using System.IO;
namespace WeatherApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public string retrieveWeather(string zipCode)
{
string weatherInfo;
WebRequest weatherReq = WebRequest.Create("http://www.google.com/ig/api?weather=" + zipCode);
weatherReq.Method = "GET";
using (WebResponse response = weatherReq.GetResponse())
{
using (Stream stream = response.GetResponseStream())
{
StreamReader weatherReader = new StreamReader(stream);
weatherInfo = weatherReader.ReadToEnd();
response.Close();
stream.Close();
weatherReader.Close();
return weatherInfo;
}
}
}
private void getWeather_Click(object sender, EventArgs e)
{
weatherDetails.Text.Equals(retrieveWeather(zipcodeBox.Text));
}
}
}
[/code]
when i click the button, nothing happens
Edit:
Nevermind, I'm retarded
didn't need the .Equals
I'm rendering a couple textured cubes (there are 16384):
[img]http://i.imgur.com/seD69.png[/img]
I'm currently getting around 5 fps and of course I'd like more. I'm using LWJGL, and backface culling is on.
Code for drawing:
[code]
GL11.glBegin(GL11.GL_QUADS);
Vector2f texturePositionSides = textures.get("sides");
GL11.glTexCoord2f(TextureUtils.findOffset(texturePositionSides.x, 0), TextureUtils.findOffset(texturePositionSides.y, 0));
GL11.glVertex3f(position.x + 1, position.y + 1, position.z + 1);
...
GL11.glEnd();
[/code]
textures is a hashtable, called 3 times every block draw for the top, bottom, and 4 sides.
I'm probably doing something horribly wrong or just need to add hidden surface removal, not sure. Could someone point me in the right direction please?
You need to actually profile your code.
Try something like "Very Sleepy" to see what's taking the most time. It may not be what you think.
[QUOTE=_Undefined;34229675]I'm rendering a couple textured cubes (there are 16384):
[img]http://i.imgur.com/seD69.png[/img]
I'm currently getting around 5 fps and of course I'd like more. I'm using LWJGL, and backface culling is on.
Code for drawing:
[code]
GL11.glBegin(GL11.GL_QUADS);
Vector2f texturePositionSides = textures.get("sides");
GL11.glTexCoord2f(TextureUtils.findOffset(texturePositionSides.x, 0), TextureUtils.findOffset(texturePositionSides.y, 0));
GL11.glVertex3f(position.x + 1, position.y + 1, position.z + 1);
...
GL11.glEnd();
[/code]
textures is a hashtable, called 3 times every block draw for the top, bottom, and 4 sides.
I'm probably doing something horribly wrong or just need to add hidden surface removal, not sure. Could someone point me in the right direction please?[/QUOTE]
You're using immediate mode, don't. Try [URL="http://www.opengl.org/wiki/Vertex_Arrays"]Vertex Arrays[/URL] or [URL="http://en.wikipedia.org/wiki/Vertex_Buffer_Object"]Vertex Buffers[/URL]. Only generate vertices that will be seen (that means exposed faces). Using a hashtable is flexible but you could just use a static array (if block types are static). Indices could be worth while too.
Clearly, I don't seem to understand the object-oriented part of this. To try to see what would work, I used P_SHIP as a class and [i]this[/i] as an object. It's ActionScript 3.
[code]package {
import net.flashpunk.Entity;
import net.flashpunk.graphics.Image;
import net.flashpunk.utils.Input;
import net.flashpunk.utils.Key;
public class e_Ship extends Entity {
[Embed(source = '../gfx/p_ship.png')] private const P_SHIP:Class;
public function e_Ship() {
graphic = new Image(P_SHIP); }
override public function update():void {
if (Input.pressed(Key.LEFT)) { P_SHIP.x - 2; trace("Left!"); }
if (Input.pressed(Key.RIGHT)) { this.x + 2; trace("Right!"); }
if (Input.pressed(Key.UP)) { this.y + 2; trace ("Forward!"); }
if (Input.pressed(Key.DOWN)) { this.y - 2; trace ("Hold course!"); } } } }
[/code]
So I am having troubles with my camera and my player I have a 2D array full with tile map and the camera allows scrolling through all of it but when the camera hits the edge to let the player continue moving around relative to the camera. I am not exactly sure how to describe it but like a 2D top down view game.
Any help would be appreciated.
Make the camera follow the player.
Then check if the camera is past an edge. If so, align it as close as you can.
Should let the player walk around freely (he should do his own checks against the edge of the world), and keep your camera from extending past.
I'm looking for a .NET library that lets me write (and read, if there's one that does both) videos by pushing frames and audio data.
Holly would be perfect, but I'm not good enough at wrapping with P/Invoke / C++/CLI to use it.
garry wrote one, but it's in C++ so expect to do some pretty heavy binding
[QUOTE=swift and shift;34238494]garry wrote one, but it's in C++ so expect to do some pretty heavy binding[/QUOTE]
[QUOTE=Tamschi;34238386]Holly would be perfect, but I'm not good enough at wrapping with P/Invoke / C++/CLI to use it.[/QUOTE]
oops, how did i miss that
After compiling SFML2 for VS2010 C++ I'm getting a strange error when building, that I can't fix.
One of the headers in SFML (err.hpp) complains that it can't find ostream.
Output
[code]
1>ClCompile:
1> Application.cpp
1>C:\lib\sfml2.0\include\SFML/System/Err.hpp(32): fatal error C1083: Cannot open include file: 'ostream': No such file or directory
1>
1>Build FAILED.
[/code]
[B]Application.cpp[/B]
[cpp]
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "SFML Sample Application");
while (Window.IsOpened())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
default:
break;
}
}
Window.Clear(sf::Color(0, 255, 255));
Window.Display();
}
return 0;
}
[/cpp]
I have code resembling the following.
[cpp]
class Example
{
// ctor, dtor, etc-tor
template<typename R, typename T>
R operator()(T a, T b) { /* code */ }
};
[/cpp]
How do I actually go about calling the functor with a specific type? In this example, the return type. Simply doing
[cpp]
Example instance(ctor, args);
instance<int, bool>(true, false);
[/cpp]
won't work. (I'm also guessing that this IS valid code, the compiler hasn't complained about it but I suppose it could be in undefined behaviour territory)
[QUOTE=Armandur;34238963]After compiling SFML2 for VS2010 C++ I'm getting a strange error when building, that I can't fix.
One of the headers in SFML (err.hpp) complains that it can't find ostream.
Output
[code]
1>ClCompile:
1> Application.cpp
1>C:\lib\sfml2.0\include\SFML/System/Err.hpp(32): fatal error C1083: Cannot open include file: 'ostream': No such file or directory
1>
1>Build FAILED.
[/code]
[B]Application.cpp[/B]
[cpp]
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow Window(sf::VideoMode(800, 600, 32), "SFML Sample Application");
while (Window.IsOpened())
{
sf::Event Event;
while (Window.PollEvent(Event))
{
switch (Event.Type)
{
case sf::Event::Closed:
Window.Close();
break;
default:
break;
}
}
Window.Clear(sf::Color(0, 255, 255));
Window.Display();
}
return 0;
}
[/cpp][/QUOTE]
You should post this on the sfml-dev.org forum, I believe laurent can help you out since it's a developer build and he's the one developing it.
I'm trying to create a handheld effect for a camera by interpolating the camera back and forth to random points within a range, however it just looks dumb and nothing at all like I want it to.
I know it's vague and barely a question but yeah, anyone have any input/ideas on how they would (by offsetting the position) achieve a sorta shaky handheld effect?
[QUOTE=Jimbomcb;34246286]I'm trying to create a handheld effect for a camera by interpolating the camera back and forth to random points within a range, however it just looks dumb and nothing at all like I want it to.
I know it's vague and barely a question but yeah, anyone have any input/ideas on how they would (by offsetting the position) achieve a sorta shaky handheld effect?[/QUOTE]
Try something like:
[code]
yaw_offset = scale * (cos(a*t) + cos(b*t) + cos(c*t));
pitch_offset = scale * (cos(d*t) + cos(e*t) + cos(f*t));
[/code]
Where a, b, c, d, e, and f are a bunch of [i]coprime[/i] coefficients for angular frequency.
Guys
Is [url=http://www.flipcode.com/archives/Frustum_Culling.shtml]this[/url] still a valid description of frustum culling or is there some ~~NEW TECHNOLOGY~~ that simplifies it or makes the process more efficient?
[QUOTE=esalaka;34248062]Guys
Is [url=http://www.flipcode.com/archives/Frustum_Culling.shtml]this[/url] still a valid description of frustum culling or is there some ~~NEW TECHNOLOGY~~ that simplifies it or makes the process more efficient?[/QUOTE]
Frustum culling is basic geometry. The basic process doesn't change.
Obviously, some scene structures are better suited than others (i.e. hierarchical structures are better than flat structures), but anything you read in an old article probably still works today.
Speaking of which, I've been thinking about breaking the frustum/occlusion culling (well, it's just frustum culling now, but I've got occlusion culling planned out on paper) code from my engine and making it into a dedicated library. It's the sort of thing every game developer really needs, but AFAIK, there isn't really a good library for it right now, short of proprietary middleware.
[QUOTE=ROBO_DONUT;34248033]Try something like:
[code]
yaw_offset = scale * (cos(a*t) + cos(b*t) + cos(c*t));
pitch_offset = scale * (cos(d*t) + cos(e*t) + cos(f*t));
[/code]
Where a, b, c, d, e, and f are a bunch of [i]coprime[/i] coefficients for angular frequency.[/QUOTE]
looks awesome, thanks. just out of interest, why do the coefficients need to be coprime
This error is pissing me right the fuck off.
[code]
main.cpp:307: error: no matching function for call to ‘layer::debug::Library::findFunction(const char [19])’
[/code]
main.cpp
[cpp]
layer::debug::Library sqlite("/usr/lib/libsqlite3.so");
const char* (*whatwhat)() = sqlite.findFunction<const char*, void>("sqlite3_libversion"); // line 307
const char* ver3 = whatwhat();
::layer::info("blah says \"%s\"\n", ver3); // printf-equiv
[/cpp]
Library is defined as
[cpp]
class Library
{
public:
Library(const GString& path); // GString is typedef'd std::string
~Library();
void* findFunction(const GString& functionName) const;
template<typename R, typename... T>
R (*findFunction(const GString& funcName))(T... Ts) const
{
return (R (*)(...))findFunction(funcName);
}
private:
void* _libraryHandle;
};
[/cpp]
Compiling with -std=c++0x -pedantic -Wall
[editline]17th January 2012[/editline]
if I use the non-templated function and some bullshit casting, it works fine.
[cpp]
void* simple = sqlite.findFunction("sqlite3_libversion");
const char* (*simpleimpl)(void) = (const char* (*)(void))(simple);
::layer::info("blah says \"%s\"\n", simpleimpl());
[/cpp]
Using QT4 in Ruby, how can I set a variable equal to what was entered into lineEdit? I've spent the past hour googling this, and I haven't had any luck. The results I got showed bits of code that were of no relevance to what I'm looking for.
[QUOTE=Jimbomcb;34253974]looks awesome, thanks. just out of interest, why do the coefficients need to be coprime[/QUOTE]
You get a longer period before the pattern repeats. It won't appear to be random movement if they have a small common factor.
creating an xml file with .net in c#, it works, but the generated file only uses 1 line like this:
[code]
<?xml version="1.0"?><Client><server>192.168.12.1</server></Client>
[/code]
But i want it to look much more organized, like this:
[code]
<?xml version="1.0"?>
<Client>
<server>192.168.12.1</server>
</Client>
[/code]
This is the code I currently have:
[code]
XmlTextWriter textWriter = new XmlTextWriter("preferences.xml", null);
textWriter.WriteStartDocument();
//Start write
textWriter.WriteStartElement("Client");
textWriter.WriteStartElement("server");
textWriter.WriteString("192.168.12.1");
textWriter.WriteEndElement();
textWriter.WriteEndElement();
//End Write
textWriter.WriteEndDocument();
textWriter.Close();
[/code]
Hmm, you could try:
[code]
textWriter.Settings.NewLineOnAttributes = true;
[/code]
On ubuntu 11.10 (64 bit), my cmake can't seem to find the xrandr library:
[img]http://i.imgur.com/Aneq7.png[/img]
even though I can use it in the terminal:
[img]http://i.imgur.com/15SVv.png[/img]
(using cmake 2.8.5).
[editline]17th January 2012[/editline]
Fixed, had to install the dev versions of everything (e.g. libsndfile-dev)
Sorry, you need to Log In to post a reply to this thread.