HermanssoN

Member
  • Content count

    78
  • Joined

  • Last visited

Community Reputation

148 Neutral

About HermanssoN

  • Rank
    Member
  1. Released my game - Letter Hunt

    Updated all the texturex, also added a menu. Got rid of all the "normal" activities.
  2. I made a fun little game with AndEngine, available (free) at the play store. Suitable for the whole family.   Hit the moving targets by tapping the display. Each target contains a letter, the goal is to hit letters that belongs to a given word and avoid those who do not. The targets will move faster if you score high enough. Good Luck! https://play.google.com/store/apps/details?id=com.hermansson.LetterHunt
  3. Problems with storing fractions in variables

    Hi. If you write this:   float number = 1/4; We know that 1/4 = 0.25, but we if use integers when dividing the reuslt will also be an integer. Integers can not hold decimal number, so it will round it to a whole number. e.g 0. If you type:   float number = 1.0f / 4.0f; now the operation will return a decimal number. to sum it up:   float f1 = 1/4; // f1 is now 0 float f2 = 1.0f/4.0f; //f2 is now 0.25
  4. std::vector and glUniformMatrix4fv

    Well, my problem might have been with glsl, not the glUniformMatrix4fv. I filled my matrix array with the identity matrix and sent all 40 of them to the shader. Since all matrices where the same I only used one, e.g g_skeleton[0]; The shader will now optimize away unused variables, e.g g_skeleton[1]->g_skeleton[MAX]. I did not realize this, I figured that if I used the g_skeleton variable all the uniforms world be "safe".   So when I sent my 40 matrices I overwrote my world, view and projection matrix. (this is my guess) This code will not cause the shader to optimize away g_skeleton[1]->g_skeleton[MAX] since I use a variable as index. position += (g_skeleton[index] * weight) * in_position   This code will: position += (g_skeleton[0] * weight) * in_position   I used my original code:   void Shader::setMatrixArray(std::string name, std::vector<glm::mat4>matrices) { glUniformMatrix4fv(m_uniformLocation[name], matrices.size(), GL_FALSE,(float*)&matrices[0]); Helper::logError("failed to set matrix array"); } And I seems to work just fine. Thank you for your help. Hope this post will help other to not do the same mistake. I am not particularly fond of this optimizing away functionality, for debugging purposes one might want to be able to  simply comment out the usage of one particular variable, and then everything might stop working.
  5. std::vector and glUniformMatrix4fv

    Yes, as I did in my first post.   void Shader::setMatrixArray(std::string name, std::vector<glm::mat4>matrices) { glUniformMatrix4fv(m_uniformLocation[name], matrices.size(), GL_FALSE,(float*)&matrices[0]); Helper::logError("failed to set matrix array"); } My inital quastion was if this way of doing it was valid.  
  6. std::vector and glUniformMatrix4fv

    I found a solution: Map the whole thing: bool Shader::addMatrixArray(std::string name, int size) { /* should not happen*/ assert(name.size() < 128); std::map<std::string,int> locations; for(int i = 0; i<size; i++) { char n[128]; sprintf_s(n, "%s[%d]", name.c_str(),i); int location = glGetUniformLocation(m_program,n); Helper::logError("Shader::addMatrixArray() failed"); locations[n] = location; } m_uniformArrays[name] = locations; //map that contans a map indexed by name :) return true; }   And setting the matrix array: void Shader::setMatrixArray(std::string name, std::vector<glm::mat4>matrices) { UniformMap map = m_uniformArrays[name]; int size = matrices.size(); int index = 0; UniformMap::iterator it = map.begin(); while(it != map.end() && index != size) { int location = (*it).second; glUniformMatrix4fv(location, 1, GL_FALSE,glm::value_ptr(matrices[index])); Helper::logError("failed to set matrix array"); index ++; it ++; } } If anyone knows a way to just uppload all tre matrices at once, pleas tell me This seems to work for now.  
  7. You migh have better luck if you post this in the "open gl" forum, or the "graphics programming and theory" forum. This is beyond the beginner level  :P
  8. SDL Regulating frame rate

    GetTicks is the amount of millliseconds since the program started. if you in your update loop save the delta int time = GetTicks(); int delta = time - lastTime; lastTime = time; //last time is a variable that you save //move something 15 units per second in x float deltaSeconds = 0.01f * delta; //ms to sec myObject.x += 15 * deltaSeconds ; If you hve low fps delta time will be high, if the fps is high delta time will be low. Using delta time means the the the movent of myObject will be frame rate independatant.
  9. Hello. I am trying to uppload an array of matrices to my glsl shader. I don't think my way of doing it is the correc way:   void Shader::setMatrixArray(std::string name, std::vector<glm::mat4>matrices) { glUniformMatrix4fv(m_uniformLocation[name], matrices.size(), GL_FALSE,(float*)&matrices[0]); Helper::logError("failed to set matrix array"); } if I check my list of uniform locations using a break point i noticed that, the g_skeleton (the matrix array) varible has the same location as my projection matrix:     Is this normal?   They are declared like this in my vertex shader: #version 330 #define MAX_BONE_COUNT 40 uniform mat4 g_view; uniform mat4 g_projection; uniform mat4 g_world; uniform mat4 g_skeleton[MAX_BONE_COUNT]; etc....   And just to be thorugh, this is how i save my uniforms: bool Shader::addUniformVariable(std::string name) { int location = glGetUniformLocation(m_program, name.c_str()); Helper::logError("Shader::addUniformVariable() failed"); if(location == -1) { return false; } m_uniformLocation[name] = location; return true; } If I dont use the matrix array evrything works just fine.
  10. Ah, my bad. I was running it as a console proram. When closing the console by clicking on the 'X' button rather than pressing enter to exit program like the console asks you to do you get that error. I changed to GUI application now, it work's fine.
  11. Hi. I got the exit message: Process terminated with status -1073741510 in code::blocks. Didn't like tone of that message, so I created a SDL project with the wizard the commes with code::blocks, SDL being the API I'm using. The same exit message occurred. I ran the sample code that's autogenrated. Can I ignore that? I't does not acctually say error. I'm using GNU GCC and will be using C, not C++.
  12. C programming segmention fault

    I tried this: [code] int geModelLoad( const char* pFilename, geModel** pModel ) { *pModel = malloc( sizeof(geModel)); } [/code] and [code] int main( int argc, char *argv[] ) { geModel* pModel; geModelLoad( "player.md5mesh", &pModel); } [/code] But this time i got the same error already in geModelLoad when performing malloc what bother me most is that I could do this: [code] int geModelLoad( const char* pFilename, geModel* pModel ) { pModel = malloc( sizeof(geModel)); pModel->meshCount = 4; //NO ERROR!!! return 1; } [/code] how ever, I solved my problem by doing it like this: [code] int main( int argc, char *argv[] ) { geModel model; geModelLoad( "player.md5mesh", &model); int mc = model.meshCount; return 0; } [/code] and the library function [code] int geModelLoad( const char* pFilename, geModel* pModel ) { pModel = malloc( sizeof(geModel)); //lots of loading code.... return geTrue; } [/code] Why can't I send a pointer straight away, like my first atempt?? I't would have worked in C++, is it because of the new keyword and the fact that C is not object oriented? e.g it would only work with a class?
  13. Hi. I'm trying to learn C programming because it's the language we will use for a school project. this is what I am trying to do: I have a library I made with code::blocks, it's for loading a MD5 meshes. Does nothing else, SDL is how ever included for later use. The only function I use is: [code] int geModelLoad( const char* pFilename, geModel* pModel ) { // bunch of loading code, initializes pModel //prints information about meshes, vertices etc to the console, this works fine printModel( pModel ); return geTrue; } [/code] In my other project, where my library is linked, I load a model like this: [code] #include<SDL/SDL.h> #include "geModel.h" int main( int argc, char *argv[] ) { geModel* pModel; geModelLoad( "player.md5mesh", pModel); int mc = pModel->meshCount; <-- ERROR! geModelDebugPrint( pModel ); if( pModel != NULL) { geModelDestroy(pModel); } return 0; } [/code] Once the program has left the "geModelLoad" function I can't use anything in my model struct without geting segmention fault. I'm new to C programming, so I suspect that I need to set some compiler settings. I'm using: IDE: Code::Blocks (mingw installed) compiler: GNU GCC compiler linker options: -lmingw32 -lSDLmain -lSDL -mwindows I have no idea what's causing the error. If I do this I get no errors: [code] int main( int argc, char *argv[] ) { geModel m; m.meshCount = 3; return 0; } [/code]
  14. Up to date math book :)

    Thank's
  15. Up to date math book :)

    Hi. I've seen this book : http://www.amazon.com/Primer-Graphics-Development-Wordware-Library/dp/1556229119 It includes a lot of things beyond the math, like visibilty determination etc. How ever it's from 2002. Is there a similar book out there that is closer to 2010? I know that math is up to date in most books anyways, but there are maybe some tecniques that been added or improved since 2002.