creating chessboard using opengl

darshnee
Unregistered
 
Post: #1
my lecture gave this assignment create a chessboard using opengl. and i know nuts about opengl. i hv been crackin my head for this assignment. can anyone help me... Cry
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #2
Any specific problems? Do you have an OpenGL view set up and you're having trouble making the chessboard or do you need help setting up the OpenGL view? I don't think anyone here is going to do your assignment, but if you have a question lots of people here can and will help you figure it out. Please do post back with specifics and I can try to help you get it figured out.
Quote this message in a reply
Member
Posts: 321
Joined: 2004.10
Post: #3
Just some hints:

Check out the OpenGL Geometric Drawing Primitives. You probably
want to use GL_POLYGON for the filled (dark) squares and maybe just
GL_LINES for the white squares. You'll need to get familar with glBegin(),
glEnd() and glVertex2f().

Check out the OpenGL Programming Guide (Red Book) - its free online.
It has some simple example programs that can get you started.

It might seem daunting at first, but start simple. Maybe with just a
square. Once this works, then you can stick this code in two for loops
for drawing the 8 rows and 8 columns.

Probably the hardest thing as a beginner will be to get the camera
set up and pointed in the right direction. I can remember staring
at many a black screen when I first started Smile But seriously, if you
start with a little working example that will be a big head start.
Quote this message in a reply
darshnee
Unregistered
 
Post: #4
well i know how to set up the opengl view. the thing is im weak in programming and out of time coz i have other 2 assignments to pass up on the same day. so im very much worried and running out of time here. i really need HELP. Cry
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #5
If you just want 2D, try somthing like:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 8, 8, 0);

glClearColor(1, 1, 1);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(0, 0, 0);
glBegin(GL_QUADS);
for(x = 0; x < 8; x++)
for(y = 0; y < 8; y++)
if((x+y)%2)
{ glVertex2f(x, y); glVertex2f(x+1, y); glVertex2f(x+1, y+1); glVertex2f(x, y+1); }
glEnd();

or you could do it with a textured quad like the redbook shows you:
http://www.rush3d.com/reference/opengl-r...ter09.html

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
darshnee
Unregistered
 
Post: #6
hey there. sorry to annoy u again. but im just not gettin it rite Cry . if u dun mind can u check it for me again where is my mistake and correct it for me pls. pls check whether does it really givin the chessboard output. ur help is very much needed. thank u soo much.

#include<windows.h>
#include<gl/gl.h>
#include<gl/glu.h>
#include<gl/glut.h>

int x,y;
void main(void)
{

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, 8, 8, 0);

glClearColor(1.0f,1.0f,1.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0f,1.0f,0.0f);
glBegin(GL_QUADS);
for(x = 0; x < 8; x++)
for(y = 0; y < 8; y++)
if((x+y)%2)
{ glVertex2f(x, y); glVertex2f(x+1, y); glVertex2f(x+1, y+1); glVertex2f(x, y+1); }
glEnd();


int main (int argc, char * argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("SAMPLE : RGB TRIANGLE");
glutReshapeFunc(ChangeSize);
glutDisplayFunc(DisplayScene);
MyInit();
glutMainLoop();
return 0;
}
}
Quote this message in a reply
Sage
Posts: 1,403
Joined: 2005.07
Post: #7
change void main(void) to void DisplayScene()
remove the line glutReshapeFunc(ChangeSize);

Sir, e^iπ + 1 = 0, hence God exists; reply!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL ES creating a 2D mesh soulstorm 0 3,037 May 20, 2009 02:37 AM
Last Post: soulstorm
  Creating an OpenGL Overlay Florian 12 10,747 Jan 23, 2009 03:29 AM
Last Post: Florian