[QUOTE=Cold;43426414]The UV doesn't need to be different, based on what triangle its part off.[/QUOTE]
Well in the image the middle vertice is part of the 4 triangles, but it has different values depending on what corner it is. So if it always had a UV of 0,0 then it would always be top left of the image, but it might not be top left of the quad/triangle
[QUOTE=Richy19;43426446]Well in the image the middle vertice is part of the 4 triangles, but it has different values depending on what corner it is. So if it always had a UV of 0,0 then it would always be top left of the image, but it might not be top left of the quad/triangle[/QUOTE]
Duplicate the vertex.
How can I get a list of all the JSON stuff.
Right now I have it just saving to a string. I have this code:
[CODE] async public void DoStuff(string url)
{
var request = WebRequest.Create(url);
string text;
request.ContentType = "application/json; charset=utf-8";
var response = (HttpWebResponse)await request.GetResponseAsync();
using (var sr = new StreamReader(response.GetResponseStream()))
{
text = sr.ReadToEnd();
}
}[/CODE]
I used [url]http://json2csharp.com[/url] and entered in this site [url]http://www.reddit.com/r/all.json[/url]
Do I have to use that class in some way?
Anyone know what's going on here:
[code]
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DllNotFoundException: Unable to load DLL 'csfml-graphics-2': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at SFML.Graphics.Font.sfFont_createFromStream(IntPtr stream)
at SFML.Graphics.Font..ctor(Stream stream)
[/code]
csfml-graphics-2.dll is in the same folder (using SFML.NET 2.1) and it works fine for a whole bunch of people, except these two
If anyone else wants to give it a try: [url]http://files.kuubstudios.com/TestGame.exe[/url]
(It's packed with garry's bundler, you can just extract it with 7zip if you want)
[QUOTE=Cold;43426490]Duplicate the vertex.[/QUOTE]
This. Two vertices with the same position aren't the same vertex if any of their other properties (e.g. texture coordinates) are different.
[QUOTE=Goz3rr;43426886]Anyone know what's going on here:
[code]
Unhandled Exception: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.DllNotFoundException: Unable to load DLL 'csfml-graphics-2': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at SFML.Graphics.Font.sfFont_createFromStream(IntPtr stream)
at SFML.Graphics.Font..ctor(Stream stream)
[/code]
csfml-graphics-2.dll is in the same folder (using SFML.NET 2.1) and it works fine for a whole bunch of people, except these two
If anyone else wants to give it a try: [url]http://files.kuubstudios.com/TestGame.exe[/url]
(It's packed with garry's bundler, you can just extract it with 7zip if you want)[/QUOTE]
The error is telling you what is going on..
[code]Unable to load DLL 'csfml-graphics-2': The specified module could not be found.[/code]
It's trying to load the DLL file csfml-graphics-2, but it doesn't find it.
[QUOTE=P1raten;43428163]
It's trying to load the DLL file csfml-graphics-2, but it doesn't find it.[/QUOTE]
[QUOTE=Goz3rr;43426886]
csfml-graphics-2.dll is in the same folder (using SFML.NET 2.1) and it works fine for a whole bunch of people, except these two
[/QUOTE]
Could somebody look at my question here please:
[url]http://stackoverflow.com/questions/20941761/c-sharp-how-to-know-which-element-is-root-object-for-deserialization/20941781?noredirect=1#20941781[/url]
So, I'm using stringification to add animations on the fly with appropriate names.
[code]#define str(s) #s
using namespace sf;
struct Animation
{
thor::Animator<Sprite, std::string> animator;
std::string temp;
thor::FrameAnimation stand;
thor::FrameAnimation walk;
Animation()
{
addFrameAnimation(stand, 6, 39, 74, 19, 80, 5);
addFrameAnimation(walk, 6, 39, 74, 339, 80, 5);
}
void addFrameAnimation(thor::FrameAnimation& frameAnimation, ...)
{
{..}
animator.addAnimation(str(frameAnimation), frameAnimation, seconds(1.f));
}[/code]
The problem is that I get an assertion fail corresponding to this line in a .inl file.
[code]template <class Animated, typename Id>
void Animator<Animated, Id>::addAnimation(const Id& id, const AnimationFunction& animation, sf::Time duration)
{
assert(mAnimationMap.find(id) == mAnimationMap.end());
mAnimationMap.insert( std::make_pair(id, ScaledAnimation(animation, duration)) );
}[/code]
Haven't been read up on templates as much as I wanted and I'm not overly familiar with list either.
[QUOTE=P1raten;43437335]So, I'm using stringification to add animations on the fly with appropriate names.
[code]#define str(s) #s
using namespace sf;
struct Animation
{
thor::Animator<Sprite, std::string> animator;
std::string temp;
thor::FrameAnimation stand;
thor::FrameAnimation walk;
Animation()
{
addFrameAnimation(stand, 6, 39, 74, 19, 80, 5);
addFrameAnimation(walk, 6, 39, 74, 339, 80, 5);
}
void addFrameAnimation(thor::FrameAnimation& frameAnimation, ...)
{
{..}
animator.addAnimation(str(frameAnimation), frameAnimation, seconds(1.f));
}[/code]
The problem is that I get an assertion fail corresponding to this line in a .inl file.
[code]template <class Animated, typename Id>
void Animator<Animated, Id>::addAnimation(const Id& id, const AnimationFunction& animation, sf::Time duration)
{
assert(mAnimationMap.find(id) == mAnimationMap.end());
mAnimationMap.insert( std::make_pair(id, ScaledAnimation(animation, duration)) );
}[/code]
Haven't been read up on templates as much as I wanted and I'm not overly familiar with list either.[/QUOTE]
Both calls to Animation::addFrameAnimation() are trying to add an animation with ID "frameAnimation". The assert fails because each ID may only exist once in the map.[cpp]str(frameAnimation)[/cpp] evaluates to "frameAnimation" each time and not to "stand" and "walk" as you might have expected.
[QUOTE=Dienes;43437368]Both calls to Animation::addFrameAnimation() are trying to add an animation with ID "frameAnimation". The assert fails because each ID may only exist once in the map.[cpp]str(frameAnimation)[/cpp] evaluates to "frameAnimation" each time and not to "stand" and "walk" as you might have expected.[/QUOTE]
So any ideas on how to get the desired result I want?
[QUOTE=P1raten;43437607]So any ideas on how to get the desired result I want?[/QUOTE]
Well, the obvious answer is to not stringify at all and just pass the ID separately.
If you absolutely want to turn the member name into a string ID, you would need a variadic macro function that expands to the actual method call. IMO not worth it.
[code]
availableIcons = {ui_Start,ui_Stop,ui_Restart,ui_Inc,ui_Dec,ui_Pause}
function inTable(element)
for _, value in pairs(availableIcons) do
if value == element then
return true
end
end
return false
end
function love.draw()
love.graphics.print(tostring(inTable(ui_Start)),16,16)
love.graphics.print(tostring(inTable(ui_Restart)),16,40)
love.graphics.print(tostring(inTable(ui_TotesWrong)),16,64)
end
[/code]
I can't for the life of me figure out what's wrong. InTable checks wether the item stated is in the table AvailableIcons, but when I test two correct items and one false one in love.draw, it prints "false" 3 times rather than only once.
Help?
[QUOTE=mobrockers;43415998]This might help you:
[url]http://stackoverflow.com/questions/6417018/retrieving-jtable-line-content-after-user-sorted-content-by-clicking-on-column[/url]
Looks like the sorting is only done in the View and not in the underlying Tablemodel, and the usual approach to getting a row only works because they're the same when unsorted.[/QUOTE]
To build on this answer:
The selected row [b]does[/b] update, you're just not converting the selected row index to what the [i]model[/i] of the table can see.
You need to call [url=http://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html#convertRowIndexToModel%28int%29]convertRowIndexToModel,[/url] and pass the value from [url=http://docs.oracle.com/javase/7/docs/api/javax/swing/JTable.html#getSelectedRow%28%29]getSelectedRow[/url] method. It will take into account things such as the columns being sorted, and give you the actual selected row.
[editline]6th January 2014[/editline]
Wait, this was answered in the StackOverflow question. My bad :v:
[QUOTE=bootv2;43449440]why does window.display(); use up to 50ms in sfml2? its a huge bottleneck in my game's performance.
I'm fairly sure the issue isnt my pc because it has 12GB of ram, an intel i5-750@2.40ghz and a amd HD 5770.[/QUOTE]
That sounds very strange. Are you sure it's the call to ::display() that takes so long? Does it also happen when you draw an empty screen in release mode? Are you limiting your FPS? Some driver issue maybe?
[QUOTE=bootv2;43449440]why does window.display(); use up to 50ms in sfml2? its a huge bottleneck in my game's performance.
I'm fairly sure the issue isnt my pc because it has 12GB of ram, an intel i5-750@2.40ghz and a amd HD 5770.[/QUOTE]
Doesn't even come near to 50ms for me.
[QUOTE=bootv2;43449562]doesnt for me either most of the time, but every few seconds it spikes to 50ms for a second.
Im trying to profile it on a few computers my friends own now
[editline]7th January 2014[/editline]
Yes, I'm sure its that specific call. And I tried it with and without fps limits.[/QUOTE]
Could it be the compiler? What are you using?
[QUOTE=bootv2;43449585]Apparently it only happens on my own pc, so I'm just going to shove it off as a driver issue and ignore it.[/QUOTE]
Strange, try running it in a VM if you have one installed. If 1 person has the issue the other might as well.
[QUOTE=Instant Mix;43438549][code]
availableIcons = {ui_Start,ui_Stop,ui_Restart,ui_Inc,ui_Dec,ui_Pause}
function inTable(element)
for _, value in pairs(availableIcons) do
if value == element then
return true
end
end
return false
end
function love.draw()
love.graphics.print(tostring(inTable(ui_Start)),16,16)
love.graphics.print(tostring(inTable(ui_Restart)),16,40)
love.graphics.print(tostring(inTable(ui_TotesWrong)),16,64)
end
[/code]
I can't for the life of me figure out what's wrong. InTable checks wether the item stated is in the table AvailableIcons, but when I test two correct items and one false one in love.draw, it prints "false" 3 times rather than only once.
Help?[/QUOTE]
Did you define the ui_* to something? Otherwise they will be nil, resulting in availableIcons to be an empty table.
This works fine:
[lua]ui_Start, ui_Stop, ui_Restart, ui_Inc, ui_Dec, ui_Pause, ui_TotesWrong = 1, 2, 3, 4, 5, 6, 7
availableIcons = {ui_Start,ui_Stop,ui_Restart,ui_Inc,ui_Dec,ui_Pause}
function inTable(element)
for _, value in pairs(availableIcons) do
if value == element then
return true
end
end
return false
end
print(tostring(inTable(ui_Start)))
print(tostring(inTable(ui_Restart)))
print(tostring(inTable(ui_TotesWrong)))[/lua]
I want to use SFML.NET in a c# windows form application, so I can have windows GUI controlling something drawn with sfml but I have no idea how to set it up. Can anyone give me a hand? :smile:
I've tried opening a new windows form application, then adding references to the sfml dlls and adding the csfml dlls as existing items, but I'm still getting:
Could not load file or assembly 'sfmlnet-graphics-2
EDIT: Using 32bit binaries seemed to fix it :smile: But I have a little problem now. Currently it draws the SFML window the entire size of the form, and any GUI elements floats on top of it. I'd rather the SFML window is a small box within the form, with the GUI stuff off to the side. The code is currently:
[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 SFML.Graphics;
using SFML.Window;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
this.Load += new System.EventHandler(this.Form1_Load);
this.FormClosed += new FormClosedEventHandler(this.Form1_Closed);
this.ResizeEnd += new EventHandler(this.Form1_ResizeEnd);
}
private RenderWindow SFMLWindow =null;
private bool FormOpen = true;
private void Form1_Load(object sender, EventArgs e)
{
SFMLWindow = new RenderWindow(this.Handle); // Create the SFMLWindow from the handle of any control. In this example we will use our current forms handle
RenderLoop();
}
private void RenderLoop()
{
while (FormOpen)
{
Application.DoEvents(); // Required for the form controls to respond
SFMLWindow.Clear(SFML.Graphics.Color.Black);
//Do your drawing code here
SFMLWindow.Display();
}
}
private void Form1_Closed(object sender, EventArgs e)
{
FormOpen = false; // Close our render loop when the form closes
}
private void Form1_ResizeEnd(object sender, EventArgs e)
{
SFMLWindow.SetView(new SFML.Graphics.View(new FloatRect(0, 0, this.ClientSize.Width, this.ClientSize.Height))); // Resize our SFML View to prevent stretching
}
}
}[/code]
I tried changing the randerwindow handle to a picturebox handle but then when I run it no form or anything comes up at all.
I'm trying to find the proper license to license my program with. Can anyone link to me the website with all the possible ways to license your code but it's been simplified with spaces where it tells you the basics of it? I want to choose a license and read up on it more in depthly.
[QUOTE=RoflKawpter;43465428]I'm trying to find the proper license to license my program with. Can anyone link to me the website with all the possible ways to license your code but it's been simplified with spaces where it tells you the basics of it? I want to choose a license and read up on it more in depthly.[/QUOTE]
[url]http://www.tldrlegal.com/[/url]
[QUOTE=chaz13;43464715]I want to use SFML.NET in a c# windows form application, so I can have windows GUI controlling something drawn with sfml but I have no idea how to set it up. Can anyone give me a hand? :smile:
I've tried opening a new windows form application, then adding references to the sfml dlls and adding the csfml dlls as existing items, but I'm still getting:
Could not load file or assembly 'sfmlnet-graphics-2
EDIT: Using 32bit binaries seemed to fix it :smile: But I have a little problem now. Currently it draws the SFML window the entire size of the form, and any GUI elements floats on top of it. I'd rather the SFML window is a small box within the form, with the GUI stuff off to the side. The code is currently:
[code]//snip[/code]
I tried changing the randerwindow handle to a picturebox handle but then when I run it no form or anything comes up at all.[/QUOTE]
For the non-C# libraries (the csfml stuff) you need to place them in the CWD, which I guess when you start the application from the IDE is either the directory where the project-file is located or the directory where the resulting executable lands.
How would one use SFML to generate a grid, i.e. a subdivided plane?
I skimmed through [URL="http://elearning.vtu.ac.in/10/enotes/06CS65/PNU/Drawingplain-PNU.pdf"]this explanation[/URL] and it seems like they draw each triangle separately (I could do that with sf::VertexArray), but this would mean that i have multiple vertices at the exact same location, right? I was assuming that each vertex could belong to several triangles.
What is the general approach to define such a grid in "one piece"?
Also, is it correct that when I apply a vertex shader to this grid, that I can manipulate each vertex' color attribute before drawing?
I have no real experience in OpenGL itself, so any guidance on this rather basic stuff is welcome.
[QUOTE=Dienes;43465917]How would one use SFML to generate a grid, i.e. a subdivided plane?
I skimmed through [URL="http://elearning.vtu.ac.in/10/enotes/06CS65/PNU/Drawingplain-PNU.pdf"]this explanation[/URL] and it seems like they draw each triangle separately (I could do that with sf::VertexArray), but this would mean that i have multiple vertices at the exact same location, right? I was assuming that each vertex could belong to several triangles.
What is the general approach to define such a grid in "one piece"?
Also, is it correct that when I apply a vertex shader to this grid, that I can manipulate each vertex' color attribute before drawing?
I have no real experience in OpenGL itself, so any guidance on this rather basic stuff is welcome.[/QUOTE]
Generally the reason why they duplicate the vertices is because every plane, that's connected to the vert has its own normal/UV-Coordinate related to the vert.
And using different Color/Normal/UV-Coordinate depending on what plane is using the vert is not something that's easy-to-do/possible in OpenGL.
[QUOTE=Cold;43468135]Generally the reason why they duplicate the vertices is because every plane, that's connected to the vert has its own normal/UV-Coordinate related to the vert.
And using different Color/Normal/UV-Coordinate depending on what plane is using the vert is not something that's easy-to-do/possible in OpenGL.[/QUOTE]
This makes sense. In my case though the whole grid should act as one huge quad, so said attributes will not change from one triangle to the other. I don't want to deform the grid as they do in the linked PDF, I only need the subdivision to generate specific color gradients on the plane.
Is it possible to reuse vertices in a sf::VertexArray for other triangles, or is that only possible with native OpenGL?
[QUOTE=Dienes;43471908]This makes sense. In my case though the whole grid should act as one huge quad, so said attributes will not change from one triangle to the other. I don't want to deform the grid as they do in the linked PDF, I only need the subdivision to generate specific color gradients on the plane.
Is it possible to reuse vertices in a sf::VertexArray for other triangles, or is that only possible with native OpenGL?[/QUOTE]
You can use a TrianglesStrip, and you'll be able to reuse some vertices.
But ideally you would do some kind of Element based rendering(glDrawElements in OpenGL) I don't think SFML has something like that.