I am trying to use opengl to create 2D color contour plot of some 
engineering data.  I found the code below which colors a triangle with 
contours using opengl.  I have been trying to convert it to work in 
Gambas.  See below my current version converted to Gambas.  I am asking 
for assistance for finishing the code conversion and to get these 
routines to run in Gambas.  Help would be most appreciated.


CODE WHICH I AM TRYING TO CONVERT AND RUN IN GAMBAS:

void CContoursDoc:: CreateTextureObject()
{
     / / Define texture image
     unsigned char Texture8[8][3] =
     {
         { 0x00, 0x00, 0xa0 }, / / Dark Blue
         { 0x00, 0x00, 0xff }, / / Blue
         { 0x00, 0xa0, 0xff }, / / Indigo
         { 0x00, 0xa0, 0x40 }, / / Dark Green
         { 0x00, 0xff, 0x00 }, / / Green
         { 0xff, 0xff, 0x00 }, / / Yellow
         { 0xff, 0xcc, 0x00 }, / / Orange
         { 0xff, 0x00, 0x00 } / / Red
     };

     / / Set pixel storage mode
     :: glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

     / / Generate a texture name
     :: glGenTextures(1, m_nTexName);

     / / Create a texture object
     :: glBindTexture(GL_TEXTURE_1D, m_nTexName[0]);
     :: glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MAG_FILTER,
         GL_NEAREST);
     :: glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_MIN_FILTER,
         GL_NEAREST);
     :: glTexImage1D(GL_TEXTURE_1D, 0, 3, 8, 0, GL_RGB,
         GL_UNSIGNED_BYTE, Texture8);
}

void CContoursDoc:: CreateTriangleList(UINT nList)
{
     :: glNewList(nList, GL_COMPILE);
     :: glNormal3f(0.0 f, 0.0 f, 1.0 f);

     :: glBegin(GL_TRIANGLES);
         :: glTexCoord1f(0.1 f);
         :: glVertex3d(-1, -1, 0);
         :: glTexCoord1f(0.7 f);
         :: glVertex3d(-1, 1, 0);
         :: glTexCoord1f(1.0 f);
         :: glVertex3d(1, 0.8, 0);
     :: glEnd();
     :: glEndList();
}

MY CURRENT GAMBAS CODE:

Sub CreateTextureObject()
     Dim m_nTexName As New Integer[1]

     'Define texture image
     '???????????????? I could not figure how to convert the array data 
for the texture ?????????????????????????

     'Set pixel storage mode
     gl.PixelStorei(gl.UNPACK_ALIGNMENT, 1)

     'Generate a texture name
     m_nTexName = gl.GenTextures(1)

     'Create a texture object
     gl.BindTexture(gl.TEXTURE_1D, m_nTexName[0])
     gl.TexParameteri(gl.TEXTURE_1D, gl.TEXTURE_MAG_FILTER, gl.NEAREST)
     gl.TexParameteri(gl.TEXTURE_1D, gl.TEXTURE_MIN_FILTER, gl.NEAREST)
     '
     ' Gambas3 help lists different parameters for teximage1d than open 
gl documents
     'Static Sub *TexImage1D* ( _Image_ As Image 
<http://gambaswiki.org/wiki/comp/gb.qt4/image> *[* , _Level_ As Integer, 
_Border_ As Integer *]* )
     'how do you convert the next statement to work with Gambas gl 
component?
     '
     gl.TexImage1D(gl.TEXTURE_1D, 0, 3, 8, 0, gl.RGB, gl.UNSIGNED_BYTE, 
Texture8)

End

Sub CreateTriangleList(nList As Integer)

     gl.NewList(nList, gl.COMPILE)
     gl.Normal3f(0.0, 0.0, 1.0)

     gl.Begin(gl.TRIANGLES)
         gl.TexCoord1f(0.1)
         gl.Vertex3f(-1.0, -1.0, 0.0)
         gl.TexCoord1f(0.7)
         gl.Vertex3f(-1.0, 1.0, 0.0)
         gl.TexCoord1f(1.0)
         gl.Vertex3f(1.0, 0.8, 0.0)
     gl.End()
     gl.EndList()

End

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to