Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - carsaxy

Pages: [1]
1
Graphics / problem with sf::RenderTexture::Draw in derived class
« on: December 23, 2011, 03:12:41 pm »
Thank you very much!
I changed the inheritance from "public" to "private" and have premium methods that I was interested in using the directive "using" and everything seems to work  :D

2
Graphics / problem with sf::RenderTexture::Draw in derived class
« on: December 23, 2011, 01:30:16 pm »
Hmm... I am thinking that there arent many methods that I have to import from sf::RenderTexture, so I could put an object RenderTexture as a member and rewrite these methods...

3
Graphics / problem with sf::RenderTexture::Draw in derived class
« on: December 23, 2011, 01:14:34 pm »
Quote
the address of an object: it must remain alive as long as you use the stored pointer

ah, ok: it was precisely the problem of the program i made using this class.

Quote
you can make things more explicit by taking a pointer argument in Add

I like that idea, but there is a way to tell if the object pointed to still exist?

How can I import only some methods with private inheritance?

4
Graphics / problem with sf::RenderTexture::Draw in derived class
« on: December 23, 2011, 11:46:16 am »
I did some debugging prints and i found that the program crashes when I call the sf::RenderTexture::Draw in the Update method

5
Graphics / problem with sf::RenderTexture::Draw in derived class
« on: December 23, 2011, 11:43:54 am »
what I want is to create drawable objects that "contain" some other drawable so that when something is changed betwen them, automatically redraw all the "contained" object on it's textures. I had various test, but this idea seemed the best because it allowed me to import methods from both classes.

here is the complete code:
Code: [Select]
#include <SFML/Graphics/RenderTexture.hpp>
#include <SFML/Graphics/Sprite.hpp>
#include <vector>

#ifndef _OG_COMPDRW_HPP_
#define _OG_COMPDRW_HPP_

#ifndef _DESKTOP_SIZE_
#include <SFML/Window/VideoMode.hpp>
#define _DESKTOP_WIDTH_ sf::VideoMode::GetDesktopMode().Width
#define _DESKTOP_HEIGHT_ sf::VideoMode::GetDesktopMode().Height
#define _DESKTOP_SIZE_ sf::Vector2f(_DESKTOP_WIDTH_,_DESKTOP_HEIGHT_)
#endif

namespace og
{

class CompDrw : public sf::RenderTexture , public sf::Sprite
{
public :

CompDrw(){
sf::RenderTexture();
sf::Texture tmpTexture = sf::RenderTexture::GetTexture();
sf::Sprite::SetTexture(tmpTexture);
CompDrw::Show();
CompDrw::Updated = true;
CompDrw::Lightable = false;
}

CompDrw(bool isLghtble){
sf::RenderTexture();
sf::Texture tmpTexture = sf::RenderTexture::GetTexture();
sf::Sprite::SetTexture(tmpTexture);
CompDrw::Show();
CompDrw::Updated = true;
CompDrw::Lightable = isLghtble;
}

void Create(unsigned int width = _DESKTOP_WIDTH_, unsigned int height = _DESKTOP_HEIGHT_, bool depthBuffer = false) {
sf::RenderTexture::Create(width, height, depthBuffer);
CompDrw::Updated = false;
}

const bool IsLightable(){
return CompDrw::Lightable;
}

const bool IsOpen(){
return CompDrw::Shown;
}

void Show(bool showthis = true){
CompDrw::Shown = showthis;
}

void Hide(bool hidethis = true){
CompDrw::Show(!hidethis);
}

void Add(const sf::Drawable&){
CompDrw::myDrawableList.push_back(&object);
CompDrw::Updated = false;
}


void Swap(const sf::Drawable&, const sf::Drawable&){
int i1 = CompDrw::FindDrawable(obj1);
int i2 = CompDrw::FindDrawable(obj2);
if (i1==-1 || i2==-1) return;
std::swap( CompDrw::myDrawableList[i1], CompDrw::myDrawableList[i1] );
CompDrw::Updated = false;
}

void Cancel(const sf::Drawable&){
int i = CompDrw::FindDrawable(obj);
if (i==-1) return;
CompDrw::myDrawableList.erase( CompDrw::myDrawableList.begin() + i );
CompDrw::Updated = false;
}

void Empty(){
sf::RenderTexture::Clear();
CompDrw::myDrawableList.clear();
CompDrw::Updated = true;
}

void Clear(){
sf::RenderTexture::Clear();
CompDrw::Updated = false;
}

void Update(bool updating = true){
if (!updating)
{
CompDrw::Updated = false;
return;
}
if (CompDrw::Updated)
return;
CompDrw::UpdateTexture();
}


private :

void UpdateTexture(){
CompDrw::Clear();
int N = CompDrw::myDrawableList.size();
int i;
for ( i=0; i<N; i++ )
sf::RenderTarget::Draw(*CompDrw::myDrawableList[i]);
sf::RenderTexture::Display();
sf::Sprite::SetTexture(sf::RenderTexture::GetTexture(), true);
CompDrw::Updated = true;
}

int FindDrawable(const sf::Drawable&){
int N = CompDrw::myDrawableList.size();
int i;
for ( i=0; i<N; i++)
if ( CompDrw::myDrawableList[i] == &obj )
return i;
return -1;
}

bool Shown;
bool Lightable;

bool Updated;
std::vector<const sf::Drawable *> myDrawableList;

}; // end class CompostiteDrawable

} // end namespace og

