PDA

View Full Version : Need help with short program!



01-30-2003, 11:13 AM
There's not much code, it just displays a checkerboard bitmap. I can't figure out what to change so that the size of the individual squares are larger or smaller.
Thanks in advance for your help.

#include<windows.h>
#include<math.h>
#include"Gl.h"
#include"glut.h"


const int screenWidth = 400; // width of screen window in pixels
const int screenHeight = 400; // height of screen window in pixels
int i,j;
GLubyte wb[2] = { 0x00, 0xff};
GLubyte check[512];

void myDisplay(void)
{
glClearColor(0.0, 0.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT); // clear the screen

for(i = 0; i < 64; i++)
{
for(j = 0; j < 8; j++)
{
check[i*8+j] = wb[(i/8 + j)%2];
}
}
glBitmap(64, 64, 0.0, 0.0, 0.0, 0.0, check);
}


void main(int argc, char** argv)
{
glutInit(&argc, argv); // initialize the toolkit
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB); // set display mode
glutInitWindowSize(screenWidth, screenHeight); // set window size
glutInitWindowPosition(300, 150); // set window position on screen
glutCreateWindow("Checkerboard"); // open the screen window "Checkerboard"
glutDisplayFunc(myDisplay); // register redraw function
glutMainLoop(); // go into a perpetual loop
}

shinpaughp
01-30-2003, 12:17 PM
That would be the wb[(i/8 + j)%2] - if you change the 8 to a 4 it should give you smaller checkers, and if you increase it from 8 it will give you bigger checkers. But, from your code, it looks as though you are only creating data for an 8 by 64 byte bitmap when it looks as though you want a 64 by 64 byte bitmap. Might want to check that.

[This message has been edited by shinpaughp (edited 01-30-2003).]