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

Pages: [1] 2
1
Graphics / Re: Nothing in Graphics module compiles!
« on: January 29, 2015, 06:32:32 am »
So, it turns out I was retarded and linked to "sfml-graphis"

It was my grandma who noticed. :-[

2
Graphics / Nothing in Graphics module compiles!
« on: January 29, 2015, 04:17:26 am »
So I've been trying to get anything in the graphics module to work (window module works fine), and it just won't happen. I get a window up and running without any issues, but as soon as I even declare a Texture, ImageLoader gives me several errors. Does anyone have a clue what they mean or how to fix them?

The Texture isn't the only thing that causes this. If I change sf::Window to sf::RenderWindow, or try to use much of anything else in the Graphics module, I get the exact same errors, all originating from ImageLoader.cpp

3
Window / Re: Hardware Position of mouse?
« on: January 28, 2015, 02:46:45 pm »
I like that idea... So simple. Just "unlock" the mouse as soon as the user reaches a menu screen or any situation where mouse use is required. Thank you!

4
Window / Hardware Position of mouse?
« on: January 27, 2015, 05:01:59 am »
Is it possible in SFML a position for the mouse that does not correspond to the position of a window or the desktop itself? For instance, in any 3D game where mouse controls camera, I need to be able to find out movement of the mouse event if it would go beyond the edge of the screen.  I didn't see anything like this in the documentation, but I've also been known to miss things now and again when perusing through.

5
Graphics / Stack around the variable "MyFont" was corrupted.
« on: May 20, 2011, 03:31:26 am »
AHA! This solved it. I never read about compiling it myself before! Interesting that it never caused me any issues until that text thing.

6
Graphics / Stack around the variable "MyFont" was corrupted.
« on: May 19, 2011, 10:06:31 pm »
I did some digging, and apparently, SFML was/is buggy with VS2010? I compiled my project in VS2008 and it worked all fine and dandy.

7
Graphics / Stack around the variable "MyFont" was corrupted.
« on: May 19, 2011, 07:19:32 pm »
Quote from: "OniLink10"
Do NOT use the default font. Last I checked, it's completely broken and results in errors. It might just be a specific version of SFML, though.


I also tried loading Xirod TTF. Is there a specific spot on my hard drive it must be in?

Quote

maybe it's the copy that is broken, try to get a reference on the default font instead of copying it


As in sf::Font &MyFont = sf::Font::GetDefaultFont(); ?

I have tried both of these, and neither lent any dice. Linking with the debug libraries has yielded nothing as well.

Some more code snippets:
Code: [Select]
GButton.h
/////////////////////
/// The font that the button class will use
/////////////////////
const sf::Font *font;


Code: [Select]
GButton.cpp
GButton::GButton(sf::RenderWindow& window, std::string text, sf::Color selectedColor, sf::Color deselectedColor)
{
//set the render window
this->window = &window;

//set the colors
this->selectedColor = selectedColor;
this->deselectedColor = deselectedColor;

//reference to the default font
font = &sf::Font::GetDefaultFont();
this->text = sf::String(text, *font, 30);
}


Code: [Select]
GButton.cpp
void GButton::Draw()
{
window->Draw(text);
}


I couldn't get a module level const variable reference to compile, so I tried a pointer. Still the same runtime error. However, I did notice that no matter what I do, the font for the sf::String 'text' seems to have an invalid size

[/img]

8
Graphics / Stack around the variable "MyFont" was corrupted.
« on: May 18, 2011, 04:58:40 pm »
I have this code, which, for test purposes, I copied and pasted directly from the 1.6 tutorial.

Code: [Select]

     sf::Font MyFont = sf::Font::GetDefaultFont();

// Create a graphical string
    sf::String Hello;
    Hello.SetText("Hello !\nHow are you ?");
    Hello.SetFont(MyFont);
    Hello.SetColor(sf::Color(0, 128, 128));
    Hello.SetPosition(100.f, 100.f);
    Hello.SetRotation(15.f);
    Hello.SetSize(50.f);


And I get the runtime error in the title bar. I've tried having SFML load Xirod font, which I put in the project folder (VS 2010) and the executable folder. No dice.

9
Graphics / sf::Color linker error
« on: May 18, 2011, 03:00:36 am »
Who this is the first I've ever had an issue without doing that... Thanks!

10
Graphics / sf::Color linker error
« on: May 17, 2011, 07:52:41 pm »
Which tutorial? I haven't been able to find any bold print, and nothing explaing linking or anything like that.

11
Graphics / sf::Color linker error
« on: May 17, 2011, 06:42:36 pm »
When I try to use the following code

Code: [Select]

        this->selectedColor = sf::Color::Green;
this->deselectedColor = sf::Color::Red;


Where selectedColor and deselectedColor are variables of type sf::Color, I get the following linker error.


Error   11   error LNK2001: unresolved external symbol "public: static class sf::Color const sf::Color::Red" (?Red@Color@sf@@2V12@B)   C:\Users\Daniel\documents\visual studio 2010\Projects\Game Template\Game Template\GButton.obj


THis is followed by an equivilent error for the green color call, and any other colors I use. If I specify the colors manually (sf::Color(0,255,0)), then I get a runtime error that breakpoints me somewhere in the middle of xutility.cpp.

My linker settings are this:
Code: [Select]
sfml-graphics.lib
sfml-window.lib
sfml-system.lib
sfml-audio.lib
sfml-main.lib
opengl32.lib
glu32.lib


and I include <SFML/Graphics.hpp> in the relevant file. What am I doing wrong?

12
Window / openGL issue + window waits to draw
« on: May 17, 2011, 06:46:25 am »
Quote from: "Laurent"
Quote
1st, the SFML window I create does not draw/display anything until I move the mouse over it.

Normal, your drawing code is inside the event loop. So it won't be executed until an event occurs.


Oh wow. I feel stupid now.

That still didn't fix the 2nd problem, which I think is probably rooted in some faulty openGL commands I've called.

Well, I did fix it. TUrns out I was not properly changing the z buffer with gluPerspective to show points as far as 5 units away. -_-

13
Window / openGL issue + window waits to draw
« on: May 16, 2011, 07:49:40 pm »
I'm currently having two issues, and I think that they are related to each other.

1st, the SFML window I create does not draw/display anything until I move the mouse over it.

Second, whenever I move the mouse, my openGL primitives get both smaller and closer together-- as long as the mouse is moving (any direction, and INSIDE the SFML window) until they disappear completely. I'll post the relevant code here, because I am currently stumped and I have no idea what to google for on this issue.

Code: [Select]


///////////////////////////////////
/// Main starts the program,
/// creates a GameManager and
/// has it loop until completion
///////////////////////////////////
int main(int argc, char** argv)
{
//constructor game manager and start looping
GameManager Manager("Template");
Manager.Loop();
}



Code: [Select]
GameManager::GameManager(string title)
{
//the dimentions of the window
int size[2] = {800, 600} ;

//creates the game window, sized to the two elements of the array declared above
window.Create(sf::VideoMode(size[0],size[1]), title);
this->initGL();
this->resize(size[0], size[1]);
}


GameManager::~GameManager(void)
{

}

const sf::Input& GameManager::GetInput()
{
return window.GetInput();
}

void GameManager::Loop()
{
//constantly loop through the window
while(window.IsOpened())
{
//go through the event processing loop
sf::Event Event;
while(window.GetEvent(Event))
{
//process event based on type
switch(Event.Type)
{
//resize if resized
case sf::Event::Resized:
resize(Event.Size.Width, Event.Size.Height);
break;

//close if closed
case sf::Event::Closed:
window.Close();
break;
}

this->update();
this->draw();

window.Display();
}
}
}

void GameManager::draw()
{
//clear the screen
glClear(GL_COLOR_BUFFER_BIT);

glMatrixMode(GL_PROJECTION);
//glLoadIdentity();
gluLookAt(0,0,1,     0,0,0,     0,1,0);
//viewport code here
//////////////////////
//////////////////////
//////////////////////
///end viewport code

//Drawing code here

glMatrixMode(GL_MODELVIEW);
        //glLoadIdentity();
//for demo purposes, we draw a triangle
glPointSize(100);
glBegin(GL_TRIANGLES);
{
glVertex2f(-1,0);
glVertex2f(1,0);
glVertex2f(0,1);
}
glEnd();

//end drawing code

glFlush();
}

void GameManager::update()
{

}

void GameManager::initGL()
{
glClearColor(0,0,1,0);
glColor3f(0,1,0);
}

void GameManager::resize(float w, float h)
{
glViewport(0,0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60, w /h, 1, 200);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gluLookAt(0,0,5, 0,0,0, 0,1,0);
}


Code: [Select]


class GameManager
{
public:
//////////////////
/// Creates the game window
/// And calls the resize method to properly set the window attributes and glViewport
/// \param The title of the game's window
//////////////////
GameManager(string title);

///////////////////
///
//////////////////
~GameManager(void);

//////////////////
/// Has the GameManager loop through the window cycle,
/// as well as updating and drawing stuff
//////////////////
void Loop();

///////////////////////////
/// Gets a reference to the window's input struct
///////////////////////////
const sf::Input& GetInput();

private:
////////////////////////
/// The render window
////////////////////////
sf::RenderWindow window;

//////////////////
/// The portion of the game currently running.
/// IE: MainMenu, OptionsMenu, etc
//////////////////
GameState state;

///////////////
/// Initializes the openGL states
//////////////
void initGL();

/////////////
/// Draws the game
/////////////
void draw();

////////////////
/// Updates everythign in need of updating
///////////////
void update();

///////////////
/// Resizes the window
///////////////
void resize(float w, float h);
};


The general gist is this:

Manager creates window. Manager updates and draws window repeatedly. Whenever the mouse is moved, the primitives (the vertex2f calls) get closer to the origin, and smaller, until they disappear completely.

Any help would be AMAZING.

I have tried:

[list=]
removing, moving, and in general experimenting with the commented out calls to glLoadIdentity() in the draw method.

debugging. The code stays in these 3 files, plus of course the openGL ones which I cannot see in VS, the entire time.

Changing the primitives from GL_POINTS to GL_LINES, and GL_TRIANGLES.

Removing GL_FLUSH.
[/list]

14
Window / Storing multiple sf::Input instances possible?
« on: May 16, 2011, 07:03:36 pm »
I would like to store input states for previous game loops, and the simplest way in XNA was simply to save the input state. IE: prevKB state = Keyboard.GetState();

Is it possible to do something like that in SFML? I can't seem to figure it out correctly...

15
Window / 3D depth stuff
« on: March 09, 2011, 10:06:43 pm »
I have this program:

Code: [Select]


#include <GL/freeglut.h>
#include <SFML/Window.hpp>

static GLfloat year = 0, day = 0, moon = 0;

bool m,M,y,Y,d,D;

void init()
{
    glClearColor(0,0,0,0);
    glShadeModel(GL_FLAT);

    glEnable(GL_DEPTH_TEST);
}

///////////////////
///Display the sun, earth, and moon
///////////////////
void display(void)
{
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glColor3f(1,1,1);

    glColor3f(1,1,0);
    glPushMatrix();
    glutSolidSphere(1, 20, 16);//the sun

    //here is where we transform matrices to get to the planet's position
    glColor3f(0,0,1);
    glRotatef((GLfloat)year , 0, 1, 0);
    glTranslatef(2,0,0);
    glPushMatrix(); //remember the planets position
    glRotatef((GLfloat)day, 0, 1, 0); //rotate the planet, but do not remember its rotation
    glutSolidSphere(0.2, 10, 8); // planet

    glColor3f(0.3,0.3,0.3);
    glPopMatrix(); //go back to the position at which the earth was drawn (before rotation)
    glRotatef(moon, 0, 1.5, 0);
    glTranslatef(0.5,0,0);
    glutSolidSphere(0.05,10,8); //and then draw the moon, transformed properly

    glPopMatrix();
    glPopMatrix();

    //glutSwapBuffers();
    //glutPostRedisplay();
}

////////////////////////////
///Set all the viewport and perspective stuff when the window is resized
////////////////////////////
void reshape(int w, int h)
{
    glViewport(0,0, (GLsizei)w, (GLsizei)h);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    gluPerspective(60, (GLfloat)w / (GLfloat)h, 1, 200);
    gluLookAt(0,2, 5,    0,0,0,     0, 1, 0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
}


void update(const sf::Input &input)
{
    const GLfloat rotationSpeed = 0.05f;

    //if M is pressed, move the moon forwards or backwards in rotation
    if(input.IsKeyDown(sf::Key::M) && !input.IsKeyDown(sf::Key::LShift))
        moon = (moon + 2 * rotationSpeed);
    else if(input.IsKeyDown(sf::Key::M))
        moon = (moon - 2 * rotationSpeed);

    //if Y is pressed move the earth in orbit
    if(input.IsKeyDown(sf::Key::Y) && !input.IsKeyDown(sf::Key::LShift))
        year = (year + rotationSpeed);
    else if(input.IsKeyDown(sf::Key::Y))
        year = (year - rotationSpeed);

    //if D is pressed rotate earth, simulating days
    if(input.IsKeyDown(sf::Key::D) && !input.IsKeyDown(sf::Key::LShift))
        day = (day + rotationSpeed);
    else if(input.IsKeyDown(sf::Key::D))
        day = (day - rotationSpeed);
}

////////////////////////////////////////////////
/// /param: Event: The event
/// /param: capitalValue: The value of the capital lettered bools
/// /param: lowerCaseValue: The value of the lowercase bools
////////////////////////////////////////////////
void keyboard(sf::Event theEvent, bool value)
{
    switch(theEvent.Key.Code)
    {
        case sf::Key::Y:
            if(theEvent.Key.Shift)
                Y = value;
            else
                y = value;
        break;
    }
}

int main(int argc, char** argv)
{
    init();
    glutInit(&argc, argv); //so glutSolidSphere can be used

    sf::Window *app = new sf::Window(sf::VideoMode(800,600), "SFML",
                                    sf::Style::Close);

    reshape(app->GetWidth(), app->GetHeight()); //set the proper window and viewport stuff

    while(app->IsOpened())
    {
        sf::Event theEvent;
        while(app->GetEvent(theEvent))
        {
            switch(theEvent.Type)
            {
                case sf::Event::KeyPressed:
                    keyboard(theEvent, true);
                    break;

                case sf::Event::KeyReleased:
                    keyboard(theEvent, false);
                    break;

                case sf::Event::Resized:
                    reshape(app->GetWidth(), app->GetHeight());
                    break;

                case sf::Event::Closed:
                    app->Close();
                    break;
            }
        }
        update(app->GetInput()); //update the planets based on current keyboard status
        display(); //display the planets
        app->Display(); //show the window
    }
}



The earth rotates around the sun, and the moon rotates around the earth, but no matter what happens, the earth is ALWAYS drawn in front of the sun (even when its rotated behind), and the moon is ALWAYS drawn in front of the Earth (and in front of the sun, naturally). I don't really know why.

Pages: [1] 2
anything