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

Pages: [1]
1
Graphics / [1.6]glScissors Screen flashing
« on: June 27, 2011, 09:28:06 am »
First of all.. I'm sorry if this doesn't belong here..
glScissors causes the entire screen to flash.
Draw code:
Code: [Select]

void Widget::Draw() const
{
if(!m_visible)
                  return;
s_gui->GetWindow().Draw(m_shape);

//also draw children if any
for(WidgetList::const_iterator it = m_widgets.begin(); it != m_widgets.end(); it++) {
//don't draw outside parent's rect
StartClipping();
it->second->Draw();
StopClipping();
}
}

StartClipping simply calls the glScissors with the appropriate params.
Code: [Select]

void Widget::StartClipping() const
{
if(!s_gui)
return;

glEnable(GL_SCISSOR_TEST);
glScissor(m_clipRect.x, m_clipRect.y, m_clipRect.w, m_clipRect.h);
}
void Widget::StopClipping() const
{
if(!s_gui)
return;

glDisable(GL_SCISSOR_TEST);
}

The m_clipRectArea gets update whenever the widget moves or is resized.
Here's the weird thing:
Code: [Select]

void Widget::ResizeClipArea( uint32 newWidth, uint32 newHeight )
{
Rect prect;
if (m_parent) {
prect = m_parent->GetRect();
}

double width = s_gui->GetWindow().GetView().GetHalfSize().x*2;
double height = s_gui->GetWindow().GetView().GetHalfSize().y*2;

double xprc = newWidth/width;
double yprc = newHeight/height;
double wprc = newWidth/width;
double hprc = newHeight/height;

m_clipRect = m_rect;

m_clipRect.x = int32(m_clipRect.x * xprc);
m_clipRect.y = int32(m_clipRect.y * yprc);
m_clipRect.w = uint32(m_clipRect.w * wprc);
m_clipRect.h = uint32(m_clipRect.h * hprc);

/*  Without this commented block.. it doesn't flash.
 *  This clips the clipRect if it's  bigger than the parent's rect.
if(m_clipRect.x < prect.x)
m_clipRect.x = prect.x;

if(m_clipRect.w > prect.w)
m_clipRect.w = prect.w;

if(m_clipRect.y < prect.y)
m_clipRect.y = prect.y;

if(m_clipRect.h > prect.h)
m_clipRect.h = prect.h;
*/
m_clipRect.y = newHeight - (m_clipRect.y + m_clipRect.h);

if(m_clipRect.y < 0)
m_clipRect.y = 0;
if((uint32)m_clipRect.h > newHeight)
m_clipRect.h = newHeight;

if(m_clipRect.x < 0)
m_clipRect.x = 0;
if((uint32)m_clipRect.w > newWidth)
m_clipRect.w = newWidth;

}


Image of flickering:


Any clue what's wrong and/or how to fix it?

2
SFML projects / My Gui library
« on: June 21, 2011, 07:54:26 pm »
Quote from: "Cuban-Pete"
age of empires spotted!  :D

WYSIWYG, sounds interesting.

small tip, don't put big frames of purple in your example images, it looks bad  :wink:

Yeah.. you're right, sorry. Looks a lot better now.

3
Window / [1.6][solved] glScissors and resizing window.
« on: April 03, 2011, 09:54:59 pm »
How should I do it... the clip area very wrong.. and I don't know how to update it to match the new window size.  :(

Edit: Helpful pictures?
normal(not resized, works) http://img845.imageshack.us/i/normalf.png/
resized(doesn't work) http://img203.imageshack.us/i/resizedb.png/
Edit: More info?  :|
this is what i do when the window gets resized:

Code: [Select]
m_clipRect = m_rect; //a IntRect ... of sorts
sf::Vector2f pos = m_rect.GetPos();
        //hopefully this will turn the view coords into screen coords?.. oh wait.. this doesn't do that.. any other way?
ConvertCoords(pos); //calls sf::RenderWindow.ConvertCoords()

m_clipRect.x = (int)pos.x;
m_clipRect.y = s_gui->GetWindow().GetHeight() - (int)pos.y - m_rect.h; //this is how it's done for glScissors apparently, cause it takes the lowerleft point
   m_clipRect.w *= scaleW;   //scaleW is newWidth/oldWidth
m_clipRect.h *= scaleH;   //same with height


Solved like so:
I used window/view ratio to find coords and size like this:
Code: [Select]

        //calculate distortion percentage
        float widthPrc = newWidth/viewWidth;
float heightPrc = newHeight/viewHeight;

        //get the coords in the view
m_clipRect = m_rect;

        //apply distortion
m_clipRect.x *= widthPrc ;
m_clipRect.y *= heightPrc ;
m_clipRect.w *= widthPrc ;
m_clipRect.h *= heightPrc ;


Only one problem remains... :

P.S. Apparently maximizing the window doesn't send a resize event... Is that intented? Is there another event for maximize or something? :|
(Windows 7 x64, sfml 1.6)

4
General / [Solved]RenderWindow 'sf::NonCopyable::operator ='
« on: April 03, 2011, 07:36:36 pm »
For some reason this won't work.. :|
Code: [Select]

//in the GuiManager class
GuiManager(sf::RenderWindow& window);

///....
sf::RenderWindow& m_window;


Code: [Select]

GuiManager::GuiManager( sf::RenderWindow& window ): m_window(window),
m_hotSpotX(0),m_hotSpotY(0), m_focus(NULL),
m_drag(false),index(0),m_theme(NULL),m_hoverTarget(NULL),
m_curDrag(NULL)
{
//etc
}


I get the non-copyable thingy..
 'sf::NonCopyable::operator =' : cannot access private member declared in class 'sf::NonCopyable'

Nvm...It was broken elsewhere apparently.

5
SFML projects / My Gui library
« on: March 29, 2011, 02:19:33 pm »
Yes.. it's yet another gui library. It's still in process, so it's not actually usable atm. It's called SimpleGui, because hopefully it'll be really easy to use.

I don't have too much to say about it, because still it's still early in the development a lot of things are subject to change, but here's a basic feature description:
1. Themes. Widgets can have default values. You can also add user data to the current theme.
2. Dynamic widget creation. Basically means that you can create widgets from .xml files.
3. WYSIWYG Editor. This isn't implemented yet, but everything I've done so far was designed to make it easier to implement it, (dynamic widget creation especially).

There's only a few default widgets so far... Like buttons, line edits, window's, checkboxes, radioboxes, and a text area... though none these are completely finished yet(but they are basically functional).

To interact with the widgets, you register a listener to some widget's events. Here's how it basically looks like in the .ui file:
Code: [Select]

    <listener name="default">
        <widget name="my_widget.my_button" event="4" />
    </listener>

and the only code you'd have to write in your app is polling for events and responding to them.. like this:
Code: [Select]

while(e = m_gui.GetMediator().GetEvent()) {
std::cout << "Received event!: " << e->GetType()) << std::endl;;
}


