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.


Topics - sknnywhiteman

Pages: [1]
1
Graphics / How would you do player animations?
« on: January 06, 2014, 04:54:49 am »
I make games in C++ and SFML with OpenGL from GLEW. I have SFML for input and windows, and all of my rendering is done from normal OpenGL. Currently, when I use animations, I have an Animation class that holds all of the frames for each animation, and how long each frame should be displayed (two int std::vectors, one for ticks and one for frames), but the problem is when I have to add new animations to my entities or dealing with multiple animations at once.

During initialization, I create animations for my characters, (which I want to change to data-driven, but not a huge priority right now) and I store the animation to my current character and any enemies that start out. The problem is, I have like 12 different animations that have to be stored(in each direction: walk, idle, run, hurt, attack), and if I want to spawn new entities, I have to either store a copy of each animation for each entity type (which I want to eventually be randomly different), or I have to load them each time. It just seems.. difficult to keep track of so many. All the animation tutorials I find online are the very basics about changing your texture coordinates for the next frame, but nothing too in-depth.

2
General / SFML 2.1 & VS 2012
« on: November 25, 2013, 04:33:47 am »
so, I downloaded SFML 2.1 to build with CMake so I can change the static libraries to not use the standard libraries, but when I do, I get 42 linker errors. I followed the tutorial as closely as possible, but I either missed something, or I'm derping somewhere.

Quote
1>sfml-graphics-s.lib(Texture.obj) : error LNK2001: unresolved external symbol ___GLEW_ARB_texture_non_power_of_two
1>sfml-graphics-s.lib(RenderTarget.obj) : error LNK2001: unresolved external symbol ___glewBlendFuncSeparateEXT
1>sfml-graphics-s.lib(RenderTarget.obj) : error LNK2001: unresolved external symbol ___GLEW_EXT_blend_func_separate
1>sfml-graphics-s.lib(GLCheck.obj) : error LNK2001: unresolved external symbol _glewInit
1>sfml-graphics-s.lib(GLCheck.obj) : error LNK2001: unresolved external symbol _glewGetErrorString
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewActiveTextureARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewAttachObjectARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewCompileShaderARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewCreateProgramObjectARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewCreateShaderObjectARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewDeleteObjectARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewGetHandleARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewGetInfoLogARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewGetObjectParameterivARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewGetUniformLocationARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewLinkProgramARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewShaderSourceARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewUniform1fARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewUniform1iARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewUniform2fARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewUniform3fARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewUniform4fARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewUniformMatrix4fvARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___glewUseProgramObjectARB
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___GLEW_ARB_fragment_shader
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___GLEW_ARB_shader_objects
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___GLEW_ARB_shading_language_100
1>sfml-graphics-s.lib(Shader.obj) : error LNK2001: unresolved external symbol ___GLEW_ARB_vertex_shader
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_std_error
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_CreateCompress
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_destroy_compress
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_stdio_dest
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_set_defaults
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_set_quality
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_start_compress
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_write_scanlines
1>sfml-graphics-s.lib(ImageLoader.obj) : error LNK2001: unresolved external symbol _jpeg_finish_compress
1>sfml-system-s.lib(SleepImpl.obj) : error LNK2001: unresolved external symbol __imp__timeGetDevCaps@8
1>sfml-system-s.lib(SleepImpl.obj) : error LNK2001: unresolved external symbol __imp__timeBeginPeriod@4
1>sfml-system-s.lib(SleepImpl.obj) : error LNK2001: unresolved external symbol __imp__timeEndPeriod@4
1>sfml-window-s.lib(JoystickImpl.obj) : error LNK2001: unresolved external symbol __imp__joyGetPosEx@8
1>sfml-window-s.lib(JoystickImpl.obj) : error LNK2001: unresolved external symbol __imp__joyGetDevCapsW@12


