Results 1 to 2 of 2

Thread: glut|es problem

  1. #1
    Junior Member
    Join Date
    May 2006
    Posts
    1

    glut|es problem

    Hi

    I have been trying to compile a program using glut|es.

    I am using opengl|es 1.0 from intel (I am using an x50v with intel 2700 graphics) and the glut|es files. I have recompiled glut|es static lib using my setup.

    I can compile the sample from glut|es but whenevever I try to run it I get a small popup window which says 'unable to create opengl|es context' and gives an error code of 12293.

    Any suggestions?

    Tristan

  2. #2
    Junior Member
    Join Date
    May 2006
    Posts
    2
    Hi

    la soluce is the initialisation of Dsiplay, replace the code as follows :
    Code :
    int main(int argc, char *argv[])
    {
    	glutInit(&argc, argv);
    	//glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); // non supporté par le ES de l'axim
    	glutInitDisplayString("red=5 green=6 blue=5 depth=24");
    	glutCreateWindow("Robots");


    voici un exemple de moncode
    Code :
    /*
    Allows the simulation of motion of different kind of robots in 3D
    Copyright (C) 2006  Lotfi BAGHLI
     
    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public License
    as published by the Free Software Foundation; either version 2
    of the License, or (at your option) any later version.
     
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
     
    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    */
     
    #define GLUTES_STATIC
    #define GLES_CL
     
    #include <GLES/glutes.h>
    #include <GLES/glues.h>
    #include <GLES/glues.c>
    //____________________________________________________________
    // Joachim
    #define _F2X(_f_)       ((int)((_f_)*(65536)))
    #define _X2F(_x_)        ((float)(_x_)/65536.0f)
    #define _FV2XV(s,d,n)    { for (unsigned int _i_ = 0; _i_ < n; _i_++) (d)[_i_] = _F2X((s)[_i_]); }
    #define _XV2FV(s,d,n)    { for (unsigned int _i_ = 0; _i_ < n; _i_++) (d)[_i_] = _X2F((s)[_i_]); }
    #define _XPIOVERTWO        102943 //_F2X((3.1415926535f / 2.0f))
    #define _XPI            205887 //_F2X(3.1415926535f)
    #define _XTWOPI            411774 //_F2X((3.1415926535f * 2.0f))
    #define _XONE            (65536)
    #define _XADD(a,b)        a+b
    #define _XMUL(a,b)        ( (int)( ((__int64)(a)*(b)) >> 16 ) )
    #define _XDIV(a,b)        ( (int)( (((__int64)(a))<<16)/(b) ) )
     
    //-----------------------------------------------------------------------------
    // Fixed point support
    //-----------------------------------------------------------------------------
    #define ONE_FX 0x00010000
    #define HALF_FX 0x00008000
    #define PI_FX 0x0003243F		//
    #define TWOPI_FX 0x0006487E		//
     
    __inline GLfixed MulFX(GLfixed x, GLfixed y)
    {
    	__int64 r = ((__int64)x) * y;
    	return (GLint)(r >> 16);
    }
     
    __inline GLfixed DivFX(GLfixed x, GLfixed y)
    {
    	__int64 r = ((__int64)x)<<16;
    	return (GLint)(r/y);
    }
     
    __inline GLfixed RandFX()
    {
    	return (rand() & 0xFFFF);
    }
     
     
    #define IToFX(x) ((x) << 16)
    #define FToFX(x) ((GLfixed)((x)*65536.0f))
    #define FXFACTOR (1.0f/65536.0f)
    #define FXToF(x) ((float)(x)*FXFACTOR)
    __inline GLfixed SinFX(GLfixed x)
    {
    	return FToFX((float)sin(FXToF(x)));
    }
     
    __inline GLfixed CosFX(GLfixed x)
    {
    	return FToFX((float)cos(FXToF(x)));
    }
     
    __inline GLfixed TanFX(GLfixed x)
    {
    	return FToFX((float)tan(FXToF(x)));
    }
    //____________________________________________________________
     
     
    //---------------------------------------------------------------------------
    bool NO_KEYactive = true;
    bool KEY_LEFTactive = false;
    bool KEY_RIGHTactive = false;
    bool KEY_UPactive = false;
    bool KEY_DOWNactive = false;
    /*
    unsigned char *loadBMP(char *filename, BITMAPINFOHEADER *bmpInfo)
    {
    	FILE *file;
    	BITMAPFILEHEADER bmpFile;
    	unsigned char *bmpImage = NULL;
    	unsigned char tmpRGB;
    	TCHAR path[256];
    	char fullPath[256];
    	GetModuleFileName(NULL, path, 256);
    	TCHAR *pos = wcsrchr(path, '\\');
    	*(pos + 1) = '\0';
    	wcstombs(fullPath, path, 256);
    	strcat(fullPath, filename);
    	file = fopen(fullPath,"rb");
    	if (!file)
    		{
    		MessageBox(NULL, L"Can't Find Bitmap", L"Error", MB_OK);
    		return NULL;
    		}
    	fread(&bmpFile,sizeof(BITMAPFILEHEADER),1,file);
    	if (bmpFile.bfType != 0x4D42)
    		{
    		MessageBox(NULL, L"Incorrect texture type", L"Error", MB_OK);
    		fclose(file);
    		return NULL;
    		}
    	fread(bmpInfo,sizeof(BITMAPINFOHEADER),1,file);
    	fseek(file,bmpFile.bfOffBits,SEEK_SET);
    	bmpImage = new unsigned char[bmpInfo->biSizeImage];
    	if (!bmpImage)
    		{
    		MessageBox(NULL, L"Out of Memory", L"Error", MB_OK);
    		delete[] bmpImage;
    		fclose(file);
    		return NULL;
    		}
    	fread(bmpImage,1,bmpInfo->biSizeImage,file);
    	if (!bmpImage)
    		{
    		MessageBox(NULL, L"Error reading bitmap", L"Error", MB_OK);
    		fclose(file);
    		return NULL;
    		}
    	for (unsigned int i = 0; i < bmpInfo->biSizeImage; i+=3)
    		{
    		tmpRGB = bmpImage[i];
    		bmpImage[i] = bmpImage[i+2];
    		bmpImage[i+2] = tmpRGB;
    		}
    	fclose(file);
    	return bmpImage;
    }
    //---------------------------------------------------------------------------
    int fonctionTexture(int x,int y)
    {
      float dx=(32.0-(float)x)/63.0*40.0;
      float dy=(32.0-(float)y)/63.0*40.0;
      float a=cos(sqrt(dx*dx+dy*dy)+0.1);
      return (int)((a+1.0)/2.0*63);
    }
    //---------------------------------------------------------------------------
    bool loadTextures()
    {
    	BITMAPINFOHEADER info;
    	unsigned char *bitmap = NULL;
     
    	// Texture1
      int i,j, a;
    	unsigned char image[64][64][3];
    	// calcule de l'image 
      for (i=0;i<64;i++)
        for (j=0;j<64;j++)
          {
          a=fonctionTexture(i,j);
          image[i][j][0]=a;
          image[i][j][1]=128;
          image[i][j][2]=128;
          }
      glGenTextures(1, & GL_Form->texture1);
    	glBindTexture(GL_TEXTURE_2D, GL_Form->texture1);	
    	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 64, 64, 0, GL_RGB, GL_UNSIGNED_BYTE, image);
     
    	// TextureUHP
    	bitmap = loadBMP("uhp1.bmp", &info);
    	if (!bitmap)	return false;
      glGenTextures(1, & GL_Form->textureUHP);
    	glBindTexture(GL_TEXTURE_2D, GL_Form->textureUHP);	
    	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, info.biWidth, info.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmap);
     
    	bitmap = loadBMP("uhpgreen.bmp", &info);
    	if (!bitmap)	return false;
      glGenTextures(1, & GL_Form->textureUHPGREEN);
    	glBindTexture(GL_TEXTURE_2D, GL_Form->textureUHPGREEN);	
    	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, info.biWidth, info.biHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, bitmap);
    	delete[] bitmap;
     
    	return true;
    }
    */
    //---------------------------------------------------------------------------
    bool init()
    {
    /*
    	if (!loadTextures())
    	{
    		MessageBox(NULL, L"Error loading textures", L"Error", MB_OK);
    		return false;
    	}
     
      GL_Form->makeRasterFont();
    */
    //________________fin
    //	glEnable(GL_LIGHTING);
    //	glEnable(GL_LIGHT0);
    	glCullFace(GL_BACK);	
    	glEnable(GL_CULL_FACE);	// face interne cachées
    	glEnable(GL_DEPTH_TEST);
    	glDepthFunc(GL_LEQUAL);
    	glDisable(GL_TEXTURE_2D);
    	glClearColorx(FToFX(0.8), FToFX(0.8), FToFX(0.8), FToFX(0.8));// fond
    	glClearDepthx(FToFX(1.0));
    //	MessageBox(NULL, L"Init OK", L"Debug", MB_OK);
    	return true;
    }
    //---------------------------------------------------------------------------
    void display()
    {
    //	GL_Form->DrawScene();
    }
    //---------------------------------------------------------------------------
    void idle()
    {
    // if (GL_Form->Timer)
    //		{
    //	GL_Form->xrot += 2.0f;
    //	GL_Form->yrot += 0.5f;
     
    //	GL_Form->TimerTicks();	// à revoir avec un timer !
     
    //		}
    	glutPostRedisplay();
    }
    //---------------------------------------------------------------------------
    void keyboardspe(int key, int x, int y)
    {
     
    	if (key == GLUT_KEY_DOWN && !KEY_DOWNactive)
    			{
    			KEY_DOWNactive=true;
    			return;
    			}
    	if (key == GLUT_KEY_UP && !KEY_UPactive)
    			{
    			KEY_UPactive=true;
    			return;
    			}
    	if (key == GLUT_KEY_RIGHT)		exit(0); 
    	if (key == GLUT_KEY_LEFT)		
    			{
    			glutSimulateButton(GLUT_RIGHT_BUTTON, 10, 20);
    			return;
    			}
    }
    //---------------------------------------------------------------------------
    void keyboardspeup(int key, int x, int y)
    {
    	NO_KEYactive=true;
    	KEY_LEFTactive = false;
    	KEY_RIGHTactive =false;
    	KEY_UPactive = false;
    	KEY_DOWNactive=false;
    }
    //---------------------------------------------------------------------------
    void mouse(int button, int state, int x, int y)
    {
    	if (NO_KEYactive)	{
    						NO_KEYactive=false;
    						}
    }
    //---------------------------------------------------------------------------
    void reshape(int width, int height)
    {
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
     
    	glViewport(0, 0, width, height);
    //	gluPerspectivef(45.0f, 1.0f * width / height, 1.0f, 100.0f);
    	gluPerspectivex(FToFX(45.0), FToFX(width / height), FToFX(0.01), FToFX(100.0));
     
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
    }
    //---------------------------------------------------------------------------
    void menu(int entry)
    {
    	switch(entry)
    	{
    	case 1 : exit(0); break;
    	}
    }
    //---------------------------------------------------------------------------
    int main(int argc, char *argv[])
    {
    	glutInit(&argc, argv);
    	//glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); // non supporté par le ES de l'axim
    	glutInitDisplayString("red=5 green=6 blue=5 depth=24");
    	glutCreateWindow("Robots");
     
     
    	if (!init())
    		return 1;
     
    	glutDisplayFunc( display);
    	glutReshapeFunc( reshape);
    	glutSpecialFunc( keyboardspe);
    	glutSpecialUpFunc( keyboardspeup);
    	glutMouseFunc( mouse);
     
    	glutIdleFunc(idle);
     
    	glutCreateMenu(menu);
    	glutAddMenuEntry("Pilotage Auto 4 All", 4);
    	glutAddMenuEntry("Reset Robots", 3);
    	glutAddMenuEntry("Reset View", 2);
    	glutAddMenuEntry("Quit", 1);
     
    	glutAttachMenu(GLUT_RIGHT_BUTTON);
    //	glutAttachMenu(GLUT_LEFT_BUTTON);
     
    	glutMainLoop();
     
    	return 0;
    }

Similar Threads

  1. help me please for GLUT ES
    By guyunduzou in forum OpenGL ES general technical discussions
    Replies: 1
    Last Post: 07-11-2008, 11:10 AM
  2. glut es beginer
    By saurabhgoyal in forum OpenGL ES general technical discussions
    Replies: 2
    Last Post: 10-09-2006, 05:17 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •