Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Sep 2010
Offline Last Active Feb 17 2014 11:23 PM

Topics I've Started

Accept class function parameters as class variables

21 January 2014 - 09:04 AM

I know this is a simple question, but one I've always been looking for a solution for.


class MAP


      Scene scene;

      void AddedToScene(Scene);




void SCENE::addedToScene(Scene newScene)
        scene = newScene;


 I know it's minor, but I don't like always having to put a scene = newscene statement in the function definition.


Is there any way to make the class function automatically accept a function parameter of the same name as a class variable.


void addedToScene(Scene scene)

         // scene is automatically accepted as the class variable with the same name


Pixel buffer

19 December 2013 - 09:19 PM

I'm working with openGL, and I want to know which is the best method of directly accessing information in the frambuffer. I want to be able to read the pixels being displayed onscreen and place them into an array, perform operations, and put them back into the current frame.

What is the best method, meaning fastest or most flexible or is there a tradeoff? If you could give me a few ideas or point me in the right direction I would be much appreciative.

Strange lighting issues

10 December 2013 - 12:47 PM

I was working with a default picker for creating light objects. You would type something like:




and it would create an ambient light based off of preset values, and handle the rest of the code elsewhere.


The problem is when I was changing up the input variables for the lightfv( GL_AMBIENCE, float* ambience)

I ran into a problem.


The scene lighting would only work if the viewing position was somewhere near the origin. It didn't make sence. I messed with attenuation, trying to lower it, raise, it, remove it completely, and it didnt seem to have an effect on this issue.


Light just stops working once the camera moves more than just a few units from the origin.


Now if you know of this to be some sort of aspect of OpenGL and I'm just missing a line of code somewhere, let me know. if we're not so lucky keep reading for a few samples of the code and a the details of when this started happening.



Now the code for the light is something liek this


class LIGHT



vector3 pos;

color ambience;

color diffuse;

color specular


float shine;

float attenuation;



void Enable()

void Update()




I'm using a color code like this:


struct color


      float r, g, b, a;

      void Set(float, float, float);

      float* pFloat(); // this returns an array of 4 numbers like the ones the light needs as input



float* color::pFloat()


       float floater[] = {r, g, b, a};

      return floater;



the vector code for light positioning works similarly


struct vector3


     float x, y, z;

     void Set(float, float, float);

     float* pFloat();



float* color:pFloat()


       float floater[] = {x, y, z};

       return floater;




And the light takes those values as such


   glLightfv(ID, GL_POSITION, position.pFloat());
   glLightfv(ID, GL_DIFFUSE, diffuse.pFloat());   
   glLightfv(ID, GL_AMBIENT, ambient.pFloat()); 


The picker works, there was no problem there, but when I tried to change from setting the color values from this:


color[0] = .5;

color[1] = .2;

color[2] = .7;


position[0] = 10;

position[1] = 15;

position[0] = 10;


to something better like this


color.Set(.5, .2, .7);

position.Set(10, 15, 10);


The structs for color and position have functions to easily set themselves, and also produce the float* number array that openGl likes to use for it's light and position color values.


I got this working, and I've used this concept many times, but I ran into this other lighting problem that I just don't understand.


At first it seemed like it wasn't getting the correct positional values and just placing the lights at some far distance place,

then i noticed that it was placing them directly at the center, inside the test object I'm using to work with the lighting.


I output the values that would be directly sent into the openGl position input, and found them to be fine.


Does anyone have any idea why this is happening?


Something I've noticed

26 November 2013 - 02:40 PM

I see everywhere people looking to create a team that will make games and proprietary engines from scratch. This is great, it means that the community hobbyists are interested in real game development. The problem I see is that everyone wants to make a seperate team, all by itself. I'm sure that each person, or small group looking to get larger has a few good sized modules of code that are efficient and could see a future in the game engine market. I fear that as people stress on for years through the team development phase, that thousands of lines of code and effective modules will get lost in the shuffle.


I suggest that someone organize a pool of people looking to create an engine from scratch. We build one team at a time, seperate into specific projects that are similar where people can make some compromises in order to get some finished product created. I want to make a game engine from scratch, sure, but every bit of it doesn't have to be my own code. It would drive me crazy trying to perfect every single module, and it has been driving me crazy.


I work on graphics implementations. Mesh code, textures, systems that handle this data. If I could focus on that specifically, I could get alot of work done. Unfortunatly I have to split my time across all the fields, like script managment, camera viewpoints, game logic, and other misc topics. If I could get on board with a good structured team that was willing to make some comprimises I coudl see a real future doing this. I just hope that people can get past thier egos in order for the greater picture to come into focus.


This is my coding horror. I hope you like it. :)

Model class stores pointer to itself

25 November 2013 - 03:14 PM

I'm creating a class that handles models used for loading meshes and textures. When my engine goes to draw these models, it looks to an array of pointers that point to each model that's been initialized. How do I make the model class put a pointer to itself in this array? I've tried the "this" tag with no luck. Any ideas?