#endif // end _OG_COMPDRW_HPP_
[/code]

6
Graphics / problem with sf::RenderTexture::Draw in derived class
« on: December 23, 2011, 10:28:28 am »
Hi all.
I'm trying to create a class derived from both sf:: RenderTexture both sf:: Sprite, since there are methods with the same prototype in these two classes I avoid the ambiguities always calling methods with the complete "address" (eg sf :: RenderTexture: GetTexture() or sf:: Sprite:: GetTexture() instead of just GetTexture()). It seems to work just about everything, but I still get an error when I call sf:: RenderTexture:: Draw ().
here is the incriminated part of the code:
Code: [Select]
class myClass : public sf::RenderTexture, public sf::Sprite
{
   private :
       std::vector<sf::Drawable *> Obj;
        ...
   public :
        void myMethod()
        {
             ...
             sf::RenderTexture::Draw(*Obj[i]);
             ...
        }
        ...
};


It compile fine, but when i launch a program that uses this class i get the error
Quote
pure virtual method called

and i can't understand where the problem is. Can anyone help me to fix it?

7
DotNet / error compiling GWEN workspace
« on: December 03, 2011, 02:58:36 pm »
Hi All!
This library looks great, but I have some problems trying to compile it with Code::Blocks on Windows.

First of all, it tells me "error: 'Gwen::Utility' was not declared" when you try to compile the file "Gwen\Controls\Base.h" but adding "#include "Gwen/Utility.h" " seems to be fixed.

However, it finds another error in the file "src\Utility.cpp":

Quote
error: invalid conversion from 'unsigned int' to 'const wchar_t*'
error: cannot convert 'const wchar_t*' to 'char*' for argument '3' to 'int vswprintf(wchar_t*, const wchar_t*, char*)'

in the declaration of the function

Code: [Select]
UnicodeString Gwen::Utility::Format( const wchar_t* fmt, ... )
{
wchar_t strOut[ 4096 ];

va_list s;
va_start( s, fmt );
vswprintf( strOut, sizeof(strOut), fmt, s );
va_end(s);

UnicodeString str = strOut;
return str;
}


but to me the code seems right...

Am I compiling the wrong way? Is the problem only mine? How can I fix it?

Thanks!

8
Thanks!
Do I have to build this library with cmake before use it?

9
General / Can't compile the Window sample
« on: October 28, 2011, 07:35:10 pm »
ok, I've installed the second version, and it seems to work, but it also looks a lot different from the 1.6 ... There is a tutorial or do I learn all from the documentation?

10
General / Can't compile the Window sample
« on: October 26, 2011, 06:31:21 pm »
ok, thanks! I'll try as soon as possible!

11
General / Can't compile the Window sample
« on: October 26, 2011, 04:59:10 pm »
Hi all!
First of all: I don't speak english since almost 3 or 4 years. Please, forgive my bad grammar...

I have a similar problem: i can't compile the file window-opengl.cpp of the tutorial about OpenGL (http://www.sfml-dev.org/tutorials/1.6/window-opengl.php). When i try to compile it, code::blocs gives the error "undefined reference to" every function (or methods) that refers to gl or glu. I tried to link every combination of "-l", "gl", "glu", "glu32"; copy "gl32", "glu32", "OpenGL32" *.lib and *.ddl files in every folder; including "gl.h", "glu.h", "glext.h", but it still gives the same error.

Could you help me?

Pages: [1]