kryton9
08-05-2007, 06:44
Inspired by Matthews work and the NeHe lessons and of course Petr's tutorials. I decided tonight to see if I could do a conversion. After some work I did, so am very happy.
I got the c code and read the tutorial at this site:
http://www.gmonline.demon.co.uk/cscene/CS5/CS5-03.html
Here is the code I looked at:
/**********************************************************************/
/******************************************/
/* A Very Simple OpenGL Example! */
/******************************************/
/* this code just creates a window and draws a rectangle in it */
#include <windows.h> /* obviously change this to your native library
if you're compiling under unix */
#include <gl\gl.h>
#include <gl\glut.h>
void init(void);
void display(void);
int main (int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("My First OpenGL Application");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-5.0, 5.0, 5.0, -5.0);
glutSwapBuffers();
}
/**********************************************************************/
Here is the thinBasic conversion I did, woo hoo!!
'---thanks to Petr and Matthew for great examples
uses "tbgl"
uses "ui"
#include "%app_includepath%\thinbasic_gl.inc"
#include "%app_includepath%\thinbasic_glu.inc"
dim hwnd as dword
hwnd = tbgl_createwindowex("my first opengl application - esc to exit", 250, 250, 32, 0)
tbgl_showwindow
tbgl_getasynckeystate(-1)
while tbgl_iswindow(hwnd)
tbgl_clearframe
init
display
tbgl_drawframe
if tbgl_getwindowkeystate( hwnd, %vk_escape) then exit while
wend
tbgl_destroywindow
sub init()
glclearcolor(0.0, 0.0, 0.0, 0.0)
glcolor3f(0.0, 0.0, 1.0)
glmatrixmode(%gl_projection)
glloadidentity()
glortho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0)
end sub
sub display()
glclear(%gl_color_buffer_bit)
glrectf(-5.0, 5.0, 5.0, -5.0)
end sub
I got the c code and read the tutorial at this site:
http://www.gmonline.demon.co.uk/cscene/CS5/CS5-03.html
Here is the code I looked at:
/**********************************************************************/
/******************************************/
/* A Very Simple OpenGL Example! */
/******************************************/
/* this code just creates a window and draws a rectangle in it */
#include <windows.h> /* obviously change this to your native library
if you're compiling under unix */
#include <gl\gl.h>
#include <gl\glut.h>
void init(void);
void display(void);
int main (int argc, char **argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
glutInitWindowSize(250, 250);
glutInitWindowPosition(100, 100);
glutCreateWindow("My First OpenGL Application");
init();
glutDisplayFunc(display);
glutMainLoop();
return 0;
}
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glColor3f(0.0, 0.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glRectf(-5.0, 5.0, 5.0, -5.0);
glutSwapBuffers();
}
/**********************************************************************/
Here is the thinBasic conversion I did, woo hoo!!
'---thanks to Petr and Matthew for great examples
uses "tbgl"
uses "ui"
#include "%app_includepath%\thinbasic_gl.inc"
#include "%app_includepath%\thinbasic_glu.inc"
dim hwnd as dword
hwnd = tbgl_createwindowex("my first opengl application - esc to exit", 250, 250, 32, 0)
tbgl_showwindow
tbgl_getasynckeystate(-1)
while tbgl_iswindow(hwnd)
tbgl_clearframe
init
display
tbgl_drawframe
if tbgl_getwindowkeystate( hwnd, %vk_escape) then exit while
wend
tbgl_destroywindow
sub init()
glclearcolor(0.0, 0.0, 0.0, 0.0)
glcolor3f(0.0, 0.0, 1.0)
glmatrixmode(%gl_projection)
glloadidentity()
glortho(-10.0, 10.0, -10.0, 10.0, -10.0, 10.0)
end sub
sub display()
glclear(%gl_color_buffer_bit)
glrectf(-5.0, 5.0, 5.0, -5.0)
end sub