|
Post by Nicky Peter Hollyoake on Jan 14, 2009 2:45:04 GMT -5
How does pointers work in C++? I mean in Basic4GL, its simple as ...
Alloc Pointer, 1000
etc, etc ...
In C++ I don't think its that simple.
Another question, I see in Basic4GL that we have the "Swapbuffers()" function, obviously this ain't an OpenGL function is it? How is it made?
- Nicky
|
|
|
Post by DJLinux on Jan 14, 2009 6:13:51 GMT -5
in C you can allocate and free memory with "pointer=malloc(size)" and "free(pointer)" in C++ you can use "new" and "new[]" "delete" and "delete[]" too
OpenGL is "only" to make 2D and 3D gfx the blitting of the rendered image is the part of the OS on windows wglSwapBuffers() on Linux glxSwapBuffers()
Joshy
|
|
|
Post by Nicky Peter Hollyoake on Jan 14, 2009 11:17:10 GMT -5
in C you can allocate and free memory with "pointer=malloc(size)" and "free(pointer)" in C++ you can use "new" and "new[]" "delete" and "delete[]" too OpenGL is "only" to make 2D and 3D gfx the blitting of the rendered image is the part of the OS on windows wglSwapBuffers() on Linux glxSwapBuffers() Joshy Thanks much! Just out of interest how would you determine what OS its running on if you want your program to run on both OS's? - Nicky
|
|
|
Post by DJLinux on Jan 14, 2009 14:53:50 GMT -5
there are predined defines in your compiler environment
#ifdef _WIN32 # include "win_things.h" #else # include "lin_things.h" #endif
if you use no IDE with project support you can use diffrent makefiles or targets inside a makefile
Joshy
|
|
|
Post by Nicky Peter Hollyoake on Jan 14, 2009 15:38:11 GMT -5
What is this "ifdef" stuff doing being put after the hash? What does it exectly do?
|
|
|
Post by Darkjester on Jan 14, 2009 16:19:53 GMT -5
IF defined... hint hint...
|
|
|
Post by DJLinux on Jan 14, 2009 16:37:48 GMT -5
What is this "ifdef" stuff doing being put after the hash? What does it exectly do? all commands with a hash are for the C/C++ preprocessor #define USE_WIN32 // now it exist a defined symbol "USE_WIN32" #ifdef USE_WIN32 ' same in BASIC "if value then" // in case of windows #include "windows.h" #include "GL\opengl.h" #include "my_windows_lib.h" #else // in the case of linux #include "X11.h" #include "GL/GLX.h" #include "my_linux_lib.h" #endif in pratice you can have two files to open a Window one for WIN32 and the other for Linux x86 but both have the same name "CreateWindow" and params #ifdef _WIN32 #include "my_windows_lib.h" #else #include "my_linux_lib.h" #endif // later in your code you can use the same code for Win and Lin hMyWindow=CreateWindow(640,480,32,"a window on Lin and Win!")
|
|
|
Post by Nicky Peter Hollyoake on Jan 15, 2009 3:18:18 GMT -5
Ah I see thanks alot! I probaly will only create programs for window anyways, but you never know what I might decide in the future. ;D
- Nicky
|
|