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 - bananu7

Pages: [1] 2
1
Graphics / sf::Image private member "myTexture"
« on: December 08, 2011, 11:36:47 am »
I use sf::Image to load image to memory. Additional benefit is that it automatically creates the openGL texture identifier, so I was using it - I mean, I gonna create it anyway, so why not?
But then, I needed to access this texture identifier. So I am using now glBindMultiTextureEXT with the texture identifier extracted from sf::Image. (with the hacked code i mentioned earlier).

One of the drawbacks is that I had to force pixel update through Bind().
I think that Bind could actually get a parameter describing what texture unit I want to bind my texture to.

Or do you think that I should not use sf::Image as texture container and use it only for loading purposes?

2
Graphics / sf::Image private member "myTexture"
« on: December 07, 2011, 09:31:37 pm »
I've found another example in which this accessor could be helpful:
Code: [Select]
glBindMultiTextureEXT()
It's direct access function (new in OpenGL 3.x I believe) which is considered to be much safer and cleaner than usual glActiveTexture/glBindTexture pair.

Of course, it requires the explicit texture number, hence the need for accessor.

3
Graphics / sf::Image private member "myTexture"
« on: December 05, 2011, 11:41:31 am »
Well, i guess, maybe that problem is the sign that the redesign I've been planning for month can now commence ;p

4
Graphics / sf::Image private member "myTexture"
« on: December 02, 2011, 06:12:23 pm »
Because I need to use it repeteadly in main loop. When I don't have access to it, I need to repeatedly dereference my resource pointer and then call bind. Also, my resource manager is pretty bad-designed right now, so getting resource pointer takes a little bit too much time.

5
Graphics / sf::Image private member "myTexture"
« on: December 01, 2011, 05:24:08 pm »
I am using sf::Image as a texture class. However, my implementation of resource manager makes calls to Bind() very unefficient.

I wanted to remember the texture number in some of my drawing calls, but got an unpassable problem - private.

I am not using sf::Image directly; I created my own wrapper class.
However, I wasn't able to access this field because I can't get access to it.

I used following code as a workaround, I'd however be very happy to see some of the private variables changed to protected or be given accessors in new API.

Code: [Select]
#define private protected
#include <SFML/Graphics/Image.hpp>
#define private private


//EDIT : this code, surprisingly, didn't work. I just edited the Image.hpp file and changed this.

6
Graphics / sf::Shape Compile() is private.
« on: December 01, 2011, 05:19:25 pm »
finally...

7
Window / What's wrong with frame time in SFML 2?
« on: October 15, 2011, 10:53:34 am »
The screen should flash red every second, when running 60 fps. If it's at lower rate, your code is running slower, so it may not be the case with sf::Timer - rather than that, something makes renderer to go too slow.

If @up is right and it's in fact in miliseconds, it's ok : 1/0.016 = 60.

8
Graphics / About images/sprites and alpha and getting an image color
« on: October 15, 2011, 10:48:08 am »
The general advantage AND disadvantage of your approach is that the only reasonable way to do it is per-pixel collision.

It's very precise, however also costs a lot of CPU time.

If you really want to implement it, divide the scene into individual objects, as was said earlier. Then generate collision bitmap from top-view for every object. First test against AABB, then against the bitmap with per-pixel.

I also assumed that you need something more than rectangle-rectangle collisions. If not, just skip the second step of what I said earlier.

9
Graphics / [SOLVED] sf::Text messed up with OpenGL calls.
« on: October 15, 2011, 12:50:54 am »
Ok, FINALLY!!

The key was:
Code: [Select]
glActiveTexture(GL_TEXTURE0);
It's an ARB extension function, used basically for multitexturing.

Now both sf::Text AND my shaders run properly ;)

10
Window / What's wrong with frame time in SFML 2?
« on: October 15, 2011, 12:48:08 am »
Could you try sending the output to a file instead of stdout?
Also, make sure that your framerate is actually what you expect, for example:
Code: [Select]
static int FrameCounter = 0;
if (FrameCounter > 60)
{
   /*set clear color to red */
   FrameCounter = 0;
}
else
{
 /* set clear color to blue */
 FrameCounter++;
}
window.Clear();

11
Graphics / sf::Image and OpenGL textures
« on: October 15, 2011, 12:42:58 am »
Yup, and it's the best way to make SFML-2.0-RC better ;p

12
Graphics / Rotating every frame?
« on: October 14, 2011, 07:06:41 pm »
Code: [Select]
glRotatef(90.f, 0.f, 0.f, 1.f);

13
Graphics / [SOLVED] sf::Text messed up with OpenGL calls.
« on: October 13, 2011, 09:12:27 pm »
I was fighting with it for about 1,5 hour, trying to turn on/off different opengl attributes in different combinations, but with no success.

Don't you just have a list of what should be enabled in order to sf::Text to render text properly? It would make my day, i spent countless hours on it in my previous project, and eventually made it randomly to work, though i don't have the slightest clue what actually solved the problem.

14
Graphics / [SOLVED] sf::Text messed up with OpenGL calls.
« on: October 13, 2011, 11:55:05 am »
I've actually disabled all of the features of my GUI, leaving only
Code: [Select]
void CGUI::Print (const string& msg, const float x, const float y)
{
sf::Text Title (msg, sf::Font::GetDefaultFont(), 20);
Title.SetPosition (x, y);
m_Wnd->SaveGLStates();
m_Wnd->Draw(Title);
m_Wnd->RestoreGLStates();
}


I asked about this weird function, because i was wondering how these functions actually work.
I'm sure you know the code like this:
Code: [Select]
glMatrixMode(/*choose any */);
// equivalent of save
glPushMatrix();

// now the reset function:
glLoadIdentity()

/* DRAWING */

// and restore
glPopMatrix();


So i was missing the reseting part[/code]

15
Window / QT integration and OpenGL 3.x
« on: October 13, 2011, 11:47:09 am »
I integrated SFML in a MFC window for my editor once. I guess that's what you are trying to do.

If using Qt window interface and SFML rendering is actually what you want, you must do something like this (its code using MFC, but i will do something similar in Qt)
Code: [Select]
m_RenderingContext = new sf::RenderWindow ();
sf::WindowHandle MyH = m_hWnd;// GetSafeHwnd();
m_RenderingContext->Create (MyH);


So basically I'm just getting window handle (which in this case is a part of my application window using to display OpenGL), and letting SFML initialize it just like a normal window.

//Edit: I thought i might add some more

Its actually implementation of the CChildView class of MFC, which should have its equivalent in Qt;

Also, i modified the OnPaint event to:
Code: [Select]
m_RenderingContext->Clear (sf::Color (0, 0, 0, 255));
/* Drawing code goes here */
m_RenderingContext->Display();

Pages: [1] 2
anything