• 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.
Sign in to follow this  
Followers 0
tom_mai78101

C++ and Java: Discussion on similar methods to drawing pixels on the screen

3 posts in this topic

I'm here to discuss a topic about a C++ alternative to Java's AWT Canvas object.

 

In Java Canvas, one can obtain a Graphics2D object that draws BufferedImages to the screen from BufferStrategy. For each BufferedImages, one can edit/modify/rasterize the data buffers by modifying the data values, which when drawn to the screen by the Graphics2D object, it will show up the modified data values, or pixels. Each pixel contains many different data value types, depending on how the BufferedImage is created. For example, alpha values and RGB values can be modified altogether by rasterizing the BufferedImages.

 

In C++, the first thing I see is that in Win32 API, there's a function called SetPixel(). However, I can't seem to find where I can change/modify the alpha value of the pixels themselves. The COLORREF reference shows that the high order byte values must be zero, therefore one can only modify the RGB values, but not the alpha values, since they don't exist. However, there are other methods available. It's just not possible to do it at a much higher level of simplicity.

 

In Java, one can simply load a BufferedImage by using the core library's ImageIO static methods. This is really simple to use.

In C++, loading a bitmap itself is a daunting task. There are a few known methods of loading bitmaps, such as this, or this.

 

In each of the cases, Java's Canvas and Win32 API functions similarly, and they are both known to be slow.

 

So, you got any C++ alternatives for Java's Canvas?

Edited by tom_mai78101
0

Share this post


Link to post
Share on other sites
What kind of game are you making?

Java's AWT was designed to be portable and was not designed around optimizations. If you read from a BufferedImage, or if you do any of a large number of operations, Java will stop using hardware acceleration for graphics. Performance will plummet, often making games drop to one or two seconds per frame (not frames per second). This is usually a very bad thing.

For the Windows api side, there are SetPixel and GetPixel functions that work on bitmaps. Bitmaps are kept in main memory as well, but have slightly better performance than the BufferedImage. Also, the GDI function do not support alpha channels (as you have discovered). You can use GDI+ objects or .net Graphics objects (which are wrappers for GDI+ that also includes image loading and processing functions) if that makes things easier for you. GDi+ supports alpha channels.

In both cases, most games will use a game-centric graphics library, such as JOGL in Java or OpenGL or DirectX on Windows. Then they will keep the graphics on the video card for high performance, always writing to them and usually never reading back from the graphics to main memory. These methods support all the fancy rendering techniques, alpha channels, and all the other good stuff. It is a bit more complicated to learn, but generally well worth the effort.
1

Share this post


Link to post
Share on other sites

I have no clue to what games I'm making, but at least the game itself is not graphics-heavy, therefore shaders, 3D models, etc. can be ignored. The only thing that is graphics-intensive would be the pixels and the manipulations themselves, that's all.

 

And thank you for telling me more about the Java's AWT and the GDI functions. Now, I understand why everyone is pushing themselves to use the more fancier graphics libraries.

0

Share this post


Link to post
Share on other sites


So, you got any C++ alternatives for Java's Canvas?

I might suggest libSDL's SDL_Surface.  Pretty similar concept: a buffer of pixels.  There are companion libraries to SDL that easily load images into SDL surfaces.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0