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

Pages: 1 [2] 3
16
System / Threads inside classes
« on: December 10, 2011, 06:04:15 pm »
Im trying to integrate a thread into the image loading class, but im getting errors
using this code

Code: [Select]


class TextureResourceManager
{void LoadFiles();
    sf::Thread imgThread;
};

TextureResourceManager::TextureResourceManager():
imgThread(&TextureResourceManager::LoadFiles)
{

}


gives me:
Quote

||=== Agame, Debug ===|
/usr/local/include/SFML/System/Thread.inl||In member function ‘void sf::priv::ThreadFunctor<T>::Run() [with T = void (TextureResourceManager::*)()]’:|
/home/richy/codeblocks/Agame/src/TextureResourceManager.cpp:73|1|instantiated from here|
/usr/local/include/SFML/System/Thread.inl|39|error: must use ‘.*’ or ‘->*’ to call pointer-to-member function in ‘((sf::priv::ThreadFunctor<void (TextureResourceManager::*)()>*)this)->sf::priv::ThreadFunctor<void (TextureResourceManager::*)()>::myFunctor (...)’, e.g. ‘(... ->* ((sf::priv::ThreadFunctor<void (TextureResourceManager::*)()>*)this)->sf::priv::ThreadFunctor<void (TextureResourceManager::*)()>::myFunctor) (...)’|
||=== Build finished: 1 errors, 0 warnings ===|


17
General / Linux failed to build SFML
« on: November 21, 2011, 02:40:42 am »
Runing make I get the following error:

Quote
/home/richy/Desktop/LaurentGomila-SFML-ac16c85/src/SFML/Network/Unix/SocketImpl.cpp:39:13: error: prototype for ‘sockaddr_in sf::priv::SocketImpl::CreateAddress(sf::Uint32, short unsigned int)’ does not match any in class ‘sf::priv::SocketImpl’
/home/richy/Desktop/LaurentGomila-SFML-ac16c85/src/SFML/Network/Unix/SocketImpl.hpp:68:24: error: candidate is: static sockaddr_in sf::priv::SocketImpl::CreateAddress(long unsigned int, short unsigned int)
make[2]: *** [src/SFML/Network/CMakeFiles/sfml-network.dir/Unix/SocketImpl.cpp.o] Error 1
make[1]: *** [src/SFML/Network/CMakeFiles/sfml-network.dir/all] Error 2
make: *** [all] Error 2

18
Graphics / sf::Texture and OpenGL
« on: November 18, 2011, 03:38:10 am »
trying to use SFML to load images and to use with OpenGL textures, but when I draw the quad its just black.
I know the UV is right so im pretty sure its the texture its self.

The main problem is im not sure how I should be using sf::Texture in an openGL way

Code: [Select]

#include "./3dSprite.hpp"

#include "./Engine.hpp"


d3Sprite::d3Sprite(Engine *mEngine)
{
engine = mEngine;
shader = new Shader("./Data/vert.vert" ,"./Data/frag.frag");

UVList[0] = 1.0f;
UVList[1] = 1.0f;

UVList[2] = 0.0f;
UVList[3] = 1.0f;

UVList[4] = 0.0f;
UVList[5] = 0.0f;

UVList[6] = 1.0f;
UVList[7] = 1.0f;

UVList[8] = 0.0f;
UVList[9] = 0.0f;

UVList[10] = 1.0f;
UVList[11] = 0.0f;

vertexList[0] = 0.5f;
vertexList[1] = 1.0f;
vertexList[2] = 0.0f;

vertexList[3] = -0.5f;
vertexList[4] = 1.0f;
vertexList[5] = 0.0f;

vertexList[6] = -0.5f;
vertexList[7] = 0.0f;
vertexList[8] = 0.0f;

vertexList[9] = 0.5f;
vertexList[10] = 1.0f;
vertexList[11] = 0.0f;

vertexList[12] = -0.5f;
vertexList[13] = 0.0f;
vertexList[14] = 0.0f;

vertexList[15] = 0.5f;
vertexList[16] = 0.0f;
vertexList[17] = 0.0f;
 
// Generate 1 buffer, put the resulting identifier in vertexbuffer
glGenBuffers(1, &vertexbuffer);
 
// The following commands will talk about our 'vertexbuffer' buffer
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
 
// Give our vertices to OpenGL.
glBufferData(GL_ARRAY_BUFFER, sizeof(vertexList), vertexList, GL_STATIC_DRAW);

MatrixID = glGetUniformLocation(shader->shaderID, "MVP");
    positionID = glGetAttribLocation(shader->shaderID, "Position");
TextureID  = glGetUniformLocation(shader->shaderID, "myTexture");
UVID = glGetAttribLocation(shader->shaderID, "UV");

//std::cout << MatrixID << ":" << positionID << ":" << TextureID << ":" << UVID << std::endl;
//TextureID prints out 65526 for some reason


glGenBuffers(1, &uvbuffer);
    glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
    glBufferData(GL_ARRAY_BUFFER, sizeof(UVList), UVList, GL_STATIC_DRAW);



glGenTextures(1, &texturebuffer);
 
// "Bind" the newly created texture : all future texture functions will modify this texture
glBindTexture(GL_TEXTURE_2D, texturebuffer);
 
// Give the image to OpenGL
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").GetWidth(), TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").GetHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE,TextureResourceManager::textureResourceManager.getFile("./Data/Pedro.png").CopyToImage().GetPixelsPtr() );
 
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);


}

d3Sprite::~d3Sprite()
{
// Cleanup VBO and shader
    glDeleteBuffers(1, &vertexbuffer);
    glDeleteBuffers(1, &uvbuffer);
glDeleteTextures(1, &texturebuffer);
delete shader;
}

void d3Sprite::Initiate(glm::mat4 *persMat, glm::mat4 *camMat)
{


*camMat =  glm::lookAt(
glm::vec3( 0, 0, 5 ),           // Camera is here  glm::vec3( 0, 0, 5 );
glm::vec3( 0, 0, 0 ), // and looks here : at the same position, plus "direction"
glm::vec3( 0, 1, 0 )                 // Head is up (set to 0,-1,0 to look upside-down)
);


Drawable::Initiate(persMat, camMat);
}

void d3Sprite::Update(float deltaTime)
{
Drawable::Update();
}

void d3Sprite::Draw()
{

glUseProgram(shader->shaderID);

glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);

glActiveTexture(GL_TEXTURE0);
    glBindTexture(GL_TEXTURE_2D, texturebuffer);
    glUniform1i(TextureID, 0);

// 1rst attribute buffer : vertices
    glEnableVertexAttribArray(positionID);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
  positionID,                  // attribute 0. No particular reason for 0, but must match the layout in the shader.
  3,                  // size
  GL_FLOAT,           // type
  GL_FALSE,           // normalized?
  0,                  // stride
  (void*)0            // array buffer offset
);
 

// 2nd attribute buffer : UVs
                glEnableVertexAttribArray(UVID);
                glBindBuffer(GL_ARRAY_BUFFER, uvbuffer);
                glVertexAttribPointer(
                        UVID,                                // attribute. No particular reason for 1, but must match the layout in the shader.
                        2,                                // size : U+V => 2
                        GL_FLOAT,                         // type
                        GL_FALSE,                         // normalized?
                        0,                                // stride
                        (void*)0                          // array buffer offset
                );

// Send our transformation to the currently bound shader,
// in the "MVP" uniform
// For each model you render, since the MVP will be different (at least the M part)
    // Draw the triangle !
    glDrawArrays(GL_TRIANGLES, 0, 6); // Starting from vertex 0; 3 vertices total -> 1 triangle

glDisableVertexAttribArray(UVID);
    glDisableVertexAttribArray(positionID);


}

19
Graphics / GL_INVALID_VALUE, when using SaveGLStates
« on: November 17, 2011, 07:17:32 pm »
Im using SFML 2.0 and im trying to use pure OpenGL with SFML stuff
however when I draw stuff and then use SaveGLStatess I get an error:
Quote

An internal OpenGL call failed in Renderer.cpp (77) : GL_INVALID_VALUE, a numeric argument is out of range


Renderer.cpp 77 is(first line in SaveGLStates):

Code: [Select]
GLCheck(glPushAttrib(GL_ALL_ATTRIB_BITS));

The last thing I do before calling saveStates is:

Code: [Select]
void d3Sprite::Draw()
{

    glEnableVertexAttribArray(positionID);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer);
glVertexAttribPointer(
  positionID,                  
  3,                  // size
  GL_FLOAT,           // type
  GL_FALSE,           // normalized?
  0,                  // stride
  (void*)0            // array buffer offset
);
 
glUseProgram(shader.shaderID);

    glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
// Draw the triangle !
    glDrawArrays(GL_TRIANGLES, 0, 6); // Starting from vertex 0; 6 vertices total -> 2 triangles

    glDisableVertexAttribArray(positionID);

}

20
Graphics / Green lines around text
« on: November 05, 2011, 11:29:36 pm »
Using the sf::Text I am getting weird lines around the text, this happens when I use big font sizes



I tried setting it to a small size and then scaling it but it just makes the text fuzzy and there is no option to set smoothing on.


21
Graphics / sf::Image heap corruption
« on: November 05, 2011, 01:57:45 pm »
Hi, I seem to have developed a problem, when closing my app I get a heap corruption error from the Image destructor.
I remember seeing that this was a fault some time ago but I thought it was fixed.
I also read that it could be an error due to me having intel graphics.
It happens with both the 1.6 version and 2.0

The program im using is quite complex but I will try and recreate the error in a simple app

