Results 1 to 10 of 10

Thread: problem with the back of a box (building)

  1. #1
    Junior Member
    Join Date
    Mar 2008
    Posts
    15

    problem with the back of a box (building)

    Hello,
    excuse for my English.

    I am learning OpenGL ES and I have a problem that I can't solve. I have 2 boxes (buildings) and I "walk around" it. I move the camera in Z. When I arrive at the end of the first building, the building continue. If I continue, the building disappear then the scene change totally.

    How could I insert screenshot from my computer ?

    thanks

    My code :

    Code :
     
    #pragma comment(lib, "libGLES_CM.lib")
    #pragma comment(lib, "ug.lib")
     
    #include "GLES/ug.h"
     
    int w = 0;
    int h = 0;
     
    float X,Y,Z;
    float Zinit = 0;
    float Yinit = 2;
    float Xinit = 4;
     
    float XanglRight,XanglLeft;
     
    GLuint texture[1];
     
    GLfloat sol[] = {
    	-50,0,10,
    	-50,0,-100,
    	60,0,10,
    	60,0,-100,
    };
     
     
    GLfloat box1[] = {
    	// FRONT
    	0, 0, -10,
    	3, 0, -10,
    	0, 7, -10,
    	3, 7, -10,
    	// BACK
    	0, 0, -30,
    	3, 0, -30,
    	0, 7, -30,
    	3, 7, -30,
    	// LEFT
    	0, 0, -30,
    	0, 7, -30,
    	0, 0, -10,
    	0, 7, -10,
    	// RIGHT
    	3, 0, -30,
    	3, 7, -30,
    	3, 0, -10,
    	3, 7, -10,
    	// TOP
    	0, 7, -30,
    	3, 7, -30,
    	0, 7, -10,
    	3, 7, -10,
    	// BOTTOM
    	0, 0, -30,
    	3, 0, -30,
    	0, 0, -10,
    	3, 0, -10,
    };
     
    GLfloat box2[] = {
    	// FRONT
    	0, 0, -7,
    	3, 0, -7,
    	0, 5, -7,
    	3, 5, -7,
    	// BACK
    	0, 0, -9,
    	3, 0, -9,
    	0, 5, -9,
    	3, 5, -9,
    	// LEFT
    	0, 0, -9,
    	0, 5, -9,
    	0, 0, -7,
    	0, 5, -7,
    	// RIGHT
    	3, 0, -9,
    	3, 5, -9,
    	3, 0, -7,
    	3, 5, -7,
    	// TOP
    	0, 5, -9,
    	3, 5, -9,
    	0, 5, -7,
    	3, 5, -7,
    	// BOTTOM
    	0, 0, -9,
    	3, 0, -9,
    	0, 0, -7,
    	3, 0, -7,
    };
     
    GLfloat box3[] = {
    	// FRONT
    	0, 0, -10,
    	4, 0, -10,
    	0, 5, -10,
    	4, 5, -10,
    	// BACK
    	0, 0, -15,
    	4, 0, -15,
    	0, 5, -15,
    	4, 5, -15,
    	// LEFT
    	0, 0, -15,
    	0, 5, -15,
    	0, 0, -10,
    	0, 5, -10,
    	// RIGHT
    	4, 0, -15,
    	4, 5, -15,
    	4, 0, -10,
    	4, 5, -10,
    	// TOP
    	0, 5, -15,
    	4, 5, -15,
    	0, 5, -10,
    	4, 5, -10,
    	// BOTTOM
    	0, 0, -15,
    	4, 0, -15,
    	0, 0, -10,
    	4, 0, -10,
    };
     
     
    void draw();
     
    void init(){
    	glEnable(GL_DEPTH_TEST);
    	glDepthFunc(GL_LESS);
     
    	glClearColor(0,0.6,1,1);//bleu
    	glClearDepthf(1);
     
    	glEnableClientState(GL_VERTEX_ARRAY);//pour desiner
     
    	glShadeModel(GL_FLAT); // enleve les dégradés de couleur
     
    	X = Xinit;
    	Y = Yinit;
    	Z = Zinit;
     
    	glMatrixMode(GL_PROJECTION);
    	glLoadIdentity();
     
    	ugluPerspectivef(45.0f, w/h, 1.0f, 100.0f);
    	//ugluPerspectivef(45, 1.0f * w / h, 0, 100.0);
    	//glOrthof(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 20.0f);
    	//glFrustumf(-3,16,-1,10,1,100);
    }
     
     
     
     
    void display(UGWindow uwin){
    	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     
    	glMatrixMode(GL_MODELVIEW);
    	glLoadIdentity();
     
    	ugluLookAtf(
    		X, Y, Z,
    		X, Y, Z-1,
    		0, 1, 0);
     
       draw();
     
       glFlush();
       ugSwapBuffers(uwin);
    }
     
    void draw(){
    	glVertexPointer(3, GL_FLOAT, 0, sol);
    	glColor4f(1, 1, 1, 1);//blanc
    	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
     
    	glVertexPointer(3, GL_FLOAT, 0, box1);
    	glColor4f(1.0f, 0.0f, 0.0f, 1.0f);//red
    	//glColor4f(0.8, 0.8, 0.8, 1.0f);//gris
    	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);//front
    	glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);//back
    	glDrawArrays(GL_TRIANGLE_STRIP, 8, 4);//left
    	glDrawArrays(GL_TRIANGLE_STRIP, 12, 4);//right
    	glDrawArrays(GL_TRIANGLE_STRIP, 16, 4);//top
    	glDrawArrays(GL_TRIANGLE_STRIP, 20, 4);//bottom
     
    	glTranslatef(5,0,0);
    	glVertexPointer(3, GL_FLOAT, 0, box2);
    	glColor4f(0.0f, 1.0f, 0.0f, 1.0f); //green
    	//glColor4f(0.6, 0.6, 0.6, 1.0f);//
    	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);//front
    	glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);//back
    	glDrawArrays(GL_TRIANGLE_STRIP, 8, 4);//left
    	glDrawArrays(GL_TRIANGLE_STRIP, 12, 4);//right
    	glDrawArrays(GL_TRIANGLE_STRIP, 16, 4);//top
    	glDrawArrays(GL_TRIANGLE_STRIP, 20, 4);//bottom
     
    	glTranslatef(5,0,0);
    	glVertexPointer(3, GL_FLOAT, 0, box3);
    	glColor4f(0.0f, 0.0f, 1.0f, 1.0f);//blue
    //	glColor4f(0.4, 0.4, 0.4, 1.0f);//
    	glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);//front
    	glDrawArrays(GL_TRIANGLE_STRIP, 4, 4);//back
    	glDrawArrays(GL_TRIANGLE_STRIP, 8, 4);//left
    	glDrawArrays(GL_TRIANGLE_STRIP, 12, 4);//right
    	glDrawArrays(GL_TRIANGLE_STRIP, 16, 4);//top
    	glDrawArrays(GL_TRIANGLE_STRIP, 20, 4);//bottom
    }
     
    void keyboard(UGWindow uwin, int key, int x, int y){
    	switch(key){
    	case 'z' :
    		Z -= 1;
    		ugPostRedisplay(uwin);
    		break;
    	case 's': 
    		Z += 1;
    		ugPostRedisplay(uwin);
    		break;
    	case 'q' :
    		X -= 1;
    		ugPostRedisplay(uwin);
    		break;
    	case 'd' :
    		X += 1;
    		ugPostRedisplay(uwin);
    		break;
    	case 'r' :
    		Y += 1;
    		ugPostRedisplay(uwin);
    		break;
    	case 'f' :
    		Y -= 1;
    		ugPostRedisplay(uwin);
    		break;
    	}
    }
     
    int main(){
    	UGCtx ug = ugInit();
     
    	w = 250;
    	h = 250;
    	UGWindow uwin = ugCreateWindow(ug, "", "proto", w, h, 100, 100);
     
    	init();
     
    	ugDisplayFunc(uwin, display);
    	ugKeyboardFunc(uwin, keyboard);
     
    	ugMainLoop(ug);
     
    	return 0;
    }
    [/code]

  2. #2
    Junior Member
    Join Date
    Mar 2008
    Posts
    15
    I searched all this day and I don't know what is happenning.

    I discovered that the problem comes when the camera arrives to the front of the building.

    I colored the faces to see what faces are wrong and when the camera is after the front side (the front is behind us), I see the back side and the left side, the right, the top and the bottom sides go to the infinite.


    Could be an orientation problem ?

    Thanks

  3. #3
    Junior Member
    Join Date
    Mar 2008
    Posts
    15
    I wondered if this problem came from the UG library or the implementation of OpenGL ES (Vincent). So I tried with an other implementation (Rasteroid) and now it works. I don't know if the UG library has a display bug or if it is an other problem but I don't have this with the rasteroid implementation.

  4. #4
    Hey there,

    Your problem sound like the problem im having.

    http://khronos.org/message_boards/viewtopic.php?t=1008

    Im going try change to Rasteroid but i have a problem changing...
    Everything looks nice.. it compiles but when im going to run the application on the emulator, it says theres a library missing.
    I think i missed something, since it works with Vincent.

    May i see your sample running under Rasteroid?

    thanks

  5. #5
    Senior Member
    Join Date
    Sep 2003
    Location
    Seattle, WA
    Posts
    246
    There is an issue for which the fix did not make it into SVN for the last 18 months or so:

    http://ogl-es.svn.sourceforge.net/viewv ... iew=markup

    remove lines 671/672

    http://ogl-es.svn.sourceforge.net/viewv ... iew=markup

    remove lines 590/591

    Let me know if this solves your problem. If it does, feel free to check it back into the project source tree.

    - HM

  6. #6
    Junior Member
    Join Date
    Mar 2008
    Posts
    15

    PostPosted: Tue Mar 18, 2008 2:53 am Post subject:
    There is an issue for which the fix did not make it into SVN for the last 18 months or so:

    http://ogl-es.svn.sourceforge.net/viewv ... iew=markup

    remove lines 671/672

    http://ogl-es.svn.sourceforge.net/viewv ... iew=markup

    remove lines 590/591

    Let me know if this solves your problem. If it does, feel free to check it back into the project source tree.

    - HM

    These links drove me on the source code of which implementation ? (Vincent's no ?).

    An other thing, I think I did not understand your first sentence (I'm French) so could you explain it ?

    I understood that I had to remove these lines then compile the sources and test. I am developping in a XP machine and I don't know how to compile this code so how can I test this ?

    Thanks for your help.



    Hey there,

    Your problem sound like the problem im having.

    http://khronos.org/message_boards/viewtopic.php?t=1008

    Im going try change to Rasteroid but i have a problem changing...
    Everything looks nice.. it compiles but when im going to run the application on the emulator, it says theres a library missing.
    I think i missed something, since it works with Vincent.

    May i see your sample running under Rasteroid?

    thanks
    I think we have the same problem.

    To solve your problem of library, try to put the 2 DLL of the Rasteroid library (libGLES_CM_NoE.lib and libEGL.lib ) on your emulator windows folder via the shared folder (see the zeusCmd tutorial if you don't see what I mean : http://www.zeuscmd.com/tutorials/opengl ... onment.php)

  7. #7
    I changed everything to use the rasteroid implementation

    Changed the include, the lib.. etc.

    The library Rasteroid i have, its called libGLES_CM_NoE.

    I had also to change the name of the library used by tge GLUT|ES.
    Because of the different name between the Vincent (libGLES_CM) and Rasteroid (libGLES_CM_NoE), i changed in the glutes.h.. was libGLES_CM and i changed to libGLES_CM_NoE.

    Currently, everything compile and link perfect but, when is everything in the emulator and i try to execute the application it appears "Unable to Initializa OpenGL|ES".
    Yes, i copied the libGLES_CM_NoE.dll and also the libEGL.dll to the windows folder in the emulator.

    May someone help me with that? I would appreciate any help or tip.

    Thank you

  8. #8
    Hey hmwill,

    The changes fixed the problem. thank you.

    I have one question. Im using the sourcecode found zipped in the download area. Theres any difference between the sourcecode i could download from the svn?

    []

    Wendel B Silva

  9. #9
    Junior Member
    Join Date
    Mar 2008
    Posts
    15
    So, you deleted these four lines and it works fine now ?

    Great...

    On which system did you compile ?

    If it is in Windows, could you give me the compiled files because I don't know how to do ??

    Thanks you

  10. #10
    I downloaded the sourcecode found in the ogles sourceforge project.

    I come with the project to compile in EVC4, VC7 and VC8... just download, open the project and change the source code,....

    In the sourcecode i downloaded, was only 2 lines.. not 4 like mentioned.. i believe i downloaded an old version of the lib.

    http://rapidshare.com/files/102590964/l ... M.dll.html

    []

    Wendel B Silva

Similar Threads

  1. Replies: 0
    Last Post: 02-27-2013, 12:26 AM
  2. Open Box Problem
    By p0pes in forum Developers Coding:Beginner
    Replies: 2
    Last Post: 04-12-2011, 11:50 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
  •