source code is here: http://code.google.com/p/simple-gui/


6
Graphics / v1.6 - Clipping (shapes, Strings..)
« on: March 23, 2011, 09:04:06 pm »
Oh! I see. I pretty much got it working. Thanks!

7
Graphics / v1.6 - Clipping (shapes, Strings..)
« on: March 23, 2011, 07:58:30 pm »
Quote from: "Laurent"
You can't do it with SFML. The best workaround is to use the OpenGL function glScissor.

Doh... I don't know OpenGL.. I've put off learning it for a while..
I guess it's time to do a tad of research.

8
Graphics / v1.6 - Clipping (shapes, Strings..)
« on: March 23, 2011, 07:25:06 pm »
I'm working on a gui system of sorts... and I'm wondering how I could clip stuff like sfml Shapes and Strings like this:

http://img88.imageshack.us/img88/6035/unclipped.png to => http://img25.imageshack.us/i/clipped.png/

9
Graphics / [Solved] v1.6 sf::Shape gets drawn in the wrong position
« on: March 09, 2011, 09:21:31 am »
I see.. Thanks! I got it working now(by making sure local position is 0,0).

10
Graphics / [Solved] v1.6 sf::Shape gets drawn in the wrong position
« on: March 08, 2011, 10:55:51 pm »
I think I know what's wrong... it's probably just because I'm using the sf::Shape wrong... I'm not exactly sure how I'm supposed to use it...
Code: [Select]

        sf::Shape s1,s2;
s1 = sf::Shape::Rectangle(50,50,100,100,sf::Color(255,0,0));
s2 = sf::Shape::Rectangle(0,0,50,50,sf::Color(0,255,0));

s1.SetPosition(0,0);
s2.SetPosition(10,10);

I'd think this would make two 50 by 50 pixels rectangles, one at 0,0 and one at 10,10. This is not actually how it works... I'll get instead two 50,50 rects, one at 10,10(green), and one at 50,50(red).

So how should I actually use the shape? Should I normalize the params to the shape so that it'll be at 0,0 ?
like: s1 = sf::Shape::Rectangle(50,50,100,100,sf::Color(255,0,0));
to:   s1 = sf::Shape::Rectangle(0,0,50,50,sf::Color(255,0,0));

I didn't think the pos of the params actually matter.. because you can always just use the SetPosition function to move it.

11
Graphics / [Solved] v1.6 sf::Shape gets drawn in the wrong position
« on: March 08, 2011, 08:10:10 pm »
Quote from: "Laurent"
Do you use scale factors?

Scale factors .. as in did I use the shape.Scale() function? No.. I didn't scale or rotate or anything.. just a drew simple shape..

12
Graphics / [Solved] v1.6 sf::Shape gets drawn in the wrong position
« on: March 08, 2011, 06:31:55 pm »
Image is pretty self explanatory..



What's going on?  :shock:

The big shape draws the smaller shape
Code: [Select]

void Widget::Draw()
{
if(!s_window) return;

s_window->Draw(m_shape);

//also draw children if any
for(WidgetList::iterator it = m_widgets.begin(); it != m_widgets.end(); it++) {
it->second->Draw();
}
}

13
General discussions / Linker Error
« on: September 25, 2010, 04:54:27 pm »
I'm getting this error when trying to compile the code below:

error LNK2001: unresolved external symbol _WinMain@16
Code: [Select]

#include <iostream>
#include <SFML/System.hpp>

int main()
{
    sf::Clock Clock;
    while (Clock.GetElapsedTime() < 5.f)
    {
        std::cout << Clock.GetElapsedTime() << std::endl;
        sf::Sleep(0.5f);
    }

    return 0;
}


The project is on Release, and the additional dependencies are: sfml-system.lib

Pages: [1]