visual studio - C++ with OpenGL - Drawing a square -


i have make program should draw square change colors. program draw window white background, dimensions of 256x256 pixels, red square upper left vertex coordinate (x, y) = (30, 226) , lower right corner coordinates (x, y) = (226 , 30). when key 'a' (keycode = 97) pressed, square should stick color blue. when 'v' key (keycode = 118) pressed, square should go red. when esc key (keycode = 27) pressed program should terminated.

-- there log...

build log      build started:  project: square, configuration: debug|win32  command lines       creating temporary file "c:\users\temp\documents\visual studio 2008\projects\square\square\debug\rsp00000544445896.rsp" contents [ /out:"c:\users\temp\documents\visual studio 2008\projects\square\debug\square.exe" /manifest /manifestfile:"debug\square.exe.intermediate.manifest" /manifestuac:"level='asinvoker' uiaccess='false'" /debug /pdb:"c:\users\temp\documents\visual studio 2008\projects\square\debug\square.pdb" /dynamicbase /nxcompat /machine:x86 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib  ".\debug\square.obj" ] creating command line "link.exe @"c:\users\temp\documents\visual studio 2008\projects\square\square\debug\rsp00000544445896.rsp" /nologo /errorreport:prompt"   output window     linking... square.obj : error lnk2019: unresolved external symbol __imp____glutinitwithexit@12 referenced in function _glutinit_atexit_hack@8 square.obj : error lnk2019: unresolved external symbol __imp____glutcreatewindowwithexit@8 referenced in function _glutcreatewindow_atexit_hack@4 c:\users\temp\documents\visual studio 2008\projects\square\debug\square.exe : fatal error lnk1120: 2 unresolved externals    results       build log saved @ "file://c:\users\temp\documents\visual studio 2008\projects\square\square\debug\buildlog.htm" square - 3 error(s), 0 warning(s) 

code:

#include <gl/glut.h>  // function callback called manage keyboard tasks float r = 0.0f; float g = 0.0f; float b = 0.0f; void gerenciateclado(unsigned char key, int x, int y) {     switch (key) {     case 'a':// change actual color red         r = 1.0f;         g = 0.0f;         b = 0.0f;         break;     case 'v':// change de color blue         r = 0.0f;         g = 0.0f;         b = 1.0f;         break;     case 27:// close screen         exit(0);         break;     }     glutpostredisplay(); }  // function callback called draw void desenha(void) {     // clean window     glclearcolor(0.0f, 0.0f, 0.0f, 1.0f);     glclear(gl_color_buffer_bit);      // initializes coordinates system     glmatrixmode(gl_projection);     glloadidentity();     double w = glutget( glut_window_width );     double h = glutget( glut_window_height );     double ar = w / h;     glortho( -2 * ar, 2 * ar, -2, 2, -1, 1);      glmatrixmode(gl_modelview);     glloadidentity();      // draw square     glbegin(gl_quads);     // shows color red     //        r  g  b     glcolor3f(r, g, b);     glvertex2f(-1, -1);     glvertex2f( 1, -1);     // shows color blue     glcolor3f(0.0f, 0.0f, 1.0f);     glvertex2f( 1, 1);     glvertex2f(-1, 1);     glend();      glutswapbuffers(); }  // main program int main( int argc, char** argv ) {     glutinit( &argc, argv );     glutinitdisplaymode(glut_double | glut_rgb);     glutinitwindowsize(256,256);     glutinitwindowposition(10,10);     glutcreatewindow("quadrado");     glutdisplayfunc(desenha);     glutkeyboardfunc(gerenciateclado);     glutmainloop(); } 

when building glut need link code glut library. try google how link visual studio additional third party library. in case believe need add library directory , add additional dependency(glut.lib) in project linker properties.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -