[QUOTE=bootv2;26846187]gaat ook kleiner worden.[/QUOTE]
Dan wordt het slechter leesbaarder denk ik, met die weinige ruimte in de a's en e's enz.
Can anyone explain how this causes text to be rendered way off from where it should be? I'm starting to believe Visual Studio is bugging out on me (multiple unexplained errors across various projects).
[cpp]
void SFMLRenderer::DrawText(std::string& text, Point& position) {
Gum::Base::Size size = MeasureText(text);
sf::Text sfText = sf::Text(text, sf::Font::GetDefaultFont(), 10);
sfText.SetColor(m_Color);
sfText.SetPosition(sf::Vector2f(position.x, position.y));
m_pTarget->Draw(sfText);
}
[/cpp]
Talking about font readability in dutch...
I must be in the wrong thread
[QUOTE=DevBug;26847991]Can anyone explain how this causes text to be rendered way off from where it should be? I'm starting to believe Visual Studio is bugging out on me (multiple unexplained errors across various projects).
[cpp]
void SFMLRenderer::DrawText(std::string& text, Point& position) {
Gum::Base::Size size = MeasureText(text);
sf::Text sfText = sf::Text(text, sf::Font::GetDefaultFont(), 10);
sfText.SetColor(m_Color);
sfText.SetPosition(sf::Vector2f(position.x, position.y));
m_pTarget->Draw(sfText);
}
[/cpp][/QUOTE]
Are you fucking with the opengl matrix at all? Try calling glLoadIdentity() before drawing the text (although SFML might do that internally idk).
- Fixed -
[editline]21st December 2010[/editline]
Does C# have template functions?
I have a function which i want it to be used by various different objects however i dont want to have one same function with each object in the argument for all diferent objects.
[QUOTE=Richy19;26850181]- Fixed -
[editline]21st December 2010[/editline]
Does C# have template functions?
I have a function which i want it to be used by various different objects however i dont want to have one same function with each object in the argument for all diferent objects.[/QUOTE]
Templates are called Generics in C#
[url]http://msdn.microsoft.com/en-us/library/twcad0zb(v=vs.80).aspx[/url]
I have done this
[code]public Boolean intersectPixels<T>(ref T myReference)
{
Rectangle rectB = new Rectangle(0, 0, GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
Rectangle rectA = myReference.rect;
int rectTop = Math.Max(rectA.Top, rectB.Top);
int rectBottom = Math.Min(rectA.Bottom, rectB.Bottom);
int rectLeft = Math.Max(rectA.Left, rectB.Left);
int rectRight = Math.Min(rectA.Right, rectB.Right);
for (int y = rectTop; y < rectBottom; y++)
{
for (int x = rectLeft; x < rectRight; x++)
{
Color colorA = myReference.collisionDetectionData[(x - rectA.Left) + (y - rectA.Top) * (rectA.Width)];
Color colorB = solidsData[(x - rectB.Left) + (y - rectB.Top) * (rectB.Width)];
if (colorA.A != 0 && colorB.A != 0)
{ return true; }
}
}
return false;
}[/code]
but i get these errors
[quote]Error 2 'T' does not contain a definition for 'collisionDetectionData' and no extension method 'collisionDetectionData' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)
[/quote]
[quote]
Error 1 'T' does not contain a definition for 'rect' and no extension method 'rect' accepting a first argument of type 'T' could be found (are you missing a using directive or an assembly reference?)
[/quote]
Also how do i access a method in my main class from a different class?
[QUOTE=Richy19;26851583]Also how do i access a method in my main class from a different class?[/QUOTE]
You can't know that T is a type with rect and collisionDetectionData fields. If they're defined in an interface or a parent class, you can do this:
[csharp]public Boolean intersectPixels<T>(ref T myReference) where T : SomeClass[/csharp]
If they're defined in only one class, I don't see any reason to use generics there.
[editline]21st December 2010[/editline]
Also, why are you using ref?
[QUOTE=raBBish;26851895]You can't know that T is a type with rect and collisionDetectionData fields. If they're defined in an interface or a parent class, you can do this:
[csharp]public Boolean intersectPixels<T>(ref T myReference) where T : SomeClass[/csharp]
If they're defined in only one class, I don't see any reason to use generics there.
[editline]21st December 2010[/editline]
Also, why are you using ref?[/QUOTE]
ATM theres 2 clases, but once i have enemies and ammo there will be 4.
Im using Ref as thats what it said in the example
Surely they will inherit from a common interface?
[QUOTE=robmaister12;26846138]hmm, well that's certainly an issue. try running [url]http://www.guru3d.com/category/driversweeper/[/url], then reinstall your graphics drivers, maybe that'll fix it...[/QUOTE]
For once it wasn't me who broke my code!
I have a class that stores a pointer to another class, but that instance might get deleted at any time from somewhere else. How can I detect that it get's deleted and NULL the dangling pointer?
[QUOTE=Z_guy;26854702]I have a class that stores a pointer to another class, but that instance might get deleted at any time from somewhere else. How can I detect that it get's deleted and NULL the dangling pointer?[/QUOTE]
You can't with regular pointers, but you could use boost's smart_ptr paired with a weak_ptr.
[QUOTE=DevBug;26847991]Can anyone explain how this causes text to be rendered way off from where it should be? I'm starting to believe Visual Studio is bugging out on me (multiple unexplained errors across various projects).
[cpp]
void SFMLRenderer::DrawText(std::string& text, Point& position) {
Gum::Base::Size size = MeasureText(text);
sf::Text sfText = sf::Text(text, sf::Font::GetDefaultFont(), 10);
sfText.SetColor(m_Color);
sfText.SetPosition(sf::Vector2f(position.x, position.y));
m_pTarget->Draw(sfText);
}
[/cpp][/QUOTE]
Turns out a rouge patch stopped my computer from restarting. I think that was the cause of the problem (don't worry I've re-installed 7). :sigh:
[QUOTE=noctune9;26859096]You can't with regular pointers, but you could use boost's smart_ptr paired with a weak_ptr.[/QUOTE]
I've tried that solution and it worked really well, but I don't like it. Since I'm writing a library and that solution would force the user of the library to store the affected objects in shared_ptrs. But I guess I just have to live with that, thanks.
How would be the best way to allow public access to a sockets based program I am developing?
It works using TCP
[QUOTE=Vbits;26865077]How would be the best way to allow public access to a sockets based program I am developing?
It works using TCP[/QUOTE]
Not really sure what you mean, but open the ports in your router?
[QUOTE=Z_guy;26865490]Not really sure what you mean, but open the ports in your router?[/QUOTE]
That is not the best option since this is only going to be up for a small while.
[QUOTE=Vbits;26865780]That is not the best option since this is only going to be up for a small while.[/QUOTE]
I guess you could try to implement UPnP or NAT-PMP.
[QUOTE=Overv;26868054]easy to read
...
[code]// Headers
#include <windows.h>[/code][/QUOTE]
Most people here work on Windows and it's just an example, so it isn't a problem.
[QUOTE=Overv;26868553]Most people here work on Windows and it's just an example, so it isn't a problem.[/QUOTE]
I was implying that easy to read and the WinAPI are polar opposites.
Oh right :saddowns:
[QUOTE=Z_guy;26867035]I guess you could try to implement UPnP or NAT-PMP.[/QUOTE]
I just added that double checked, it is working fine, 2 lines of code and a reference that is part of C#.
Anything that I should do before making it public.
[QUOTE=Vbits;26865780]That is not the best option since this is only going to be up for a small while.[/QUOTE]
It's not an option: if you're using a NAT router you can't accept incoming connections (on a machine behind the router) without using port forwarding.
UPnP lets an application request port forwarding on a temporary, transient basis, but if you want something simple that works without having to implement UPnP, just set it up manually on the router. There's no harm having it there when your program isn't running.
I have already implemented it. 3 lines of code that worked first time is not what I call hard, though is there anything that could be a security concern in a really simple webserver + a little hosting trick.
Is it possible to have an stl vector or list of pointers?
yes.
Sorry, you need to Log In to post a reply to this thread.