Jump to content

  • Log In with Google      Sign In   
  • Create Account

King of Men

Member Since 16 Apr 2004
Offline Last Active Apr 20 2015 02:05 PM

Topics I've Started

Moving a variable declaration affects unit test...

18 April 2015 - 02:34 PM

So if I declare my class this way:

  vector<ContractInfo*> obligations;
  map<EconActor*, double> borrowers;
  double discountRate;

then my unit tests fail. But if I do it this way:

  double discountRate;
  vector<ContractInfo*> obligations;
  map<EconActor*, double> borrowers;

they pass. My heart fills with unbounded joy at the thought of tracking this one down...


I suspect I have a destructor somewhere that I ought to have declared virtual, but didn't. Any better guesses?

Learning modern OpenGL

08 November 2013 - 04:04 PM

So I've been using OpenGL for a while and I feel I've got a reasonable grasp of the basics: Primitives, transforms, textures. I can make a sprite in a modelling program and get it up on the screen. But this is all using the fixed pipeline and basic glBegin, glEnd calls; I'd like to move on to the modern features. Can anyone recommend a good tutorial for understanding vertex shaders and such? For that matter, just a list of what the advanced features are would be helpful, so I know what the holes in my knowledge are. 

Seeking advice on presenting game information

08 October 2013 - 06:31 PM

I'm working on a turn-based, hex-based, 4X game. It is currently in a "playable" state, in that you can move armies around, recruit, attack, and there's a nod in the direction of supply lines. Much gameplay remains to be coded. Right now, though, I'm thinking of the interface. I've spent some time trying to reflect the game state in the main view, and am reasonably pleased with the engine, but the content needs a bit of work, and more to the point, input from someone who knows a bit about graphics. My screenshots, let me show you them:


This is a view of the main playing area, with an army selected - specifically, the one under the red banner. You can see the hex-line-vertex structure that forms the game surface, overlaid on green plains rising to a mountain in the center-right. If, like me, you know what's going on, you can also pick out villages, with their militia units and cows showing supply stockpiles, and the two castles. But none of this is very clear.


A different view of the playing area, offering perhaps some better idea of what's happening. Note the trees on the right.


A closeup on a village. At this distance the chimneys that distinguish the houses from being blobs of wood are visible. Note the militia on the left, armed with pitchforks.


A closeup on the cows, indicating that this village has a largish supply stockpile. Note also the fields among the trees, in the center; at the moment they are in the "fallow" state, but will change colour as the turns go and the village works them. Turns are a week long.


A closer view of the armies - distinct from the militias - showing the pikemen of the AI army, with their green banner, repeated on their uniform. In the background on the left, the archers and militia under the red banner of the human player; the archers get the banner on their uniform, the militia do not.

Now: I'm reasonably pleased with the way my graphics engine works, and with the sprites in a close view. What I'm not so happy about is how it all appears in an overview, ie zoomed out. Nothing stands out; you have to zoom in and fiddle with the view angle to extract any real information. So I'm open to suggestions. Could I have a better colour scheme? (The militia, especially, are a rather greyish blob at any sort of distance. Realistic-ish, but not very interesting.) Fiddle with the level of detail - abstract when zoomed out? (If so, I'd like to hear suggestions for how to present the same information: Size of the village, supply stockpile, size and unit type of the militia, and location/size/units of the field armies.) Something else?

Turing Machines

10 January 2011 - 09:33 PM

So there's something I don't understand about Busy Beaver numbers. Consider: We know that no Turing machine can calculate arbitrary BB numbers, because if one could, it could solve the Halting Problem. However, Turing machines are allowed to calculate particular BB numbers. Now, any Turing machine can emulate any other. So why can one not calculate any particular BB number by emulating a machine that can? Or have I just proved that there must exist at least one BB number which no Turing machine whatever can calculate?

Unexpected results with transparent textures

03 January 2011 - 06:12 PM

I am trying to draw some simple 2D graphics. My plan is to draw a quad in a single color, say green; then I draw a texture on top of that. The texture is mostly black, but partly transparent; thus I want the green to shine through the transparent parts, making an outline. It seems to me that this ought to happen when I use the GL_DECAL mode. In particular, where the texture is black and opaque, I should get color (1-1)*(0.0, 1.0, 0.0)+1*(0.0, 0.0, 0.0) = (0.0, 0.0, 0.0), which is black. Fine. But where the texture is transparent (and white), I should get (1-0)*(0.0, 1.0, 0.0)+0*(1.0, 1.0, 1.0)=(0.0, 1.0, 0.0), green. Instead, I get white, as shown in this screenshot:

Problem with decal mode

Clearly I'm misunderstanding something about how this works. Can anyone help me out?

This is my rendering code:

// Get coordinates
glColor4d(0.0, 1.0, 0.0, 1.0);
glBindTexture(GL_TEXTURE_2D, 0);
glVertex3d(coords11.first, coords11.second, -0.001);
glVertex3d(coords12.first, coords12.second, -0.001);
glVertex3d(coords21.first, coords21.second, -0.001);
glVertex3d(coords22.first, coords22.second, -0.001);
glColor4d(0.0, 0.0, 0.0, 0.0);

glBindTexture(GL_TEXTURE_2D, textureIDs[castleTextureIndices[i]]);
glTexCoord2d(0.0, 0.0); glVertex3d(coords11.first, coords11.second, 0.0);
glTexCoord2d(1.0, 0.0); glVertex3d(coords12.first, coords12.second, 0.0);
glTexCoord2d(1.0, 1.0); glVertex3d(coords21.first, coords21.second, 0.0);
glTexCoord2d(0.0, 1.0); glVertex3d(coords22.first, coords22.second, 0.0);