opengl view question

Member
Posts: 105
Joined: 2007.03
Post: #1
Something very strange is happening in my engine's tile drawing routine(s)(tiles=textured quads). I normally draw only the tiles which are visible(and nearly visible so there's no abrupt popping of tiles) but for some odd reason opengl initially only draws tiles which are immediately and completely within the bounds of the window or view.

If I decrease the size of the view/window, everything is drawn properly(I don't have any special reshape function if it makes any difference).

The pic on the right is how it appears normally, and the pic on the left is after I have decreased the size of the window/view(after decreasing it, I can then resize it anyway I like and everything will still draw properly.

http://web.mac.com/aleister55/iWeb/Site/Blank%202.html

Anyone have an idea of what might be going on?
Quote this message in a reply
Moderator
Posts: 371
Joined: 2006.08
Post: #2
sounds like your algorithm for checking if tiles are "nearly visible so there's no abrupt popping of tiles" is accounting for the resizing of the window. (or calculating it wrong somehow); can you post the code that conducts that test?
-wyrmmage

Worlds at War (Current Project) - http://www.awkward-games.com/forum/
Quote this message in a reply
Member
Posts: 105
Joined: 2007.03
Post: #3
wyrmmage Wrote:sounds like your algorithm for checking if tiles are "nearly visible so there's no abrupt popping of tiles" is accounting for the resizing of the window. (or calculating it wrong somehow); can you post the code that conducts that test?
-wyrmmage

No it's not my drawing code(it doesn't matter if I draw the entire map or only the visible+near visible tiles), the code itself is fine.

Anyways, here's my viewport setup:
Code:
NSRect viewBounds = [self bounds];
gluOrtho2D(0, viewBounds.size.width,
               0, viewBounds.size.height);

The only thing(with my extremely limited knowledge of opengl) that comes to mind is that somehow the clipping planes are initially set to the bounds of my viewport, and perhaps somehow resizing the window extends them or something? I don't know, but I can't begin to figure out what's happening


here's the drawing function(which draws the entire map for the sake of my testing purposes):


Code:
void draw_tiles2(void)
{
    int x, y, layer = 0;
    NSPoint pixel, tile;
    quad2d_type tile_quad;
    
    
    
    for (layer = 0; layer < 8; layer++)
    

        for (y  = MAP_HEIGHT; y > -1; y--){
                for (x = 0; x < MAP_WIDTH; x++){
                if (g_tile_map[x][y][layer].active)
                {
            
                
                    tile = NSMakePoint(x,y);
                    pixel = convert_point_tile_to_world(tile);
                    create_tile_quad( &tile_quad, g_tile_map[x][y][layer],
                                pixel.x, pixel.y);
                    draw_quad(&tile_quad);
                }
            }
        }
    
}
Quote this message in a reply
Moderator
Posts: 3,571
Joined: 2003.06
Post: #4
Leroy Wrote:No it's not my drawing code(it doesn't matter if I draw the entire map or only the visible+near visible tiles), the code itself is fine.
Well OpenGL is certainly not culling your quads, so that only leaves your code suspect...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL view first frame flickers garbage mk12 8 6,586 Sep 4, 2010 06:06 PM
Last Post: mk12
  When to create custom OpenGL view instead of subclass NSOpenGL view Coyote 37 21,524 Oct 20, 2009 08:16 PM
Last Post: Coyote
  GL view bounds question/quirk rezwits 3 3,326 Jul 12, 2009 08:45 AM
Last Post: rezwits
  Porting SDL to Cocoa OpenGL view--texture problem smittyz 7 5,009 Jul 21, 2007 07:53 PM
Last Post: smittyz
  Printing OpenGL View in Window skyhawk 3 3,653 Mar 21, 2007 02:05 PM
Last Post: unknown