2. PhysX Windows
Jump To:
main.cpp Source
Download
Main.CPP File: Now that we have our workspace setup for coding with the PhysX SDK, lets get a basic program up and running that incorporates OpenGL. I am going to start off with a base OpenGL program with a display function and reshape function, and the base GLUT code in our main function. The base of this program looks simply like this: // #include <GL\glut.h> // void display(void){ // glutSwapBuffers(); // void reshape(int w, int h){ // glViewport(0,0, (GLsizei)w, (GLsizei)h); // int main(int argc, char** argv) { // glutDisplayFunc(display); // glutMainLoop(); // return 0; // } So lets go ahead and create a function to initialize our PhysX SDK with. I am going to call this initNX. This is going to contain the code from the previous tutorial for Physics SDK: // void initNX(void){ Now that we have initialized the PhysX SDK, lets go ahead and create a cleanup function which I am going to call deinitNX: // void deinitNX(void){ These functions are going to be called from inside our main function: // int main(int argc, char** argv) { // glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_STENCIL); // initNX(); // glutDisplayFunc(display); // glutMainLoop(); // deinitNX(); // return 0; In my opinion, this is looking much neater and much more like a program than the last tutorial. So next up we are going to create a virtual scene for our physics calculations to take place. Check it out here. If you have any questions, just email me at swiftless@gmail.com #include <stdio.h> #include <GL\glut.h> #include <Physics\include\NxPhysics.h> #define NOMINMAX #include <windows.h> #pragma comment(lib,"PhysXLoader.lib") static NxPhysicsSDK* gPhysicsSDK = NULL; void initNX(void){ void deinitNX(void){ } void display(void){ glutSwapBuffers(); void reshape(int w, int h){ } int main(int argc, char** argv) { glutCreateWindow("Physics"); initNX(); glutDisplayFunc(display); glutMainLoop(); deinitNX(); return 0; |
Download: |