Results 1 to 7 of 7

Thread: Draw image behind collada sphere

  1. #1

    Default Draw image behind collada sphere

    I am trying to use the Object3D example to make a pool game with 3D balls, but i cant figure out how to draw an Image in the background and keep the ball on top. I have compared it with the lightsurface example and i cant find the difference that makes that one work.

    If I remove the following two lines, I can see the Image but the ball disappears and if I keep them I can see the ball but no Image.

    Code:
    CL_Mat4f perp = CL_Mat4f::perspective(45.0f, ((float) gc.get_width()) / ((float) gc.get_height()), 0.1f, 1000.0f);
                    gc.set_projection(perp);
    I guess there is some way to set the projection for the image ?

  2. #2
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    In the Object3D example.

    Add, just before the "while (!quit)" loop

    Code:
    	CL_Sprite spr_logo(gc, "../../Display/Basic2D/Resources/logo.png");
    Add, just before the "window.flip(1);"

    Code:
    	
    	gc.set_map_mode(cl_map_2d_upper_left);
    	gc.set_modelview(CL_Mat4f::identity());
    	spr_logo.draw(gc, 32, 32);
    	gc.set_map_mode(cl_user_projection);
    And you will get:
    Name:  clanlogo_on_object3d.png
Views: 8
Size:  106.6 KB

    to get it on the background.. move the code around a bit:

    Code:
    	
    	gc.clear(CL_Colorf::black);
    
    	gc.set_map_mode(cl_map_2d_upper_left);
    	gc.set_modelview(CL_Mat4f::identity());
    	spr_logo.draw(gc, 32, 32);
    	gc.set_map_mode(cl_user_projection);
    	CL_Mat4f perp = CL_Mat4f::perspective(45.0f, ((float) gc.get_width()) / ((float) gc.get_height()), 0.1f, 100000.0f);
    	gc.set_projection(perp);
    
    	gc.clear_depth(1.0f);

  3. #3

    Default

    First of all, thanks for the help. We were able to draw our collada balls on the sprite table. But we encountered a new problem after testing the game on different computers. It seems that on computers with Nvidia graphics cards everything except the 3D balls get very dark. The following screenshots is from two different machines, one with Nvidia graphics and one with Intel.

    Name:  baryard.png
Views: 10
Size:  332.5 KBName:  Screenshot-2.png
Views: 10
Size:  391.6 KB

    we also have problems with CL_Draw , everything gets white even if we try several different colours like :
    Code:
    CL_Draw::circle(gc_,82,41,10,CL_Colorf::gold);
    the circle and the texts "Duke Nukem" and "Megaman" on the screenshots is supposed to be coloured. it worked before we inserted the 3D balls.

  4. #4
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    I see you are using linux.

    Using Intel graphics card on linux currently causes problems.

    Looking at http://en.wikipedia.org/wiki/Intel_GMA ,the highest OpenGL spec is still OpenGL 2.1. Mostly 1.4 is supported.

    clanGL = OpenGL 2.x+
    clanGL1 = OpenGL 1.x

    So, it you do want to support intel cards, i'm afraid the only option is to drop down to the GL1 target. This is not a problem unless you use custom opengl GLSL shaders.

    However, iirc, you are already using GL1 via the Object3d example. If that is true, try running "Examples/Display_GL/cubegl1" ( http://esoteric.clanlib.org/~rombust...es/gl1cube.png ) to ensure that works.

    I am not sure at this time, what the other problems are.

  5. #5

    Default

    Actually we have no problems with Intel graphics, except for CL_Draw only drawing white circles and text, but maybe that is caused by the code being wrong somewhere?

    We get the problem with dark 2D only on Nvidia graphics cards, both in windows and linux. On one linux computer with nvidia graphics, we tried the game before installing the graphics drivers, and then both 2D and 3D was bright like we want it(with alot of lag). But after installing the correct drivers everything except the 3D balls got dark.

    After trying the game on two different computers with Intel graphics, and one with ATI, all with both 2D and 3D bright, while three different computers with Nvidia graphics got dark 2D we thought that the Nvidia graphics should be the problem.

    The following screenshot is from a Windows XP machine with Nvidia GeForce 8800 GT.

    Name:  WindowsXPnvidia.PNG
Views: 5
Size:  295.0 KB

  6. #6
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    It's difficult to guess the problem. but it's unlikely to be a fault with the driver, as you have described it.

    Myself and another developer also use NVidia 8800GT, and have not experienced problems (although not using the latest driver).

    Assuming the CL_Draw problems and the black display are actually the same problem,
    it may be caused by:
    1) The blend mode is not correct. gc.set_blend_mode(CL_BlendMode() ) - Might fix this
    2) The initial screen or a frame buffer was not cleared at the start of the program, leaving it in an uninitialised state (Maybe containing an alpha value of 0.0f). gc.clear(CL_Colorf::black) should fix this.
    3) The depth buffer was not cleared. (gc.clear_depth())
    4) The CL_PolygonRasterizer was not reset drawing the background. gc.set_polygon_rasterizer(CL_PolygonRasterizer ()) should fix this
    5) CL_BufferControl was not reset drawing the background. gc.set_buffer_control(CL_BufferControl()) should fix this

    Just a guess.

    Try removing functions until it works. If you can get it to a few lines, post the code to the forum.

    Other developers may be able to help at http://webchat.freenode.net/?channels=clanlib ,but be patient, a response might be slow.

  7. #7
    ClanLib Developer
    Join Date
    May 2007
    Posts
    1,824

    Default

    One last thing.

    If you are using clanGL1, it is possible it contains a bug. Try using clanGL on the NVidia card, if that works, there is a 99% changes it's a bug in clanGL1

Similar Threads

  1. draw sprites without background
    By Koli14 in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 01-14-2010, 09:26 AM
  2. CL_Surface draw a picture
    By DavinciZhe in forum Official ClanLib SDK Forums
    Replies: 2
    Last Post: 08-08-2009, 02:01 AM
  3. GDI Target Draw Problems
    By rombust in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 05-01-2009, 01:21 PM
  4. Rendering into my custom image and then drawing this image to the display
    By ValkaVALES in forum Official ClanLib SDK Forums
    Replies: 4
    Last Post: 07-03-2007, 09:53 AM
  5. Image help
    By in forum Dink Smallwood HD
    Replies: 2
    Last Post: 02-04-2004, 08:42 PM

Bookmarks

Bookmarks

Posting Permissions

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