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

Pages: [1]
1
Graphics / Settings texture wrapping to repeat using sf::Renderer
« on: June 08, 2011, 07:16:08 pm »
I was just trying out some ways to generate a racing track from a few points, generating the vertices worked out right but I'm having some problems with the texture coordinates. I currently have a distance variable which keeps track of the current track distance and a textureSize variable which determines how much pixels of the track the texture should cover.

The code which calculates the uv coordinates:
Code: [Select]

float textureSize = 64.0f //The texture is 64x64 so this should display it at the real scale.

// The two sides of the point in the track.
leftVertex.texCoords = sf::Vector2f(0.0f, distance / textureSize);
rightVertex.texCoords = sf::Vector2f(1.0f, distance / textureSize);


I render the vertices like this:
Code: [Select]

renderer.SaveGLStates();
   
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_WRAP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_WRAP);
   
renderer.SetTexture(&m_Texture);
renderer.Begin(sf::Renderer::TriangleStrip);
    for (int i = 0; i < m_sideVertices.size(); i++)
    {
        renderer.AddVertex(m_sideVertices[i].position.x,
                           m_sideVertices[i].position.y,
                           m_sideVertices[i].texCoords.x,
                           m_sideVertices[i].texCoords.y,
                           sf::Color::White);
    }
renderer.End();

renderer.RestoreGLStates();


But it looks like this (red lines show where the vertices are):


As you can see the beginning of the track (the left side) is textured correctly because the v coordinates are within the 0-1 range, after that the texture gets stretched out.

So is setting the texture wrapping mode to GL_REPEAT not working or am I using the wrong texture coordinates?

2
General / Get positional data from View in SFML 2.0
« on: May 06, 2011, 09:20:00 pm »
I just changed to SFML 2.0 and all went well until I couldn't find a way to retrieve data about the position of the current sf::View. I have a tile map and I only want to draw the tiles that are currently visible. The only way I thought of was to retrieve the data from the projection matrix but it seems kind of hacky :?.

3
General / Window only updates when mouse is moved over it.
« on: April 16, 2011, 10:52:28 am »
I just switched to Ubuntu and tried using SFML, however my RenderWindow only updates when I move the mouse cursor over it.

I use the code from the tutorial about Sprites and move the sprite by a tiny amount each frame. If I move the mouse for a few seconds the window keeps updating after I stop moving it, but after a few seconds the window stops updating.

Code: [Select]

#include <SFML/Graphics.hpp>
 
 int main()
 {
     sf::RenderWindow App(sf::VideoMode(800, 600), "SFML window");

     sf::Image Image;
     Image.LoadFromFile("data/circle.png");
     sf::Sprite Sprite(Image);

     while (App.IsOpened())
     {
         sf::Event event;
         while (App.GetEvent(event))
         {
             if (event.Type == sf::Event::Closed)
                 App.Close();
         }

         sprite.Move(20 * App.GetFrameTime(), 0);
 
         // Clear screen
         App.Clear();
 
         App.Draw(sprite);
 
         // Update the window
         App.Display();
     }
 
     return 0;
 }

4
General / Game won't start anymore
« on: December 14, 2010, 08:20:26 pm »
Hello, I've a bit of a problem here, I continued working on my game and all of a sudden it won't start any more  :shock:. When I click the .exe it does nothing for about 5 seconds and then a console window pops up which doesn't close directly when you try to. It works on the computer of a friend of mine so it's not in the code.

I know it's not a lot of information but is there anything I might have changed in my computer that can cause this?

5
Window / Disabling the CMD window that opens when creating a window
« on: December 06, 2010, 07:28:47 pm »
Sorry if this is already discussed but I couldn't find it.

Every time I create a RenderWindow it also opens a CMD window. When distributing my game I don't want it to open. I'm sure there is a very simple solution for this but I have not found it yet.

6
Window / Linker cannot resolve OpenGL functions
« on: November 06, 2010, 06:03:10 pm »
Hello, I tried compiling the tutorial which uses OpenGL to draw a cube on the screen. However I'm getting a bunch of linker errors which probably indicate that it can't find the OpenGL functions. I thought OpenGL was included by SFML/Window.hpp?
What am I doing wrong  :x .

The errors:
1>Main.obj : error LNK2001: unresolved external symbol __imp__glClearDepth@8
1>Main.obj : error LNK2001: unresolved external symbol __imp__glClear@4
1>Main.obj : error LNK2001: unresolved external symbol __imp__glClearColor@16
1>Main.obj : error LNK2001: unresolved external symbol __imp__glEnd@0
1>Main.obj : error LNK2001: unresolved external symbol __imp__glBegin@4
1>Main.obj : error LNK2001: unresolved external symbol __imp__glDepthMask@4
1>Main.obj : error LNK2001: unresolved external symbol __imp__glRotatef@16
1>Main.obj : error LNK2001: unresolved external symbol __imp__glVertex3f@12
1>Main.obj : error LNK2001: unresolved external symbol __imp__glMatrixMode@4
1>Main.obj : error LNK2001: unresolved external symbol __imp__glViewport@16
1>Main.obj : error LNK2001: unresolved external symbol __imp__glTranslatef@12
1>Main.obj : error LNK2001: unresolved external symbol __imp__glEnable@4
1>Main.obj : error LNK2001: unresolved external symbol __imp__glLoadIdentity@0

Pages: [1]
anything