• Advertisement

Archived

This topic is now archived and is closed to further replies.

Help with displaying a polygon! :p

This topic is 6589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I''m having trouble compiling the following piece of code: #include ''windows.h'' #include ''gl/gl.h'' #include ''gl/glaux.h'' #include ''conio.h'' void CALLBACK DrawScene() { glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); glBegin(GL_POLYGON); // being drawing the square glColor3f(0.0, 1.0, 0.0); glVertex2f(0.0, 0.0); glVertex2f(5.0, 0.0); glVertex2f(5.0, 5.0); glVertex2f(0.0, 5.0); glEnd(); glFlush(); // force drawing } void main() { auxInitDisplayMode(AUX_SINGLE / AUX_RGBA); auxInitPosition(100,100,250,250); // size and coordinates auxInitWindow("A simple square"); auxMainLoop(DrawScene); cprintf("Push any key to close the coloured window...\n"); getch(); } I''m a newbie, as you can tell- just in case my code is entirely way off, this application is supposed to display a small square inside a window. Whenever I compile it, I get the following errors: Compiling... simple square.cpp Linking... LIBCD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16 Debug/Simple Square.exe : fatal error LNK1120: 1 unresolved externals Error executing link.exe. Simple Square.exe - 2 error(s), 0 warning(s) What am I missing? Can anyone help me out? Programming::~Fredric(const Annoy_Ance)

Share this post


Link to post
Share on other sites
Advertisement
Thanks a lot! That solved my problem and got rid of the errors, but when I ran my program, the window that was supposed to display my polygon didn''t show up. I looked at the source code to make sure that I cleared the screen BEFORE I drew the polygon, but the polygon doesn''t show up. What am I doing wrong?

Programming::~Fredric(const Annoy_Ance)

Share this post


Link to post
Share on other sites
before glBegin(..);
type, glTranslatef(0.0f,0.0f,-6.0f);
this moves the figure back 6 places in the Z coordinate. Before it was being clipped. If you want to move it around just use this function.
prototype:
glTranslatef(x, y, z);

Share this post


Link to post
Share on other sites
what''s yer viewport? orthographic or perspective? if it''s perspective, then you have to use gluLookAt(x,y,z, x,y,z,0,1,0) in the render code. if you''re using orthographic, make sure the object is within clipping region.

a2k

Share this post


Link to post
Share on other sites
I know this may be a bother, but I''m a newbie as you can tell! Can one of please do me the huge favor of copy and pasting my original source code into a message and making the necessary changes? If you could that would be awesome!

Programming::~Fredric(const Annoy_Ance)

Share this post


Link to post
Share on other sites
you know what. i tried it, but got the same result. my best advice is to not use the auxiliary library, but either the gl/glu library or the glut library, which is easiest of all. you can download it from any opengl site, like opengl.org. starting with glut is really good, cuz it''s easy. you can go to the NeHe pages, and get lots of code from there. they have EXCELLENT tutorials. nehe.gamedev.net. just go to opengl tutorials link. i swear you''ll learn something from there.

i have a question. how''d you earn martyr status without knowing open gl? are you a direct x expert or something?

good luck, and happy coding =)!!

a2k

Share this post


Link to post
Share on other sites
I got to my current status because I like to talk a lot in then lounge.... as well, I''m a C++ programmer!
If I use the GLUT library, I just change aux with glut! What''s the difference?

Programming::~Fredric(const Annoy_Ance)

Share this post


Link to post
Share on other sites
aux is exactly what it is. it''s auxiliary. it''s pretty much for learning, and it''s pretty limited. i don''t think it''s suitable for programming a game. you know what though, i could be fulla shit, but i learned with glut, and all the books out there now cover glut, and it''s just a nice encapsulation of all gl and glu libraries. that''s all.

a2k

Share this post


Link to post
Share on other sites
I know that AUX is used purely for learning and not necessarily suitable for programming a game, but I checked out the source code in my OpenGL red book, and I basically wrote the entire source code that used GLUT, and replaced each GLUT with AUX (I have some previous basic knowledge of AUX) because I was more comfortable with AUX.
Thus... there has to be some way I can make the polygon appear! I mean, the only way I''m using AUX for is initializing the window and making the MainLoop point to the DrawScene function!

Programming::~Fredric(const Annoy_Ance)

Share this post


Link to post
Share on other sites

  • Advertisement