• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

griffenjam

Displaying bitmaps NOT using textured quads

11 posts in this topic

I want to display bitmaps, but all the info I find on doing it says to use either textured quads or glDrawPixels(). I don''t like textured quads be it requires that all bitmaps have sizes in powers of 2 (I think) and I head that glDrawPixels is slow (true?). So if YOU were writing a 2D game in OpenGl what would YOU do? Jason Mickela ICQ : 873518 E-Mail: jmickela@pacbell.net ------------------------------ "Evil attacks from all sides but the greatest evil attacks from within." Me ------------------------------
0

Share this post


Link to post
Share on other sites
example
create a 256x128 sized texture

draw a 200x100 sized image in the bottom left corner

glBegin( GL_QUADS)
glTexCoord(0,0) glVertex3fv(corner1);
glTexCoord(0,100.0/128.0) glVertex3fv(corner2);
glTexCoord(200.0/256.0,100.0/128.0) glVertex3fv(corner3);
glTexCoord(200.0/256.0,0) glVertex3fv(corner4);
glEnd();

get the idea?
0

Share this post


Link to post
Share on other sites
Hi,
I believe OpenGL has a function to display just standard bitmaps, but I''m not sure how it works...
However, the Windows API has a function to display a bitmap...BitBlt ;-) However, that''s really slow.

I would use textured quads in a 2D game...Powers of 2 texture sizes isn''t much of a restriction. If you don''t have images that are powers of 2, simply resize the image''s canvas and don''t use the blank space...
I think I explained that clear enough... ^-^

--nairb
0

Share this post


Link to post
Share on other sites
Yes, glDrawPixels is generally slow (on consumer PC hardware, on old SGI systems it was pretty speedy).

The best way to do it is to use textured quads. The best way to use textured quads is to write a bitmap manager that will take care of the details once and reuse this all over.
Some of the things the bitmap manager can do, if it is designed and programmed well:

Load multiple smaller sprites onto single larger power-of-2 textures (sort of like sprite managers that load multiple sprites onto one big DirectDraw surface). This helps reduce video memory wastage. Then you can use the texture matrix and uv mapping to only display part of the larger texture on specific quads.

Handle very large bitmaps by splitting them up into multiple textures. The bitmap manager should always heed the maximum texture size for the current card (which can be as little as 256 for 3dfx cards). If the bitmap is too large for one texture, it should split the bitmap into N textures and then either use a multitexture/multipass method on a single quad the size of the bitmap, or (usually the better choice) draw multiple quads, each mapped with part of the large bitmap.



Anyway, that's what I would do. All in all I agree that its quite silly that there isn't a better/faster OpenGL 2D interface. D3D/DD do a pretty decent job of working together (or did, before Microsoft dropped DD in DX8). There's slowdown involved because of stalls when doing 2D operations, but its nowhere near the insanely slow performance that is common when using the OpenGL glDrawPixels interface.


Edited by - gmcbay on August 8, 2001 1:00:42 PM
0

Share this post


Link to post
Share on other sites
quote:
Original post by griffenjam
So if YOU were writing a 2D game in OpenGl what would YOU do?



I wouldn''t write a 2D game in OpenGL.
0

Share this post


Link to post
Share on other sites
You''re bitmaps don''t have to always be a power of 2, if you make the texture a mipmapped texture you can get around that restriction.
0

Share this post


Link to post
Share on other sites
yes they do
gluBuildMipMaps(..) calls gluScaleImage which resizes your image to powers of 2.
note with geforces + perhaps other new cards ''radeon?'' u can use non power ofd2 sized images but there are restrictions eg no mipmaps (though for a 2d game this aint important)
0

Share this post


Link to post
Share on other sites
Why don''t you want to use "powers of 2" sprites? It may simplify collision detection...

It is a bit strange, but PC hardware is faster with 3D than 2D...
0

Share this post


Link to post
Share on other sites
If you''re writing a "2D" game it''s going to be 3D anyway, as far as the hardware is concerned. You''re just going to be texturing flat quads in 3d space.

Do you ever watch the History channel, where the camera pans across an old photograph or something? SURPRISE! That photograph is actually a real life 3d object displayed as a 2d image on the television. Same concept.
0

Share this post


Link to post
Share on other sites
I guess I''ll help you out a bit...

Here''s a technique that will draw any size sprite on an opengl screen.

1) Determine the size of the sprite. (30pixels x 40pixels)
2) Find the closest ^2 that the sprite will fit into. for the 30x40 example it would be 32x64.
3) Make a texture the size of the ^2(32x64) and paint the sprite(30x40) onto the corner.
4) Draw a quad with the texture, but the the texture coordanites set correctly.

You can also use one giant 1024x1024 texture with all your sprites on it and use the appropriate texture coordanites.

You''d really be better of using an API that will allow you direct access to blitting and pixels like DirectDraw, or if your using LINUX or another real OS Allegro or SDL.

The only reason you should stick to opengl is if your going to be doing heavy alpha blending or antialiasing or rotations.
0

Share this post


Link to post
Share on other sites