I'm assuming I'm missing something small, but I have SFML_STATIC, I'm using /MT, I built SFML Statically (I only have the '-s.lib's), and I built with the SFML_USE_STD_LIBS flag set to false so I can link statically, but apparently I can't. Does anything jump out at you? I also use glew from their website so I can use Vertex Buffer Objects for rendering with OpenGL.

3
Network / [SFML 2.0] Does TCP socket use the Window context?
« on: March 15, 2013, 06:59:11 pm »
I'm using a multi-threaded program to use one for rendering and the other for things with the CPU.. but after I create the second thread and start the context in it for the window, I'm unable to do anything with the TCP socket without it crashing. Is that it, or am I doing something wrong?

4
Graphics / [SOLVED]Vertex Buffer Object error
« on: February 18, 2013, 12:06:44 am »
so.. I have NO idea why this is throwing an exception, but it's crashing my game whenever I call glDrawArrays. I set everything up correctly, and I've even copied-pasted code from tutorials that show people how to use VBOs, and it goes up to the glDrawArrays, and then crashes. I'm using sf::Renderwindow, and I get the error 0xC0000005: Access violation reading location 0x00000000.
GLuint createVBO(GLfloat* vertices, int size){
        GLuint vbo;
        glGenBuffers(1, &vbo);
        glBindBuffer(GL_ARRAY_BUFFER, vbo);
        glBufferData(GL_ARRAY_BUFFER, size*sizeof(GL_FLOAT), vertices, GL_STATIC_DRAW);
        glBindBuffer(GL_ARRAY_BUFFER, 0);
        return vbo;
}

//init function
glewInit();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0, window.getSize().x, window.getSize().y, 0, -1, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glEnable(GL_ALPHA_TEST);
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
glLoadIdentity();
glAlphaFunc(GL_GREATER, 0.2f);
glLoadIdentity();
GLfloat *verts = new GLfloat[6];
verts[0] = 100.0f; //Verts at (100, 100), (200, 100), (150, 150)
verts[1] = 100.0f;
verts[2] = 200.0f;
verts[3] = 100.0f;
verts[4] = 150.0f;
verts[5] = 150.0f;
GLuint VertexVBOID = createVBO(verts, 6);
while(running){
        glBindBuffer(GL_ARRAY_BUFFER, VertexVBOID);
        glEnableClientState( GL_VERTEX_ARRAY );
        glVertexPointer(2, GL_FLOAT, 0, BUFFER_OFFSET(0));
        glDrawArrays(GL_TRIANGLES, 0, 3);
        glBindBuffer( GL_ARRAY_BUFFER, 0 );
        glDisableClientState( GL_VERTEX_ARRAY );
        window.display();
        sf::sleep(sf::milliseconds(16));
}

For anyone who is looking for the answer in the future, my problem was solved from http://www.sfml-dev.org/old-forum/viewtopic.php?t=7327&sid=c277620601084e8aa0f406a415a6b795. I hadn't disabled some states that SFML had enabled in secrecy. GL_TEXTURE_COORD_ARRAY & GL_COLOR_ARRAY.

5
General / Any idea on why I can't use /MT?
« on: February 08, 2013, 04:19:41 am »
I built SFML 2.0 RC with CMake with a tutorial I found online, and I know it works, because I've used it before (with /MD setting), and it worked fine. I want to use the /MT flag with SFML, and I found out through the forums I need to rebuild it, so I installed CMake and did everything I had to with VS2012 command prompt, and it built fine. I made sure I used the "SFML_USE_STATIC_STD_LIBS=TRUE", but it still gives me the errors in studio when I try to compile it with link errors like
 
