View Single Post
Join Date: Mar 2008
Posts: 40
Reputation: midimatt is an unknown quantity at this point 
Solved Threads: 2
midimatt's Avatar
midimatt midimatt is offline Offline
Light Poster

Re: error in cstdlib

 
0
  #6
Dec 31st, 2008
the only thing i've done is add

GLUT_BUILDING_LIB to the preprocessors to stop a clash between glut and stdlib

i have no idea what code to post, my program consists of 30 files and the error says its in the file cstdlib the only thing i have to go on is the errors happen after these 3 files

test.cpp
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. #include "vrobject.h"
  6.  
  7.  
  8. int main(int argc, char **argv){
  9.  
  10. Viewer *myViewer=new Viewer;
  11. myViewer->Init(argc,argv);
  12. myViewer->InitWorld();
  13. myViewer->SetValue(BUFFER,MDOUBLE);
  14. myViewer->CreateWin("Test",1280,720);
  15. myViewer->InitCamera();
  16. myViewer->Show();
  17.  
  18. return 0;
  19. }
viewer.cpp
  1. #include "viewer.h"
  2.  
  3. using namespace std;
  4.  
  5. Viewer::Viewer(){
  6.  
  7.  
  8. WinName="";
  9. BufType=GLUT_SINGLE;
  10.  
  11. for(int i=0;i<3;i++){
  12. background[i]=0.0f;
  13. }
  14.  
  15. }
  16.  
  17. Viewer::~Viewer(){
  18. return;
  19. }
  20.  
  21. void Viewer::Init(int argc,char **argv){
  22.  
  23. eye[0]=0.0f;
  24. eye[1]=0.5;
  25. eye[2]=25.0;
  26.  
  27. aim[0]=0.0f;
  28. aim[1]=0.0f;
  29. aim[2]=0.0f;
  30.  
  31. upright[0]=0.0f;
  32. upright[1]=1.0f;
  33. upright[2]=0.0f;
  34.  
  35. glutInit(&argc,argv);
  36.  
  37. }
  38.  
  39. void Viewer::CreateWin(char *Name,int Width,int Height){
  40. WinName=Name;
  41. WinWidth=Width;
  42. WinHeight=Height;
  43. }
  44.  
  45. void Viewer::SetValue(myEnum PName,myEnum Type){
  46.  
  47. switch(PName){
  48. case BUFFER:
  49. if(Type==MDOUBLE)
  50. BufType=GLUT_DOUBLE;
  51. else
  52. if(Type==SINGLE)
  53. BufType=GLUT_SINGLE;
  54. break;
  55. case BACKCOLOUR:
  56. break;
  57. default:
  58. break;
  59. }
  60. }
  61.  
  62.  
  63. void Viewer::InitWorld(){
  64. vrman=new WorldManager;
  65. vrman->initialise();
  66.  
  67. }
  68. void Viewer::InitCamera(){
  69. mycamera=new camera(PERSPECTIVE);
  70. mycamera->SetValue(MNEAR,1.0f);
  71. mycamera->SetValue(YANGLE,45.0f);
  72.  
  73.  
  74. mycamera->SetValuev(AIMAT, aim);
  75. mycamera->SetValuev(UPDIRECTION, upright);
  76. mycamera->SetValuev(POSITION, eye);
  77.  
  78. mycamera->SetValue(MFAR,500.0f);
  79. mycamera->SetValue(HEIGHT,WinHeight);
  80. mycamera->SetValue(ASPECT,1.0f);
  81. }
  82.  
  83. void Viewer::SetCamera(float nvalue,float viewangle){
  84. mycamera->SetValue(MNEAR, nvalue);
  85. mycamera->SetValue(YANGLE, viewangle);
  86.  
  87. }
  88.  
  89. void Viewer::Show(){
  90.  
  91. GLInit();
  92. glutMainLoop();
  93.  
  94. }
  95.  
  96.  
  97. void Viewer::GLInit(){
  98. glutInitDisplayMode(BufType |GLUT_RGB |GLUT_DEPTH);
  99. glutInitWindowSize(WinWidth, WinHeight);
  100. glutCreateWindow(WinName);
  101. glutReshapeFunc(Reshape);
  102. glutDisplayFunc(Display);
  103. glutMouseFunc(Mouse);
  104. glutIdleFunc(Idle);
  105. glutKeyboardFunc(Keyboard);
  106. glutSpecialFunc(SpecialKey);
  107. glEnable(GL_DEPTH_TEST);
  108. glClearColor(0.0f,0.0f,0.0f,1.0f);
  109.  
  110. }
  111.  
  112.  
  113. void Viewer::Display(){
  114. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  115.  
  116. vrman->exec_loop();
  117.  
  118.  
  119. glFlush();
  120. if(BufType==GLUT_DOUBLE){
  121.  
  122. glutSwapBuffers();
  123. }
  124.  
  125.  
  126. }
  127.  
  128. void Viewer::Reshape(int w,int h){
  129.  
  130. glViewport(0,0,(GLsizei)w,(GLsizei)h);
  131. WinWidth=w;
  132. WinHeight=h;
  133. mycamera->SetValuev(POSITION,eye);
  134. mycamera->SetValuev(AIMAT,aim);
  135. mycamera->Render();
  136.  
  137. }
  138.  
  139. void Viewer::Mouse(int button,int state,int x,int y){
  140.  
  141. vrman->mouse(button,state,x,y);
  142. Display();
  143. }
  144.  
  145. void Viewer::Idle(){
  146. vrman->idle();
  147. Display();
  148. }
  149.  
  150. void Viewer::Keyboard(unsigned char key,int x,int y){
  151.  
  152. switch(key){
  153. case 0x14b:
  154. case 38://up
  155. eye[2]-=0.5;
  156. aim[2]-=0.5;
  157. break;
  158. case 40: //down arrow
  159. eye[2]+=0.5;
  160. aim[2]+=0.5;
  161. break;
  162. case 37://left
  163. eye[0]-=0.5;
  164. aim[0]-=0.5;
  165. break;
  166. case 39://right arrow
  167. eye[0]+=0.5;
  168. aim[0]+=0.5;
  169. break;
  170. default:
  171. vrman->keyboard((unsigned char)key,x,y);
  172. break;
  173. }
  174.  
  175. Display();
  176. }
  177.  
  178. void Viewer::SpecialKey(int key, int x, int y){
  179. switch(key){
  180. case GLUT_KEY_F1:
  181. upright[0]=0.0f;
  182. upright[1]=0.0f;
  183. upright[2]=-1.0f;
  184. aim[0]=0.0f;
  185. aim[1]=0.0f;
  186. aim[2]=0.0f;
  187. eye[0]=0.0f;
  188. eye[1]=25.0f;
  189. eye[2]=0.0f;
  190. break;
  191. case GLUT_KEY_F2:
  192. upright[0]=0.0f;
  193. upright[1]=1.0f;
  194. upright[2]=0.0f;
  195. aim[0]=0.0f;
  196. aim[1]=0.0f;
  197. aim[2]=0.0f;
  198. eye[0]=0.0f;
  199. eye[1]=0.5f;
  200. eye[2]=25.0f;
  201. break;
  202. case GLUT_KEY_F12:
  203. vrman->restart();
  204. break;
  205. case GLUT_KEY_UP:
  206. eye[2]-=0.5;
  207. aim[2]-=0.5;
  208. break;
  209. case GLUT_KEY_DOWN:
  210. eye[2]+=0.5;
  211. aim[2]+=0.5;
  212. break;
  213. case GLUT_KEY_LEFT:
  214. eye[0]-=0.5;
  215. aim[0]-=0.5;
  216. break;
  217. case GLUT_KEY_RIGHT:
  218. eye[0]+=0.5;
  219. aim[0]+=0.5;
  220. break;
  221. case GLUT_KEY_PAGE_UP:
  222. eye[1]+=0.5;
  223. aim[1]+=0.5;
  224. break;
  225. case GLUT_KEY_PAGE_DOWN:
  226. eye[1]-=0.5;
  227. aim[1]-=0.5;
  228. break;
  229. default:
  230. vrman->keyboard((unsigned char)key,x,y);
  231. break;
  232. }
  233. mycamera->SetValuev(UPDIRECTION,upright);
  234. mycamera->SetValuev(POSITION,eye);
  235. mycamera->SetValuev(AIMAT,aim);
  236. mycamera->Render();
  237. Display();
  238. }
worldmanager.cpp
  1. #include "worldmanager.h"
  2.  
  3. using namespace std;
  4.  
  5. void WorldManager::initialise(){
  6. myscene=new Scene;
  7. myscene->initialise();
  8. return;
  9. }
  10.  
  11. void WorldManager::restart(){
  12.  
  13.  
  14. }
  15.  
  16. void WorldManager::exec_loop(){
  17. //exectuion loop.
  18. render();
  19. }
  20.  
  21. void WorldManager::render(){
  22.  
  23. // Draw a scene
  24. myscene->render();
  25. }
  26.  
  27. void WorldManager::keyboard(unsigned char key,int x,int y)
  28. {
  29. myscene->keyboard(key,x,y);
  30. }
  31.  
  32. void WorldManager::mouse(int button, int state, int x,int y){
  33. return;
  34. }
  35.  
  36. void WorldManager::idle(){
  37. return;
  38. }

i'm thinking it could be a corrupt header file but i cant seem to find stdlib anywhere atleast not one that looks anything like what i have at the moment

-midi
Last edited by midimatt; Dec 31st, 2008 at 11:37 pm.
Reply With Quote