PDA

View Full Version : Why won't my ground show up, or my display list



10-19-2004, 05:53 AM
#include <gl\glut.h>
#include <math.h>
#include <gl\gl.h>
#include <gl\glu.h>

#include <stdlib.h>

static float angle=0.0,ratio;
static float x=0.0f,y=1.75f;
static float lx=0.0f,ly=0.0f;
static GLint flower_display_list;

void changeSize int w, int h


// Prevent a divide by zero, when window is too short
// you cant make a window of zero width.
ifh == 0
h = 1;

ratio = 1.0f * w / h;
// Reset the coordinate system before modifying
glMatrixMode GL_PROJECTION;
glLoadIdentity;

// Set the viewport to be the entire window
glViewport 0, 0, w, h;



void drawflower



// Draw Pot
glColor3f 1.0f, 1.0f, 1.0f;
glTranslatef 0.0f ,0.75f, 0.0f;
glutSolidCube 0.l;

// Draw Bud
glColor3f 0.0f, 1.0f, 1.0f;
glTranslatef 0.0f, 1.0f, 0.0f;
glutSolidSphere 0.25f,1,1;

// Draw Petals

glPushMatrix;
glColor3f 0.0f,0.0f,0.0f;
glTranslatef 0.05f, 0.10f, 0.18f;
glutSolidSphere 0.05f,10,10;
glTranslatef -0.1f, 0.0f, 0.0f;
glutSolidSphere 0.05f,10,10;
glTranslatef -0.1f, 0.0f, 0.0f;
glutSolidSphere 0.05f,10,10;
glTranslatef -0.1f, 0.0f, 0.0f;
glutSolidSphere 0.05f,10,10;
glTranslatef -0.1f, 0.0f, 0.0f;
glutSolidSphere 0.05f,10,10;
glPopMatrix;

// Draw Stalk
glColor3f 1.0f, 1.0f, 1.0f;
glColor3f 1.0f, 0.5f , 0.5f;
glRotatef 0.0f,1.0f, 0.0f, 0.0f;
glutSolidCone 0.08f,0.5f,10,2;

GLuint createDL
GLuint flowerDL;

// Create the id for the list
flowerDL = glGenLists 1;

// start list
glNewListflowerDL,GL_COMPILE;

// call the function that contains the rendering commands
drawflower;

// endList
glEndList;

returnflowerDL;

void initScene

glEnable GL_DEPTH_TEST;
flower_display_list = createDL;

void renderScene void
glClearGL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT;

//Draw Ground

glColor3f 0.0f, 1.0f, 0.0f;
glBegin GL_QUADS;
glVertex3f-100.0f, 200.0f, 0.0f;
glVertex3f-100.0f, 640.0f, 0.0f;
glVertex3f 800.0f, 640.0f, 0.0f;
glVertex3f 800.0f, 200.0f, 0.0f;
glEnd;

// Draw Sky

glColor3f 0.0f, 0.0f, 1.0f;
glBegin GL_QUADS;
glVertex3f-100.0f, 0.0f, 0.0f);
glVertex3f-100.0f, 100.0f, 0.0f;
glVertex3f 800.0f, 100.0f, 0.0f;
glVertex3f 800.0f, 0.0f, 0.0f;
glEnd;

// Draw flowers

forint i = -1; i < 1; i++
for int j=-1; j < 1; j++
glPushMatrix;
glTranslatef i*1.0,0,j * 1.0;
glCallListf
lower_display_list;;
glPopMatrix;

glutSwapBuffers;

void processNormalKeys unsigned char key, int x, int y

if key == 27
exit 0;

int main int argc, char **argv

glutInit &argc, argv;
glutInitDisplayMode GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA;
glutInitWindowPosition 100,100;
glutInitWindowSize 800,640;
glutCreateWindow "Flower Scene";
glutKeyboardFunc processNormalKeys;
glutDisplayFunc renderScene;
glutIdleFunc renderScene;

glutReshapeFunc changeSize;
initScene;

glutMainLoop;

return0;

If you run it, it produces a strange black and blue background, when it should be blue and green, like ground and sky, and then the list is supposed to show a flower and repeat it on a 2D render....anyone help??

Obviouldy, no parenthese are in it....

10-19-2004, 08:37 AM
Can some one help please??