Quote:
when can I have your first born?
nono, a deal is a deal!
ok so i had to get some sleep , but just tried the code again.. this time it compiles.. as i had forgot to use ( ) before ...
but it does not show anything and gives errors at
Code:
row[c].height
its showing ????? as height, but up top for the
Code:
hexagon grid[rows][columns];
it is showing 1.0f as height.
I am going to give it a shot and try some things, but want a full copy of what i have so far

Code:
// Game.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <GL\glew.h>
#include <GL\freeglut.h>
#include <math.h>
#define tau 6.283185307179586476925286766559
#define uint unsigned int
struct hexagon
{
hexagon();
float height ;
//other attributes...
};
hexagon::hexagon() :
height(1.0f)
{
}
const uint rows = 18;
const uint columns = 18;
hexagon grid[rows][columns];
void RenderHexRow(float originX, float originY, float radius, hexagon* row, uint columns, float xStride)
{
static const float angleIncrement = tau / 6;
static const float edgXc = cos(angleIncrement);
static const float edgYc = sin(angleIncrement);
float edgeX = edgXc * radius;
float edgeY = edgYc * radius;
for (int c = 0; c!= columns; ++c)
{
// Perimeter (zig-zag srip pattern)
glBegin(GL_TRIANGLE_STRIP);
float a = originX + radius;
glVertex3f(a, originY, 0.0f);
glVertex3f(a, originY, row[c].height);
a = originX + edgeX;
float b = originY - edgeY;
glVertex3f(a, b, 0.0f);
glVertex3f(a, b, row[c].height);
a = originX - edgeX;
glVertex3f(a, b, 0.0f);
glVertex3f(a, b, row[c].height);
b = originX - radius;
glVertex3f(b, originY, 0.0f);
glVertex3f(b, originY, row[c].height);
b = originY + edgeY;
glVertex3f(a, b, 0.0f);
glVertex3f(a, b, row[c].height);
a = originX + edgeX;
glVertex3f(a, b, 0.0f);
glVertex3f(a, b, row[c].height);
a = originX + radius;
glVertex3f(b, originY, 0.0f);
glVertex3f(b, originY, row[c].height);
glEnd();
//top face
glBegin(GL_TRIANGLE_FAN);
glVertex3f(a, originY, row[c].height);
b = originY - edgeY;
glVertex3f(originX + edgeX, b, row[c].height);
a = originX - edgeX;
glVertex3f(a, b, row[c].height);
glVertex3f(originX - radius, originY, row[c].height);
b = originY + edgeY;
glVertex3f(a, b, row[c].height);
glVertex3f(originX + edgeX, b, row[c].height);
glEnd();
originX += xStride;
}
}
void RenderHexGrid(float originX, float originY, float radius, hexagon** hexgrid, uint rows, uint columns)
{
static const float angleIncrement = 2 * tau / 6;
float xStride = radius * 2;
float yStride = sin(angleIncrement) * xStride;
float originX2 = originX + radius;
float originY2 = originY + yStride;
yStride *= 2;
for (int r = 0; r < rows; r += 2)
{
RenderHexRow(originX, originY, radius, hexgrid[r],columns,xStride);
originY += yStride;
}
for (int r = 1; r< rows; r+= 2)
{
RenderHexRow(originX2, originY2, radius, hexgrid[r],columns,xStride);
originY2 += yStride;
}
}
void display(void)
{
glClearColor(1.f,0.f,0.f,1.f);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glFlush();
}
int _tmain(int argc, CHAR **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode (GLUT_SINGLE);
glutInitWindowSize(500,500);
glutInitWindowPosition(100,100);
glutCreateWindow("Your first opengl Window");
glutDisplayFunc(display);
RenderHexGrid(0.0f,0.0f,0.5f,(hexagon**)grid,rows,columns);
glutMainLoop();
return 0;
}