Codesnippets > Code Snippets
OpenGL calls
Kitty Hello:
Well, here's a small snippet that shows how to use all the OpenGL calls (in case you're missing something) from GLBasic. It uses the INLINE command, however.
--- Code: (glbasic) ---// --------------------------------- //
// Project: OpenGL - OpenGL calls through INLINE
// Start: Thursday, October 12, 2006
// IDE Version: 3.283
// Make a texture
FILLRECT 0,0,64,64,RGB(0x80, 0x80, 0xff)
PRINT "GLBasic", 1,1
GRABSPRITE 1, 0,0,64,32
BLACKSCREEN
// create 3D viewport + set texture
X_MAKE3D 1,10,45
X_CAMERA 0,0,5, 0,0,-1
X_SETTEXTURE 1,-1
// start OpenGL calls
TryGL()
SHOWSCREEN
MOUSEWAIT
// this function is required to close the MainGame function
@FUNCTION dummy:
ENDFUNCTION
// here we need an inline block _outside_ of functions, that
// gives us some prototypes for glX calls.
INLINE
} // end namespace __GLBASIC__ - see manual for INLINE
// some constants - for more see:
// http://www.css.taylor.edu/~btoll/resources/graphics/opengl/xp/gl.h
#define GL_QUADS 0x0007
// the functions are all >>extern "C" __stdcall
bigsofty:
Aha, so thats how its done!
finally a way into the rendering pipeline, cool :D
Thanks Gernot, this little old GLBasic program sure is flexible ;)
Kitty Hello:
Here's an update how to diretcly write to texture pixels:
--- Code: (glbasic) ---// --------------------------------- //
// Project: OpenGL - OpenGL calls through INLINE
// Start: Thursday, October 12, 2006
// IDE Version: 3.283
// Make a texture
FILLRECT 0,0,64,64,RGB(0x80, 0x80, 0xff)
PRINT "GLBasic", 1,1
GRABSPRITE 1, 0,0,64,32
BLACKSCREEN
SHOWSCREEN
// create 3D viewport + set texture
// start OpenGL calls
WHILE TRUE
X_MAKE3D 1,10,45
X_CAMERA 0,0,5, 0,0,-1
TryGL()
SHOWSCREEN
WEND
MOUSEWAIT
// this function is required to close the MainGame function
@FUNCTION dummy:
ENDFUNCTION
// here we need an inline block _outside_ of functions, that
// gives us some prototypes for glX calls.
INLINE
} // end namespace __GLBASIC__ - see manual for INLINE
// some constants - for more see:
// http://mvb.saic.com/freeware/freewarev40/mesa/include/gl/gl.h
#define GL_QUADS 0x0007
// the functions are all >>extern "C" __stdcall
bigsofty:
Again, very handy info.
GLBasic can really do a lot more than its command set initially would reveal.
Minion:
Genot,
Ive had a look at this and im not quite sure i understand whats going on, but hey ho, i`ll carry on racking my brains until i wouk out what is actually happening.
I`ll ask now before I contiue tho. Is this actually creating/modifing a bmp that can be used as a sprite etc, or is it soley a texture for 3d ? (am trying to build bmps on the fly so to speak). And how would I go about thowing variables in and out of the inline code ? ( basically arrays )
Sorry if this is a noddy question, but ive pondered this code for 3 days now and if im not running on the right trcks I`d sooner get off this train and get on the right one.
Navigation
[0] Message Index
[#] Next page
Go to full version