22
Feature requests / Switching styles on the go
« on: September 30, 2011, 04:03:44 am »
Would it be bossible to alow switching th window style (from windowed to fullscreen) without having to recreate the window and thus without loosing the openGL context?

Also allowing to resize the context/

23
General / Getting mouse wheel value
« on: September 28, 2011, 03:11:16 pm »
Hi, i was wondering if SFML gives you the ability to access the mouse wheel value?

24
General / trying to convert Spark to SFML 2
« on: September 19, 2011, 08:12:21 pm »
Im trying to compile spark using SFML 2, I think i have fixed most issues but I am stuck on this:

Quote

Error   1   error C2259: 'SPK::SFML::SFMLSystem' : cannot instantiate abstract class   C:\Documents and Settings\Richy\My Documents\spark\include\RenderingAPIs\SFML\SPK_SFMLSystem.h   63   1   SPARK Engine SFML LIB
Error   2   error C2259: 'SPK::SFML::SFMLSystem' : cannot instantiate abstract class   C:\Documents and Settings\Richy\My Documents\spark\include\RenderingAPIs\SFML\SPK_SFMLSystem.h   142   1   SPARK Engine SFML LIB
Error   3   error C2259: 'SPK::SFML::SFMLSystem' : cannot instantiate abstract class   C:\Documents and Settings\Richy\My Documents\spark\include\RenderingAPIs\SFML\SPK_SFMLSystem.h   63   1   SPARK Engine SFML DLL
Error   4   error C2259: 'SPK::SFML::SFMLSystem' : cannot instantiate abstract class   C:\Documents and Settings\Richy\My Documents\spark\include\RenderingAPIs\SFML\SPK_SFMLSystem.h   142   1   SPARK Engine SFML DLL



on this file
https://sparkengine.svn.sourceforge.net/svnroot/sparkengine/trunk/include/RenderingAPIs/SFML/SPK_SFMLSystem.h

Wasnt really sure if this is best here or in the Spark forum but I thought you would maybe know

25
DotNet / Playing video in SFML.Net
« on: September 15, 2011, 07:26:03 pm »
With the C++ version you can use one of the extra "plugins" made for SFML, but i wanted to know how you would do this with SFML.Net

26
System / Using threads to load stuff
« on: September 07, 2011, 08:49:42 pm »
I want to use a thread to load all the assets and while this is happening animate a loading screen.

The way I thoughht I would do it is:

Code: [Select]

void loadFiles()
{
    ...
}

sf::Thread loadingThread( &loadFiles);
loadingThread.Launch();

while(loadingThread.isRunning)
{
    Animate and draw loading screen
}


The problem is that there is no way to find out if the thread is still running, it there any way to do this?

27
SFML website / Finishing github tutorials
« on: September 05, 2011, 01:23:48 pm »
Hi, just wanted to know if there are any plans to finish the tutorials on github

mainly the
Loading images in a thread (and displaying progress)
and
Stock all your resources in a single DAT file

28
Graphics / Game crashes on Display
« on: September 01, 2011, 05:54:48 pm »
So after the last thread in which I was having an error with openGL I have starte to use just SFML and 2D
But now its breaking with this.

I have
Code: [Select]

std::cout << "draw sfml" << loop << std::endl;
            Game::DrawSFML();
std::cout << "display" << loop << std::endl;
            // Display window contents on screen
            App.Display();
            std::cout << "end" << loop << std::endl;

            loop++;


which gives

sqwitch0
menu0
draw sfml0
display0
[richy@fedoraLt Release]$

Im going to look through the SFMl source and my code to check if i have maybe created the window incorrectly

29
Window / Hoow do I set the position/other stuff before creation?
« on: August 30, 2011, 05:53:48 pm »
Basically I currently use

Code: [Select]
Game::isOpenGLSetup = Game::setupOpenGL();
    App.SetFramerateLimit(GlobalSettings::globalSettings.getFrameRateLimit() );
    App.ShowMouseCursor(false);

    sf::VideoMode desktopVM = sf::VideoMode::GetDesktopMode();
    App.SetPosition( (desktopVM.Width/2.0) - (App.GetWidth()/2.0) , (desktopVM.Height/2.0) - (App.GetHeight()/2.0)  );

    smView = sf::Vector2i(800,600 );
    winView = sf::Vector2i(GlobalSettings::globalSettings.getWinWidth() , GlobalSettings::globalSettings.getWinHeight() );

    App.Show(true);


Where App.create... gets called in setupOpenGL() but this means that the window shows and then after moves looking a bit ugly.
But if I set it before create then it doesnt do anything.
Im not sure if calling create resets all the values or something

30
Feature requests / Drawable have depth value
« on: August 30, 2011, 05:41:05 pm »
Allow any drawable class to have a depth value that way you only need to change 1 value to change what order to draw stuff, instead of having to change the order of all elements

Pages: 1 [2] 3
anything