Levels rendered sideways?

So I have this interesting problem with my tile engine. My nested for loops start rendering the tiles from the upper-left ([0][0] of the array), but OpenGL starts rendering at the bottom left. So whenever I create a level, and then render it, it renders sideways. If that makes any sense…

This is how I initialize the level:

//the tiles[][] array refers to my Tile class tiles, the ids[][] array is an int array containing tile ids passed by the constructor,
//and Tile.tiles is an ArrayList containing all the tiles that exist

for(int x = 0; x < ids[0].length; x++){
for( int y = 0; y < ids.length; y++){
//iterate through tile IDs
for(int i = 0; i < Tile.tiles.size(); i++){
if(Tile.tiles.get(i).getID() == ids[x][y]){ //check for match
tiles[x][y] = Tile.tiles.get(i); //the tile matched an id in the array, so set that tile to the one it matched
}
}
}
}

And how I render it:

//pos is a vector representing the position of the level

for(int x = 0; x < ids[0].length; x++){
for(int y = 0; y < ids.length; y++){

	//set x and y coords of tiles before rendering
	tiles[x][y].getPos().setX(pos.getX() +(x * tileSize); //set X
	tiles[x][y].getPos().setY(pos.getY() +(y * tileSize); //set Y
	
            //render tile
            tiles[x][y].render();

	}
}

}

I’m pretty sure I could just change the origin to be the top left instead of bottom left using glOrtho, but I don’t really like thinking that way.

Hopefully you guys understand the problem. Any help?

Use [ code ] your code [ /code ].
And there are no details maybe the way you load the level? If you are doing it from a image just flip it!

You need to flip y-axis in opengl. (screen.height - y)

That’s because OpenGL has its origin in the lower left corner.
Like trollwarrior1 said already you could flip the y Coordinate with [icode]screenHeight - y;[/icode] or else you could just initalize OpenGL with [icode]glOrtho(0, screenWidth, screenHeight, 0, -1, 1);[/icode], then you have your origin in the top left.
There’s nothing wrong with changing the orthographic projection :wink: