1. Post #1521
    sim642's Avatar
    July 2010
    1,039 Posts
    I've used TortoiseGit for using git on Windows. Unfortunately it has no portable version that i could put on a USB drive. Is there a portable program for using git on Windows?
    Reply With Quote Edit / Delete Windows Vista Estonia Show Events

  2. Post #1522
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,717 Posts
    I've used TortoiseGit for using git on Windows. Unfortunately it has no portable version that i could put on a USB drive. Is there a portable program for using git on Windows?
    You can install Linux on the usb drive, then boot up into Linux whenever you need git.

    I'm actually pretty serious; I was sick of dealing with school computers so I just bring my own OS to develop in on them. It feels nice knowing all of your work is saved on git as well as in your pocket, leaving the host computer untouched.
    Reply With Quote Edit / Delete Linux United States Show Events

  3. Post #1523
    sim642's Avatar
    July 2010
    1,039 Posts
    I've used TortoiseGit for using git on Windows. Unfortunately it has no portable version that i could put on a USB drive. Is there a portable program for using git on Windows?
    I found out that GitForWindows has a portable version so I'm going to use that currently.
    Reply With Quote Edit / Delete Windows Vista Estonia Show Events Friendly Friendly x 1 (list)

  4. Post #1524
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,717 Posts
    I found out that GitForWindows has a portable version so I'm going to use that currently.
    I guess someone is not feeling adventurous today. :(
    Reply With Quote Edit / Delete Linux United States Show Events Friendly Friendly x 1 (list)

  5. Post #1525
    Richy19's Avatar
    May 2010
    5,394 Posts
    When building the model matrix, what is the correct order to do the rotation, scaling, translation?
    Also if I what to rotate 2 axis by different degrees in glm I need to perform 2 different rotations, does it matter what order I rotate them?
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Dumb Dumb x 1 (list)

  6. Post #1526
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,717 Posts
    When building the model matrix, what is the correct order to do the rotation, scaling, translation?
    Also if I what to rotate 2 axis by different degrees in glm I need to perform 2 different rotations, does it matter what order I rotate them?
    My matrices are generated like this:
    Code:
    glm::mat4 Pos = glm::translate(glm::mat4(),Position);
    glm::mat4 Ang = glm::rotate(glm::mat4(),Angle.z,glm::vec3(0,0,1));
    Ang = glm::rotate(Ang,Angle.y,glm::vec3(0,1,0));
    Ang = glm::rotate(Ang,Angle.x,glm::vec3(1,0,0));
    glm::mat4 Sca = glm::scale(glm::mat4(),Scale);
    Matrix = Pos*Ang*Sca;
    Reply With Quote Edit / Delete Linux United States Show Events

  7. Post #1527
    Gold Member
    Lord Ned's Avatar
    April 2006
    3,702 Posts
    When building the model matrix, what is the correct order to do the rotation, scaling, translation?
    Also if I what to rotate 2 axis by different degrees in glm I need to perform 2 different rotations, does it matter what order I rotate them?
    It depends on if you're using row-major or column-major. Whatever it is in DirectX (D3DXMATRIX) is backwards from whatever it is in OpenGL/GLM (glm::mat4)
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  8. Post #1528
    Richy19's Avatar
    May 2010
    5,394 Posts
    It depends on if you're using row-major or column-major. Whatever it is in DirectX (D3DXMATRIX) is backwards from whatever it is in OpenGL/GLM (glm::mat4)
    How do you mean? I know GLM mat4 are mat4[column numb][row numb]
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Dumb Dumb x 1 (list)

  9. Post #1529
    Gold Member
    Lord Ned's Avatar
    April 2006
    3,702 Posts
    How do you mean? I know GLM mat4 are mat4[column numb][row numb]
    With GLM it's: Translation * Rotation * Scale
    With DirectX: Scale * Rotation * Translation

    In the shader, on DirectX:
    output.Position = mul(float4(input.Position, 1), gWorldMatrix);
    output.Position = mul(output.Position, gProjViewMatrix);

    It may be a different order on OpenGL (multiply by ProjView first, then World)
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  10. Post #1530
    Richy19's Avatar
    May 2010
    5,394 Posts
    With GLM it's: Translation * Rotation * Scale
    With DirectX: Scale * Rotation * Translation

    In the shader, on DirectX:
    output.Position = mul(float4(input.Position, 1), gWorldMatrix);
    output.Position = mul(output.Position, gProjViewMatrix);

    It may be a different order on OpenGL (multiply by ProjView first, then World)
    Yea glsl is: gl_Position = MVP * vec4(Position, 1.0f);

    Edited:

    Thanks for clearing up the Model matrix stuff :)
    Reply With Quote Edit / Delete Linux United Kingdom Show Events Dumb Dumb x 1 (list)

  11. Post #1531
    Gold Member
    esalaka's Avatar
    July 2007
    10,191 Posts
    I guess someone is not feeling adventurous today. :(
    You clearly have not used Git for Windows
    Reply With Quote Edit / Delete Linux Finland Show Events Funny Funny x 2Zing Zing x 1 (list)

  12. Post #1532
    Jimmylaw's Avatar
    November 2007
    506 Posts
    Trying to create a method that returns an array but its just not being as easy as I want it too. I tired googling this problem but none seem to fit my situation.

    Entity * GameObjectManager::getInt(Entity::entityName name)
    {
    	std::map<int, Entity*>::const_iterator results = _gameObjects.begin();
    	static Entity * r[10];
    	int index = 0;
    
    	if(results->second->name == name)
    	{
    		r[index] = results->second;
    		index++;
    	}
    
    	return r;
    }
    
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  13. Post #1533
    Gold Member
    esalaka's Avatar
    July 2007
    10,191 Posts
    Return a vector.
    Reply With Quote Edit / Delete Linux Finland Show Events

  14. Post #1534
    Jimmylaw's Avatar
    November 2007
    506 Posts
    Return a vector.
    This has to be a super hacky way of doing this but I cannot think of any other way to do this.

    std::map<int, Entity*>  GameObjectManager::getGroup(Entity::entityName name)
    {
    	std::map<int, Entity*>::const_iterator itr = _gameObjects.begin();
    	std::map<int, Entity*> temp;
    
    
    	while(itr != _gameObjects.end())
    	{
    		if(itr->second->name == name)
    		{
    			temp.insert(std::pair<int,Entity*>(itr->second->getID(),itr->second));
    		}
    		itr++;
    	}
    
    
    	return temp;
    
    
    	std::for_each(temp.begin(),temp.end(),GameObjectDeallocator());
    }
    

    	std::map<int, Entity*> tempArray = Main::GetGameObjectManager().getGroup(Entity::entityName::entityBullet);
    
    
    	std::map<int, Entity*>::const_iterator itr = tempArray.begin();
    	
    	while(itr != tempArray.end())
    	{
    		if(itr->second->GetBoundingRect().intersects(GetBoundingRect()))
    		{
    			SetPosition(0,0);
    			Main::GetGameObjectManager().Remove(itr->second->getID());
    		}
    		itr++;
    	}
    
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  15. Post #1535
    Gold Member
    Z_guy's Avatar
    July 2005
    594 Posts
    This has to be a super hacky way of doing this but I cannot think of any other way to do this.

    std::map<int, Entity*>  GameObjectManager::getGroup(Entity::entityName name)
    {
    	std::map<int, Entity*>::const_iterator itr = _gameObjects.begin();
    	std::map<int, Entity*> temp;
    
    
    	while(itr != _gameObjects.end())
    	{
    		if(itr->second->name == name)
    		{
    			temp.insert(std::pair<int,Entity*>(itr->second->getID(),itr->second));
    		}
    		itr++;
    	}
    
    
    	return temp;
    
    
    	std::for_each(temp.begin(),temp.end(),GameObjectDeallocator());
    }
    

    	std::map<int, Entity*> tempArray = Main::GetGameObjectManager().getGroup(Entity::entityName::entityBullet);
    
    
    	std::map<int, Entity*>::const_iterator itr = tempArray.begin();
    	
    	while(itr != tempArray.end())
    	{
    		if(itr->second->GetBoundingRect().intersects(GetBoundingRect()))
    		{
    			SetPosition(0,0);
    			Main::GetGameObjectManager().Remove(itr->second->getID());
    		}
    		itr++;
    	}
    
    Give it a reference instead to avoid copying the std::map.

    void GameObjectManager::getGroup(Entity::entityName name, std::map<int, Entity*> &list)
    {
    	list.clear();
    
    	std::map<int, Entity*>::const_iterator itr = _gameObjects.begin();
    
    	while(itr != _gameObjects.end())
    	{
    		if(itr->second->name == name)
    		{
    			list.insert(std::pair<int,Entity*>(itr->second->getID(),itr->second));
    		}
    		itr++;
    	}
    
    	std::for_each(list.begin(),list.end(),GameObjectDeallocator());
    }
    

    	std::map<int, Entity*> tempArray;
    	Main::GetGameObjectManager().getGroup(Entity::entityName::entityBullet, tempArray);
    
    
    	std::map<int, Entity*>::const_iterator itr = tempArray.begin();
    	
    	while(itr != tempArray.end())
    	{
    		if(itr->second->GetBoundingRect().intersects(GetBoundingRect()))
    		{
    			SetPosition(0,0);
    			Main::GetGameObjectManager().Remove(itr->second->getID());
    		}
    		itr++;
    	}
    
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  16. Post #1536
    Jimmylaw's Avatar
    November 2007
    506 Posts
    Give it a reference instead to avoid copying the std::map.
    Either I'm being slow or I just don't understand this but how does the updated "tempArray" get passed back from getGroup method to the function that wants it? Or it is because your passing it a pointer and not an object?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  17. Post #1537
    Gold Member
    Z_guy's Avatar
    July 2005
    594 Posts
    Either I'm being slow or I just don't understand this but how does the updated "tempArray" get passed back from getGroup method to the function that wants it? Or it is because your passing it a pointer and not an object?
    std::map<int, Entity*> &list
    Notice the &-sign? That means you're passing in a reference, which works kind of like a pointer.
    It means you're passing in the actual object instead of a copy of it.
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  18. Post #1538
    I hide under your bed
    Dennab
    July 2011
    1,877 Posts
    So i am mucking around with the Farseer Physics Engine. I'm running into issues loading content with Debug View.

    Code:
    DebugView.LoadContent(ScreenManager.GraphicsDevice, ScreenManager.Content);
    When this code is run, i get "Error loading "font". File not found."

    How should i fix this? I assume that ScreenManager.Content is empty or something and it's attempting to load a font that doesn't exist or something.
    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  19. Post #1539
    false prophet's Avatar
    October 2011
    954 Posts
    This sort of thing is a bit beyond my understand right now, but basically I am doing some bit twiddling. However, I am not sure if my pack function is correct, it seems to work properly but I am just not sure and would like insight from a more experienced programmer.

    http://pastebin.com/v1dsdWnH

    Also, I am aware that the function names are poop.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  20. Post #1540
    Gold Member

    March 2005
    3,028 Posts
    It looks fine to me.
    Reply With Quote Edit / Delete Windows 7 Show Events

  21. Post #1541
    Gold Member
    Armandur's Avatar
    March 2009
    666 Posts
    I've been programming for quite some time now (five courses in 2.5 years, one introductory course taught in C++ which I finished during my first year, in a week. I had two C++ and two Java courses during my second and third year), with excellent grades. I know much of learning to program is to just practice and experiment by yourself, and that I have done, but I feel like I'm not advancing any more in C++.

    I have a good grasp of classes and pointers in C++ and I've been doing some 2d work in SDL and SFML. I've started nosing about with templates in C++ but I haven't found anything interesting to use them with, yet (finding them quite hard to understand right now, actually) Suggestions? and what should I try to focus on doing after that?
    Reply With Quote Edit / Delete Windows 7 Sweden Show Events

  22. Post #1542
    Gold Member
    PortalGod's Avatar
    August 2009
    2,300 Posts
    so I'm trying to find a method to optimize drawing with rectangles, using the least amount of rects possible. I got it to check horizontally:



    but no matter how hard I try, I can't get it to check vertically as well. The code is really ugly, but the logical steps behind how I did it are like this:

    Code:
    at pixel (x, y)
    	check horizontally
    	if the colors are the same
    		repeat at (x + 1, y)
    	else
    		check downwards for the whole rectangle
    		if all the colors are the same
    			repeat at (x, y + 1)
    		else
    			back up, store the rectangle
    		end
    	end
    end
    I don't even know if the rectangles are just getting overlapped, because LOVE sucks with debugging

    is there a better way to do this? or an example I can look at?
    Reply With Quote Edit / Delete Windows 7 United States Show Events Artistic Artistic x 1 (list)

  23. Post #1543
    D33Jay's Avatar
    January 2012
    63 Posts
    I've been stuck with this for a while, I'm hoping that WDYNHW will be my savior.

    I've been trying to make a 2D platformer forever, one similar to SMB or Megaman. I know how to draw everything and get moving, but how would I make it so if it collided with a certain area (such as a wall) it would stop jumping, stop moving, or whatever. I can't figure this one out.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  24. Post #1544
    Gold Member
    WTF Nuke's Avatar
    March 2009
    4,465 Posts
    How do big devs handle things like entity systems? I know they are usually component based and before I start writing code I want to plan this out, lest I get awful and incomprehensible code that I just don't want to deal with. Like what does gamebryo do?
    Reply With Quote Edit / Delete Canada Show Events

  25. Post #1545
    T3hGamerDK's Avatar
    January 2011
    2,551 Posts
    How do big devs handle things like entity systems? I know they are usually component based and before I start writing code I want to plan this out, lest I get awful and incomprehensible code that I just don't want to deal with. Like what does gamebryo do?
    This one is actually really easy on yourself, considering things with the source engine.
    Just get the source code for modding, and look at the entity cpp and header files.
    Reply With Quote Edit / Delete Linux Denmark Show Events

  26. Post #1546
    Gold Member

    March 2005
    3,028 Posts
    Like what does gamebryo do?
    Nothing that you want to replicate.
    Reply With Quote Edit / Delete Windows 7 Show Events Agree Agree x 6Funny Funny x 1 (list)

  27. Post #1547
    Gold Member
    robmaister12's Avatar
    January 2008
    4,969 Posts
    How do big devs handle things like entity systems? I know they are usually component based and before I start writing code I want to plan this out, lest I get awful and incomprehensible code that I just don't want to deal with. Like what does gamebryo do?
    As long as you define components by functionality and not by the type of an object, you really can't go that wrong with a component based entity system. Before I implemented that type of system for the first time, I kept on thinking that it would be really complicated and that it would be hard to build the proper framework around it, etc. Then at some point I just started writing some code and realized that a lot of the complications I thought of were non-issues and a lot of things worked themselves out.

    The only planning you really need to do right now before you write code:

    -What data is shared between all components and should be a part of Entity? (hint: position)
    -How will components communicate with one another? (In my implementation all components store a reference to their parent Entity, and you can request other components through the Entity. Other implementations do things like a message passing interface. Depends on what you need.)
    -how will I store all the components and update them? (Usually this involves a ComponentManager or something similar. In my implementation it only accepts Entities, but internally stores them as separate components separated by type.)

    Once you have a plan for those three things, start writing some code and you'll see that a lot of it will start to fall in place.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  28. Post #1548
    Jimmylaw's Avatar
    November 2007
    506 Posts
    Having a problem with "'Particle' : base class undefined" after lots of google search it appears its causes by an issue with 2 classes having the same header file but this is not the case with mine.

    
    #pragma once
    #include "Particle.h"
    
    class blueParticle :public Particle
    {
    public:
    	blueParticle(int x, int y, float dirx, float diry);
    	virtual ~blueParticle();
    
    protected:
    
    };
    

    
    #pragma once
    
    #include "Entity.h"
    #include "Main.h"
    
    class Particle : public Entity
    {
    public:
    	Particle(int x, int y, float dirx, float diry);
    	virtual ~Particle();
    	virtual void Update(float frametime);
    
    protected:
    	float life_time_;
    	sf::Vector2f direction;
    	float timeAcc;
    };
    
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  29. Post #1549
    Gold Member
    Lord Ned's Avatar
    April 2006
    3,702 Posts
    Does Main.h or Entity.H include blueParticle.h/Particle.h?

    I don't see any reason for your Particle class to include "Main.h" either.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  30. Post #1550
    Richy19's Avatar
    May 2010
    5,394 Posts
    Does anyone know what are some good values for perlin noise?
    Im using these values:
    PerlinNoise p;
        p.Set(
              2.25,     //Persistance
              4.0,      //Frequency
              0.50,     //Amplittude
              6,        //Octaves
              5555);    //Seed
    
    
        glGenTextures( 1, &tex );
        glBindTexture( GL_TEXTURE_2D, tex );
        int imgSize = 512;
        glm::vec3 img[imgSize*imgSize];
    
    
    
        for(int y = 0; y < imgSize; y++)
        {
            for(int x = 0; x < imgSize; x++)
            {
                int id = x + (y * imgSize);
                img[id] = glm::vec3(p.GetHeight(x, y));
            }
        }
        glTexImage2D( GL_TEXTURE_2D, 0, GL_RGB, imgSize, imgSize, 0, GL_RGB, GL_FLOAT, img );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
        glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
        glGenerateMipmap( GL_TEXTURE_2D );
    

    But it gives this ugly thing:
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  31. Post #1551
    quincy18's Avatar
    September 2007
    1,005 Posts
    Tried setting up a basic opengl window with glut and then binding a shader to it with glew, for some reason the shader doesn't do anything, does anybody have any idea why ?

    Source : http://dl.dropbox.com/u/28926055/EmpiresOpenGL.rar
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  32. Post #1552
    Gold Member
    Naelstrom's Avatar
    June 2010
    2,717 Posts
    Tried setting up a basic opengl window with glut and then binding a shader to it with glew, for some reason the shader doesn't do anything, does anybody have any idea why ?

    Source : http://dl.dropbox.com/u/28926055/EmpiresOpenGL.rar
    You should add shader error checking. You're blindly compiling and linking the shader without actually checking if it succeeded or not.

    You can use my engine's shader object for reference if you'd like, but it's a little messy: https://github.com/naelstrof/Astrost...rc/NShader.cpp
    Reply With Quote Edit / Delete Linux United States Show Events

  33. Post #1553
    quincy18's Avatar
    September 2007
    1,005 Posts
    Yea, I figured that much, so I added it in and this was the error :

    http://dl.dropbox.com/u/28926055/juulbitch.png

    But the vertex and fragment shader are both really simple, can't find anything that could cause this.
    - Edit -
    Managed to fix the error by removing the #version 150 but now it doesn't error and still just displays a white cube instead of a yellow one.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events

  34. Post #1554

    October 2005
    5 Posts
    Currently messing around with SAT (Separating Axis Theorem), But failing miserably to produce a decent collision response.

    Does anyone have any examples or old code to share and learn from?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  35. Post #1555
    Richy19's Avatar
    May 2010
    5,394 Posts
    Can anyone see anything wrong with this perlin class, I cant get the desired output.

    #include "PerlinNoise.hpp"
    
    PerlinNoise::PerlinNoise()
    {
      persistence = 0;
      frequency = 0;
      amplitude  = 0;
      octaves = 0;
      randomseed = 0;
    }
    
    PerlinNoise::PerlinNoise(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed)
    {
      persistence = _persistence;
      frequency = _frequency;
      amplitude  = _amplitude;
      octaves = _octaves;
      randomseed = 2 + _randomseed * _randomseed;
    }
    
    void PerlinNoise::Set(double _persistence, double _frequency, double _amplitude, int _octaves, int _randomseed)
    {
      persistence = _persistence;
      frequency = _frequency;
      amplitude  = _amplitude;
      octaves = _octaves;
      randomseed = 2 + _randomseed * _randomseed;
    }
    
    double PerlinNoise::GetHeight(double x, double y) const
    {
      return amplitude * Total(x, y);
    }
    
    double PerlinNoise::Total(double i, double j) const
    {
        //properties of one octave (changing each loop)
        double t = 0.0f;
        double _amplitude = 1;
        double freq = frequency;
    
        for(int k = 0; k < octaves; k++)
        {
            t += GetValue(j * freq + randomseed, i * freq + randomseed) * _amplitude;
            _amplitude *= persistence;
            freq *= 2;
        }
    
        return t;
    }
    
    double PerlinNoise::GetValue(double x, double y) const
    {
        int Xint = (int)x;
        int Yint = (int)y;
        double Xfrac = x - Xint;
        double Yfrac = y - Yint;
    
      //noise values
      double n01 = Noise(Xint-1, Yint-1);
      double n02 = Noise(Xint+1, Yint-1);
      double n03 = Noise(Xint-1, Yint+1);
      double n04 = Noise(Xint+1, Yint+1);
      double n05 = Noise(Xint-1, Yint);
      double n06 = Noise(Xint+1, Yint);
      double n07 = Noise(Xint, Yint-1);
      double n08 = Noise(Xint, Yint+1);
      double n09 = Noise(Xint, Yint);
    
      double n12 = Noise(Xint+2, Yint-1);
      double n14 = Noise(Xint+2, Yint+1);
      double n16 = Noise(Xint+2, Yint);
    
      double n23 = Noise(Xint-1, Yint+2);
      double n24 = Noise(Xint+1, Yint+2);
      double n28 = Noise(Xint, Yint+2);
    
      double n34 = Noise(Xint+2, Yint+2);
    
        //find the noise values of the four corners
        double x0y0 = 0.0625*(n01+n02+n03+n04) + 0.125*(n05+n06+n07+n08) + 0.25*(n09);
        double x1y0 = 0.0625*(n07+n12+n08+n14) + 0.125*(n09+n16+n02+n04) + 0.25*(n06);
        double x0y1 = 0.0625*(n05+n06+n23+n24) + 0.125*(n03+n04+n09+n28) + 0.25*(n08);
        double x1y1 = 0.0625*(n09+n16+n28+n34) + 0.125*(n08+n14+n06+n24) + 0.25*(n04);
    
        //interpolate between those values according to the x and y fractions
        double v1 = Interpolate(x0y0, x1y0, Xfrac); //interpolate in x direction (y)
        double v2 = Interpolate(x0y1, x1y1, Xfrac); //interpolate in x direction (y+1)
        double fin = Interpolate(v1, v2, Yfrac);  //interpolate in y direction
    
        return fin;
    }
    
    double PerlinNoise::Interpolate(double x, double y, double a) const
    {
        double negA = 1.0 - a;
      double negASqr = negA * negA;
        double fac1 = 3.0 * (negASqr) - 2.0 * (negASqr * negA);
      double aSqr = a * a;
        double fac2 = 3.0 * aSqr - 2.0 * (aSqr * a);
    
        return x * fac1 + y * fac2; //add the weighted factors
    }
    
    double PerlinNoise::Noise(int x, int y) const
    {
        int n = x + y * 57;
        n = (n << 13) ^ n;
      int t = (n * (n * n * 15731 + 789221) + 1376312589) & 0x7fffffff;
        return 1.0 - double(t) * 0.931322574615478515625e-9;/// 1073741824.0);
    }
    
    Reply With Quote Edit / Delete Linux United Kingdom Show Events

  36. Post #1556
    this link changes
    ScottyWired's Avatar
    April 2012
    8,563 Posts
    ActionScript 3, pretty much my first game ever.

    if //scorer1 reaches 200
    {
    //Go to scene 2 and play
    }
    }
    I want the game to go to scene 2 and play after scorer1 reaches 200. scorer1 is the instance name of the text box displaying the score. I know how to modify numeral values when they are a string
    if blah blah { scorer1.text=(int(scorer1.text)+1).toString()
    but I don't know how to detect when a string has become a certain value.

    Learning AS3 at school as first programming language. I'll be moving onto harder stuff next year. Sorry my coding isn't as grand as that noise-simulator thingy made in Perl above :/
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  37. Post #1557
    open.gl
    Overv's Avatar
    February 2007
    7,431 Posts
    Yea, I figured that much, so I added it in and this was the error :

    http://dl.dropbox.com/u/28926055/juulbitch.png

    But the vertex and fragment shader are both really simple, can't find anything that could cause this.
    - Edit -
    Managed to fix the error by removing the #version 150 but now it doesn't error and still just displays a white cube instead of a yellow one.
    Your shaders use very old deprecated OpenGL features, so GLSL 1.50 is definitely not suited for you.

    Using a glGetError() I found that glUseProgram was causing a GL_INVALID_VALUE error. To see why this happens, let's have a look at shader creation:

    shader = Shader("Shaders\\vertexshader.shader", "Shaders\\pixelshader.shader");

    What happens here is that a shader object is created and loads the shaders you specified. It is then assigned to the shader variable and finally it destroys itself because it is no longer necessary. This destruction causes the shaders to be unloaded and they will no longer be usable by your program.

    To circumvent this, you need to implement your own assignment operator:

    Shader& Shader::operator=( Shader& shader )
    {
    	shader_vp = shader.shader_vp;
    	shader_fp = shader.shader_fp;
    	shader_id = shader.shader_id;
    	shader.shader_id = 0;
    	return *this;
    }

    And tell the destructor to not do anything if no shader program is set:

    Shader::~Shader(void)
    {
    	if ( shader_id == 0 ) return;

    And of course initialise it to be 0:

    Shader::Shader()
    {
    	shader_id = 0;
    }

    This will result in a correctly drawn cylinder.



    Really though, the OpenGL code used here is depressing. If you want to use glut, fair enough, but using fixed pipeline properties in shaders? Ugh. If you have some pride, either ditch shaders or switch to full programmable mode.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events Friendly Friendly x 1 (list)

  38. Post #1558
    Gold Member
    Asgard's Avatar
    July 2010
    3,615 Posts
    Is there any easier way than putting all my .lua files with main.lua on top in a .zip, change it to a .love and execute it everytime I make a small change?

    Lua + Love2D.
    Reply With Quote Edit / Delete Linux Netherlands Show Events

  39. Post #1559
    Grimpunch Games
    TM Gmod's Avatar
    May 2005
    524 Posts
    In unity I'm trying to figure out how to change a texture at runtime in C#. I have the file name of the texture in a string, but I dont know how to set the texture from a path.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  40. Post #1560
    Gold Member
    HeroicPillow's Avatar
    July 2009
    4,651 Posts
    In unity I'm trying to figure out how to change a texture at runtime in C#. I have the file name of the texture in a string, but I dont know how to set the texture from a path.
    here's one way at least
    using System.IO;
    
    	private Texture2D loadTexture(string name){
    		byte[] png = File.ReadAllBytes(name); //name is a full path
    		Texture2D temp; //= new Texture2D(1,1); //i don't remember if you need to initialize it beforehand
    		temp.LoadImage(png);
    		temp.filterMode =  FilterMode.Point; //pixelated by default (use whichever mode you'd like)
    		temp.wrapMode = TextureWrapMode.Clamp; //don't repeat the texture
    		return temp;
    	}
    Reply With Quote Edit / Delete Windows 7 United States Show Events