Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About waxor

  • Rank
  1. waxor

    Compilier "correct" behavior

    Well you learn something new every day,thanks for the insight. Given that my puter's case is part purple I will be more wary of using "undefined" code in the future. : ) -Mikel
  2. lets say I have this data structure in an array in memory: struct foo{ int something; int x; int y; } so the memory looks like this: {[something][ x ][ y ]}{[something][ x ][ y ]}{[something][ x ][ y ]}..... Ok. I have a pointer that is currently pointing to the first x in the first structure called ptr. Now I have a function: sendData(12, *ptr); This should send that data stored at that x as the second parameter. Here is the actual function I am using: sendData(12, *ptr++, *ptr++); That should send (12, x, y) and leave the pointer at the start of the next structure. Under Linux this compiles and executes fine. With windows Visual studio 6 the post increments are not called until after the function call. I am fairly certain that the windows behavior is "wrong". Anyone agree? -Mikel
  3. The cpp file bit was the trick. I would rather use a reference than a pointer, just because I have written a bunch of states that all refer to it as a reference. Thanks.
  4. Here is my situation, I have a base class called State and several derived classes, such as Running and Placing. The master game object maintains an array of these derived state objects. I use the common methods to move my game along. Most of the derived classes need access to a vector that is contained inside the main game object. This is a vector of all in game characters, which I call "units". The easy solution is to pass a reference to the units vector to each derived class that needs it when I create them. What I would like to do is make the reference a static member of the base class and let all derived classes access it through that. That seems very clean and the "right" way to do things. To bad I cant seem to get the syntax right. Here is the relevant code: class State{ protected: // Reference to "global" list of units static vector<Unit*>& unitsI; public: static void setUnitList(vector<Unit*>& unitsIn) {unitsI = unitsIn;} } And then in the setup process in my game object I do something like this: vector<Unit*> units; State::setUnitList(units); When I try to compile it I get: undefined reference to State::unitsI So I add this to the end of the class's .h file: vector<Unit*>& State::unitsI; Except now it complains: 'State::unitsI' declared as reference but not initialized I could create a temp vector, assign it to the reference and then reassign the reference later but that makes the compiler shout a lot about "multiple definitions", so that seems like the way to go. I could use a pointer to the vector instead of a reference like this: vector<Unit*>* unitsI; but that gives me the same "multiple definition of State::unitsI" error message that I get when I try the temp vector. What is a good way to do this? Am I missing some trivial trick or is my idea flawed? -Waxler
  5. waxor

    Question On Bitmap Font's, Opengl

    This will print your string in the upper right corner of the screen, should be trivial to get it to move around. void stringDisplay(string stringIn) { glColor3f(1,.2,.2); // Stolen from António Fernandes @ http://www.lighthouse3d.com/opengl/glut/ float x = 5, y = 30; // switch to projection mode glMatrixMode(GL_PROJECTION); // save previous matrix which contains the //settings for the perspective projection glPushMatrix(); // reset matrix glLoadIdentity(); // Get the Screen Properties GLint viewport[4]; glGetIntegerv(GL_VIEWPORT,viewport); // set a 2D orthographic projection gluOrtho2D(0, viewport[2], 0, viewport[3]); // invert the y axis, down is positive glScalef(1, -1, 1); // mover the origin from the bottom left corner // to the upper left corner glTranslatef(0, -viewport[3], 0); glMatrixMode(GL_MODELVIEW); glPushMatrix(); glLoadIdentity(); //Render String const char *c; int x1 = (int)x; for (c = stringIn.c_str(); *c != '\0'; c++) { glRasterPos2f(x1, y); glutBitmapCharacter(GLUT_BITMAP_TIMES_ROMAN_24, *c); x1 = x1 + glutBitmapWidth(GLUT_BITMAP_TIMES_ROMAN_24, *c) + 3; } //Reset Perspective glPopMatrix(); glMatrixMode(GL_PROJECTION); glPopMatrix(); glMatrixMode(GL_MODELVIEW); }
  6. waxor

    GLUT mouse movement

    Yeah I was not really clear on what I wanted. My problem is the mouse mouvement is bounded by the window size. I can only move the mouse in the x direction the same amount as my screen.
  7. Does anyone know how to get GLUT to read mouse movement as realative instead of absolute? I would like to make my code portable so at this point I have stuck to GLUT commands only. Am I up againt a wall? -Mikel
  8. waxor

    Rendering terrain

    I think I probably asked the wrong question. (does some more research...) What I really want is a basic terrain renderer that renders low detail terrain. Then on top of that I need to place a hex grid. The hex grid is game idea only. I should not have any effect on terrain rendering. What I need is something like this, only take out the triangles and replace them with hexes. I dont need to render the ground with hexes, I just need the player to see hexes. http://home.planet.nl/~monstrous/image/terr01.jpg Make sence?
  9. waxor

    Rendering terrain

    I am making a strategy game based on a hex map. My initial map was a grid of hexes that could be raised, angled, and rotated. This is fairly simple and really ugly. What I would like is a semi-smooth 3d terrain with a hex grid laid on top of that. The hex grid can be a separate entity that gets laid on top of the terrain since it might not always be visible. The easiest thing I can think of is to setup a 2 dimensional array and store color and height data in that and render each of those individual points. So basically a voxel based map. This seems like a bad idea though since I will need roughtly a 64x64 hex map and at least 25x25 pixels per hex to make it look ok, probably more to make it look nicer. Really my main problem is that I am at a loss for search terms. I dont know where to start looking. Does anyone have recommendations as to how best create the terrain or some articles that I could read? -Mikel
  10. waxor

    glut***func and member functions

    I feel silly. A little net research found me the solution. The function passed must be a static function. Making render a static fuction fixed it all good. -Mikel
  11. I am trying to abstract away from the opengl initialization process. What I want to do is put all the startup stuff in a class like this. The problem is that the glutDisplayFunc is this: argument of type `void (Engine::)()' does not match `void (*)()' class Engine{ void render(){ /.../ }; void setFuncs(){ glutDisplayFunc(render); } void go(){ glutMainLoop(); } } void Main()[ Engine engine; engine.setFuncs(); engine.go(); }
  12. Wow, your mom is way l33ter the mine. ;) I talked to one of my professors and we both came to the vector as a solution. Thanks a bunch for the links and the code example. Esp. the detailed accessin you did at the end, that should clear up a bunch of potential issues. -Mikel
  13. Right now I am allocating a static array in my map class to store my map. Basically like this: Class Map{ Hex cells[128][128]; //..... } What I would like to do is this: Class Map{ Hex *cells; void setupMap(){ cells = new Hex[128][128]; } //..... } Can you use 2 dimentional arrays with the new function or do I just need to allocate the number of cells I need and write an access function that translates from getCell(x,y) into the appropriate position position in the array? Also, assuming that all these class members/functions are public is there a trick to getting to those hex's members? Let me explian that better: Map.cells[1].x =2; cout << Map.cells[1].x; Map.cells[1].x should print the number I stored in x, instead I get back garbage. Can you see what is wrong with that syntax?
  14. waxor

    Hex map woes

    Yeah, that is how I am rendering them. The problem is making all the hexes planar while making the map look ok.
  15. waxor

    Hex map woes

    For my game I would like to use a hex grid instead of a square grid as the basis for the map. The spell system is based on hex shaped runes and it seems more artisicly correct to use hexes wherever possible. My first issue is making anything that is not a flat plane. it is very easy to create non-planar hex cells, by that I mean a hex that needs to have side at different angles and heights. This would create a visually strange effect, (ie ugly). There is no easy way to create a pretty slope. I could seperate each hex with a small border and use that as a kind of buffer to take care of the twisting. That adds a lot of extra polygons and logic to rendering the map, not where I really want to go. It also means that there would be tiny triangle holes at each corner, I could fill those but that adds even more cpu/storage strain. I could ignore this issue and render each hex at a specific height and angle, which would look bad but would get me past the issue. Has anyone run into hex map troubles? What did you do? -Mikel
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!