Quote
sfml-window-s.lib(Window.cpp.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease' in Source.obj
I'm so frustrated, because I've spent hours trying to fix this, and I have gotten no progress at all. Can you tell me what I need to fix to get this to work?
I'm using the settings -G "NMake Makefiles" -D CMAKE_BUILD_TYPE=Release -D BUILD_SHARED_LIBS=FALSE -D SFML_USE_STATIC_STD_LIBS=TRUE
Would someone by any chance already have pre-built sfml 2.0 RC with these specs? :D

6
Window / Weird Vsync CPU consumption?
« on: July 17, 2012, 04:01:32 am »
So, when I'm running my game and I use Vsync, it uses all of one core to render my game screen even though I'm sleeping for 16 ms at a time. I have a solid 60 FPS and everything is smooth, but when I take Vsync off, it uses little to none CPU, and I found the reason why after searching the forums a little:
http://en.sfml-dev.org/forums/index.php?topic=7732.msg51443
Basically, if you don't want to read it, the creator of the thread said that the problem is in nVidia control panel and turning threaded optimization off. I tried it, and it works perfectly.  They also figured out that the problem isn't in AMD cards.
My question is, (because when I went in to the control panel, it was "auto") are we able to somehow state that we want it off for nVidia users?

7
Graphics / OpenGL VBOs
« on: June 29, 2012, 08:28:05 pm »
I've been reading around recently about how people render things in OpenGL, and I see that most people who have been working with OpenGL for a while have been using Vertex Buffer Obects. I became interested in them and started reading around people's OpenGL code to create it. I tried using them, however, and I'm not able to use any functions like glGenBuffers(1, &IndexVBOID), and glBindBuffer(GL_ARRAY_BUFFER, VertexVBOID). Does anybody else use VBOs with SFML or know of any way to use them? I could use Glut if I needed to, but I'd rather not.
If anyone could help me, it'd be appreciated greatly! :D

8
General / Linking errors?
« on: May 28, 2012, 01:15:10 am »
I'm like 95% sure this is a problem on my part, not SFML, but I'm using MinGW with Code::Blocks on SFML RC, and every single time I compile, I get these warnings:

||warning: auto-importing has been activated without --enable-auto-import specified on the command line.|
||Info: resolving vtable for sf::Text by linking to __imp___ZTVN2sf4TextE |
||Info: resolving vtable for sf::VertexArray by linking to __imp___ZTVN2sf11VertexArrayE |
||Info: resolving sf::RenderStates::Default      by linking to __imp___ZN2sf12RenderStates7DefaultE |
||=== Build finished: 0 errors, 1 warnings ===|

Because they're only warnings, I'm able to continue as I was, but this started happening after updating to the Release Candidate.. Am I not linking right? I followed the installation guide on the Tutorials, but maybe I missed something..

9
Graphics / SF::Text problem..
« on: December 10, 2011, 11:57:24 pm »
I'm making a multiplayer game right now, and everything is running smoothly, except one thing. I have everyone in a vector with my Player class, and one of the things is a name. I want the name to be displayed above the player, (which is right now just a green square, for testing purposes.) but it's not working. After some testing, I see what is happening. OpenGL is rendering the squares correctly, but the letters that are supposed to be there, are changing into green squares the size of the letters.. It seems like OpenGL and SFML are having conflicts on my screen. The actual drawing part of my game, minus the OpenGL stuff is here:

Code: [Select]
for(unsigned int a = 0; a < players.size(); a++){
        sf::Text Name;
        Name.SetString(players.at(a).getName());
        Name.SetColor(sf::Color::Black);
        Name.SetCharacterSize(14);
        Name.SetPosition(players.at(a).getX(), players.at(a).getY() - 20);
        Window->Draw(Name);
    }
    Window->Display();

(Notice that when I actually get rid of the Name.SetColor(sf::Color::Black) part, it changes it to green, but when I put that there, it changes the green square, and the text, to black.

EDIT:
Let me also clarify that when I get rid of the Window->Draw(Name) part, it also makes my game look normal. The drawing method is doing weird things to    the game.. :(

10
System / SFML 2.0 Clock
« on: December 05, 2011, 06:16:24 pm »
I have recently switched from 1.6 to 2.0, and have spent lots of time debugging a lot of the changes you have made, (I like a lot of them!) and one thing I came across was sf::Clock::GetElapsedTime(). It used to return in a float, which I thought was really nice. It went even further than to the nearest millisecond, and never returned a 0.0f. With it returning a Uint32, it goes to the nearest millisecond, which makes me sad. :( Here's why.
I'm programming a server and client for a little game I'm making to mess around with. The server has a main thread constantly accepting new players, removing them, and updating them (with a mutex! :D) and then I have the second thread which is doing nothing but looping through and ticking all of the connected players. Everything was working fine, until I switched to sfml 2.0 with the clocks. I updated all of my floats to sf::Uint32 and because it returns with seconds, and my computer can tick everything so fast, it usually returns at 0, which makes everyone connected sit at a stand-still. (I would go back to sfml-1.6, but I really like 2.0 a lot better with the changes, and the pesky Socket.Bind(0); doesn't work with sfml-1.6. That's why I switched.)

So... I don't really know what to do with this problem. My people need to move, but I don't want a static number to move the players with.
Thanks for your help! :D

11
Network / UDP server problems. =(
« on: August 07, 2011, 07:21:46 pm »
So... This is exactly what is happening with me:

It runs perfectly fine, no problems or issues.
I invite my friend to join to see if it works properly.
He joins, and it instantly ignores me, and focuses on him.
He disconnects.
Server focuses on me again.

How do I fix this? Also, if anyone has any suggestions on how to make my code more efficient, that would also be appreciated.
By the way, this is only the loop part of my server. Everything else works fine.

Code: [Select]

while(running){
    IPAddress Address;
    unsigned short port;
    if(Listener.Receive(Received, Address, port) != Socket::Done){
        cout << "Error receiving information from " << Address << " ( Message ) " << endl;
    }
    string message;
    message.clear();
    Received >> message;
    if(message == "New character"){
        float x,y;
        bool exists = false;
        int character;
        string name;
        Received >> name >> x >> y >> character;
        cout << name << endl;
        for(int a = 0; a < connected_players; a++){
            if(playersc[a].getIP() == Address){
                exists = true;
            }
        }
        if(exists == false){
            players[connected_players].SetX(x);
            players[connected_players].SetY(y);
            playersc[connected_players].setName(name);
            playersc[connected_players].setCharacter(character);
            playersc[connected_players].setIP(Address);
            connected_players++;
            cout << "There are now " << connected_players << " playing. " << Address << " has connected!" << endl;
        }
    }
    if(message == "Remove character"){
        for(int a = 0; a < connected_players; a++){
            if(playersc[a].getIP() == Address){
                for(int b = a; b < connected_players; b++){
                    playersc[b] = playersc[b + 1];
                    players[b] = players[b + 1];
                }
                cout << "now there are " << connected_players - 1 << " players playing. " << Address << " has disconnected!" << endl;
                connected_players--;
            }
        }
    }
    if(message == "Update"){
        float x, y;
        string name;
        int character;
        Received >> name >> x >> y >> character;
        for(int a = 0; a < connected_players; a++){
            if(playersc[a].getIP() == Address){
                playersc[a].setCharacter(character);
                players[a].SetX(x);
                players[a].SetY(y);
            }
        }
        ToSend << connected_players - 1;
        if(Listener.Send(ToSend, Address, port) != Socket::Done){
            cout <<"Error sending information to "<< Address << " ( Update ) " << endl;
        }
        ToSend.Clear();
        for(int a = 0; a < connected_players - 1; a++){
            if(playersc[a].getIP() != Address){
                ToSend << playersc[a].getName() << players[a].GetPosition().x <<players[a].GetPosition().y << playersc[a].getCharacter();
                if(Listener.Send(ToSend, Address, port) != Socket::Done){
                    cout << "Error sending information to "<< Address << " ( Update ) " << endl;
                }
                ToSend.Clear();
            }
        }
    }
}
[/code]

Pages: [1]