Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: 2D Scrolls Side Game (help with textures)

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2005
    Posts
    5

    2D Scrolls Side Game (help with textures)

    Hello guys, i am new here, this is my first post, in fact

    Well, this is my problem:

    ----------------------------

    I have to make a 2D Scroll Side game, like Mario Bros, you know.

    For that, i know all the concepts (the matrix, the tiles with attribs, etc)

    I have done some work with that (a level creator), but when i arrived to the Graphics section (for the Engine itself) , i got some problems...

    At first, i wanted to do it with the Canvas of C++ Builder, but it is sooooo, soooo, SLOW.

    So i decided to use OpenGL.... But i don't know nothing about OpenGL !!

    Si i started a few weeks ago, and i have learned some basic concepts... but i have not solve the main problem: the engine for the game.

    The details:

    I need to create a Big Rectangle, wich contains the "parallax" (a big texture for background, example: far mountains, of 640*480 pixels)

    On top of that big texture, i need various squares, that will contain different textures (of 32*32 pixels)

    Obviously, almost all of that textures, will have some transparent pixels, showing what is behind... i mean, showing the parallax.

    -----------------------------

    So, if anyone here can help...

    can you post some EXAMPLES like... ?

    -quads showing Different Textures...

    -quads showing textures, but some quads having TRANSPARENT TEXTURES...

    -moving quads around X axis in a "fast" way (you know... 2D world)

    PLEASE, i need a lot of help, as i said, i am a very very begginer.

    Carlos,
    CHILE.

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2005
    Posts
    115

    Re: 2D Scrolls Side Game (help with textures)

    Well, to learn how to translate on the x-axis go to http://programminghq.tk there aren't texture tutorials yet, thought.

    To use a texture in opengl you have to load it first. here is a function to load a texture.

    Code :
    void text(UINT textureArray[], LPSTR strFileName, int ID)
    {
    	if(!strFileName)   return;
     
    	AUX_RGBImageRec *pBitMap = auxDIBImageLoad(strFileName);
     
    	if(pBitMap == NULL)	exit(0);
     
    	glGenTextures(1, &textureArray[ID]);
    	glBindTexture(GL_TEXTURE_2D, textureArray[ID]);
    	gluBuild2DMipmaps(GL_TEXTURE_2D, 3, pBitMap->sizeX, pBitMap->sizeY, GL_RGB, GL_UNSIGNED_BYTE, pBitMap->data);
    	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
    	glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);	
     
    	if (pBitMap)										
    	{
    		if (pBitMap->data)								
    		{
    			free(pBitMap->data);						
    		}
    		free(pBitMap);									
    	}
    }
    This will only load bitmaps, though. To load a tga file go here http://www.morrowland.com/apron/tut_gl.php and find the download on tga files.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,102

    Re: 2D Scrolls Side Game (help with textures)

    http://nehe.gamedev.net/

    There are a lot of tutorials on this site.

    The most interesting for you is propably Lesson 9, and depending on how much you already know the ones before that, too...

  4. #4
    Junior Member Newbie
    Join Date
    Jun 2005
    Posts
    5

    Re: 2D Scrolls Side Game (help with textures)

    Hi,

    i was reading Nehe Lesson #6, and there is a comment: "The width and height must be at least 64 pixels, and for compatability reasons, shouldn't be more than 256 pixels"

    But i have done all the previous work with 32*32 pixels !!!

    What can i do ? (please don't tell me "start all again an resize all the textures with a paint program")

    Thanks.

    Carlos.
    CHILE

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2000
    Location
    Naarn, Austria
    Posts
    1,102

    Re: 2D Scrolls Side Game (help with textures)

    You're the second one to mention to me that textures have to be at least 64x64 recently, so I just checked the spec myself

    There seems to be a misunderstanding: The maximum allowed texture size has to be at least 64x64 for any OpenGL implementation. There is no minimum texture size (except 1 )

    This means you can use any smaller texture size, as long as it is a power of 2 (except for the ARB_texture_rectangle and ARB_texture_npot extensions)...

  6. #6
    Junior Member Newbie
    Join Date
    Jun 2005
    Posts
    5

    Re: 2D Scrolls Side Game (help with textures)

    Hi, thanks for the answers...

    can you help me with this, please??

    I have two quads, one with a green texture (quad #1), and the other with a texture with Fuchsia pixels (quad #2)... and i want ONLY the FUCHSIA pixels be transparent...

    so, when the Quad#2 be on top of the Quad #1, the fuchsia pixels show what is behind the quad...

    like this image:


    I hope someone can help me.. because i don't find the answer in the tutorials.

    THANKS.

    Carlos,
    Chile.

  7. #7
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: 2D Scrolls Side Game (help with textures)

    When loading texture, create a RGBA texture, with A being the transparency : 0 transparent, 255 opaque, other values for different transparency.

  8. #8
    Senior Member Frequent Contributor ehsan2004's Avatar
    Join Date
    Jun 2004
    Location
    Iran
    Posts
    645

    Re: 2D Scrolls Side Game (help with textures)

    Originally posted by Overmind:

    This means you can use any smaller texture size, as long as it is a power of 2 (except for the ARB_texture_rectangle and ARB_texture_npot extensions)...
    Overmind,
    I can load the textures that aren't a power of 2. it seems that this limitation refers to the previous versions of OpenGL.
    -Ehsan-

  9. #9
    Senior Member Regular Contributor
    Join Date
    Sep 2002
    Location
    Dresden, Sachsen, Germany
    Posts
    203

    Re: 2D Scrolls Side Game (help with textures)

    As far as I know this feature is only exposed through extensions otherwise it is not possible because this adds a new texture target ...

  10. #10
    Super Moderator OpenGL Lord
    Join Date
    Dec 2003
    Location
    Grenoble - France
    Posts
    5,574

    Re: 2D Scrolls Side Game (help with textures)

    Originally posted by powerpad:
    As far as I know this feature is only exposed through extensions otherwise it is not possible because this adds a new texture target ...
    To be more precise, GL_ARB_texture_non_power_of_two does not add any new entrypoint, just relaxes power-of-two size limitations.

    (ARB_texture_rectangle is not so great though)

Page 1 of 2 12 LastLast

Similar Threads

  1. hang when running two programs side by side
    By remdul in forum OpenGL: Windows
    Replies: 2
    Last Post: 12-29-2011, 09:03 AM
  2. Side-By-Side configuration
    By andersb in forum COLLADA
    Replies: 1
    Last Post: 02-25-2008, 07:34 PM
  3. Replies: 0
    Last Post: 04-04-2004, 09:24 PM
  4. Right side and Left side Lighting not happening
    By iris_raj in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 12-11-2003, 06:39 PM
  5. wire appears to move from side to side on object
    By JoeFinn in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-18-2001, 09:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean