PDA

View Full Version : How to define a bitmap in Delphi?



earth_walker
07-11-2003, 10:14 AM
Hi!

I tried to define and display a bitmap in Delphi 5.0 with OpenGL, but failed, because I only have the reference book on C but not Delphi, can you help me to see what is the error?

Thank you!

Following is my code:

declaration



var rasters: array of GLubyte;


OnCreate



SetLength(rasters, 24);
rasters[0]:=$ff; rasters[1]:=$ff; rasters[2]:=$ff;
rasters[3]:=$ff; rasters[4]:=$ff; rasters[5]:=$ff;
rasters[6]:=$ff; rasters[7]:=$ff; rasters[8]:=$ff;
rasters[9]:=$ff; rasters[10]:=$ff; rasters[11]:=$ff;
rasters[12]:=$ff; rasters[13]:=$ff; rasters[14]:=$ff;
rasters[15]:=$ff; rasters[16]:=$ff; rasters[17]:=$ff;
rasters[18]:=$ff; rasters[19]:=$ff; rasters[20]:=$ff;
rasters[21]:=$ff; rasters[22]:=$ff; rasters[23]:=$ff;


OnResize



glViewport(0, 0, ClientWidth, ClientHeight);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1 ,1, -1, 1, 0, 10);
MyDraw;


MyDraw



//clear the screen
glClearColor(0,1,0,0);
glClear(GL_COLOR_BUFFER_BIT);
{some code}
glMatrixMode(GL_MODELVIEW);
glLoadIdentity;
gluLookAt(0,0,0, 0,0,1, 0,1,0);
{some code}
//display the bitmap
glRasterPos3f(0,0,2);
glBitmap(16, 12, 0, 0, 20, 0, rasters);
glBitmap(16, 12, 0, 0, 20, 0, rasters);
glBitmap(16, 12, 0, 0, 20, 0, rasters);
SwapBuffers(Canvas.Handle);

Sourpotato
07-12-2003, 12:09 AM
friend,please have a look at this place
http://www.delphi-gems.com/Graphics.php

earth_walker
07-12-2003, 08:38 PM
Thank you! I will read it.