• 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
CryoGenesis

C++ Graphics help.

11 posts in this topic

Hey there, I've been programming in Java for 2 years and I've recently gotten hold of a NVidia GTX 660. I want to work on my own 3D rendering program but I have no idea how to draw 2D Images to the screen in C++. I know how to do it in Java but C++ looks a little bit more complicated when it comes to making windows. 

I'm using Ubuntu 12.10 64-bit and using NVidia's nvcc compiler which uses gcc and g++.

All I want to do is draw a 2D image to the screen. No GUI, no window borders, just an image.

One idea I had was to set up a socket connection between a C++ app and a Java app which sends the pixel data over my computer to the Java app which displays the image but I think that may be a bit slow (I have no idea).

Is there a way to do this without any external libraries? Can I do this with just the gcc and g++ includes?

Any help is appreciated and I'll give +1 rep for any helpful answers.

0

Share this post


Link to post
Share on other sites

C++ as a language has no concept of graphics so you'll have to use some sort of API/library to do your rendering/window setup. SDL is a popular choice, as is SFML and GLFW. Maybe elaborate on what you wish to achieve short and long term to get more accurate responses.

2

Share this post


Link to post
Share on other sites

Well, literally all I want to do is to draw a 2D image onto the screen from an array of pixels. The pixels will be manipulated from the C++ program. I want it to be fullscreen and I want it to update the image every time the program updates. So, no window borders or pretty GUI stuff, just a 2D image. Right now I'm going to try and write a java program that reads a 2D image from a file and displays it and at the same time the C++ program writes to the 2D image. The problem with that is thread problems and getting the image to be read when C++ has finished writing it,

0

Share this post


Link to post
Share on other sites
Hey there, I've been programming in Java for 2 years and I've recently gotten hold of a NVidia GTX 660. I want to work on my own 3D rendering program but I have no idea how to draw 2D Images to the screen in C++. I know how to do it in Java but C++ looks a little bit more complicated when it comes to making windows. 

I'm using Ubuntu 12.10 64-bit and using NVidia's nvcc compiler which uses gcc and g++.

All I want to do is draw a 2D image to the screen. No GUI, no window borders, just an image.

One idea I had was to set up a socket connection between a C++ app and a Java app which sends the pixel data over my computer to the Java app which displays the image but I think that may be a bit slow (I have no idea).

Is there a way to do this without any external libraries? Can I do this with just the gcc and g++ includes?

Any help is appreciated and I'll give +1 rep for any helpful answers.

 

Wait, do you want to work on a 3D rendering program, or just a 2D one where you directly set each pixel of an image and then just draw that to the screen?

 

I recommend you find some simple OpenGL tutorials online and then start playing around with setting up OGL and drawing some simple shapes to the screen.  Then you can texture them.  (at that point you can get a pointer to the texel data and do whatever you want with it).  Then move on to more advanced stuff like moving the camera around, etc.

 

http://www.swiftless.com/opengltuts.html

 

http://www.blitzbasic.com/Community/posts.php?topic=42662

Edited by 0r0d
1

Share this post


Link to post
Share on other sites

If you use a 2D library like SDL, your NVidia GTX 660 will be unused because all the rendering is done in software.

 

I suggest OpenGL (or DirectX if you dislike portability).

 

If you prefer to use a higher level library (like you would if using Java), then I suggest Irrlicht and the following tutorial in particular.

 

http://irrlicht.sourceforge.net/docu/example006.html

 

That should get you started pretty quickly and although the engine can do 3D, it does 2D well with the added benefit of being hardware accelerated.

1

Share this post


Link to post
Share on other sites
Hey there, I've been programming in Java for 2 years and I've recently gotten hold of a NVidia GTX 660. I want to work on my own 3D rendering program but I have no idea how to draw 2D Images to the screen in C++. I know how to do it in Java but C++ looks a little bit more complicated when it comes to making windows. 

I'm using Ubuntu 12.10 64-bit and using NVidia's nvcc compiler which uses gcc and g++.

All I want to do is draw a 2D image to the screen. No GUI, no window borders, just an image.

One idea I had was to set up a socket connection between a C++ app and a Java app which sends the pixel data over my computer to the Java app which displays the image but I think that may be a bit slow (I have no idea).

Is there a way to do this without any external libraries? Can I do this with just the gcc and g++ includes?

Any help is appreciated and I'll give +1 rep for any helpful answers.

 

Wait, do you want to work on a 3D rendering program, or just a 2D one where you directly set each pixel of an image and then just draw that to the screen?

 

I recommend you find some simple OpenGL tutorials online and then start playing around with setting up OGL and drawing some simple shapes to the screen.  Then you can texture them.  (at that point you can get a pointer to the texel data and do whatever you want with it).  Then move on to more advanced stuff like moving the camera around, etc.

 

http://www.swiftless.com/opengltuts.html

 

http://www.blitzbasic.com/Community/posts.php?topic=42662

 

I'm going to be writing my own rasteriser that converts a 3D world space into a 2D image that is drawn on the screen. I managed to do it in Java but I got a new graphics card which is CUDA enabled. It means I can do lots of parallel processing and make the program run a lot faster. Problem is that I don't know how to draw 2D images with C++ ;D

I was thinking about using OpenGL to draw the 2D image but I don't know how to create a window to set the OpenGL library to draw to. I'll look it up on teh googhels.

0

Share this post


Link to post
Share on other sites
If you use a 2D library like SDL, your NVidia GTX 660 will be unused because all the rendering is done in software.

 

I suggest OpenGL (or DirectX if you dislike portability).

 

If you prefer to use a higher level library (like you would if using Java), then I suggest Irrlicht and the following tutorial in particular.

 

http://irrlicht.sourceforge.net/docu/example006.html

 

That should get you started pretty quickly and although the engine can do 3D, it does 2D well with the added benefit of being hardware accelerated.

My GTX 660 is CUDA enabled. This allows me to use the CUDA SDK to program the graphics cards to do mathematical operations in C++. It's very useful because I can do around 800GHz of operations. If I used a 2D library like SDL the only function I would be using would be to draw an image, all the image manipulation and/or the rasterizer math would be done with cuda code. I think my GPU comes with 1000 cuda cores. It allows me to do program the 3D stuff from scratch whilst making it incredibly fast. Problem is, if I tried to use it with another computer it wouldn't run.

So, essentially, I'm going to be coding the hardware acceleration myself and use some random library to just draw the pixel array to the screen. 

0

Share this post


Link to post
Share on other sites
 

 

Wait, do you want to work on a 3D rendering program, or just a 2D one where you directly set each pixel of an image and then just draw that to the screen?

 

I recommend you find some simple OpenGL tutorials online and then start playing around with setting up OGL and drawing some simple shapes to the screen.  Then you can texture them.  (at that point you can get a pointer to the texel data and do whatever you want with it).  Then move on to more advanced stuff like moving the camera around, etc.

 

http://www.swiftless.com/opengltuts.html

 

http://www.blitzbasic.com/Community/posts.php?topic=42662

 

I'm going to be writing my own rasteriser that converts a 3D world space into a 2D image that is drawn on the screen. I managed to do it in Java but I got a new graphics card which is CUDA enabled. It means I can do lots of parallel processing and make the program run a lot faster. Problem is that I don't know how to draw 2D images with C++ ;D

I was thinking about using OpenGL to draw the 2D image but I don't know how to create a window to set the OpenGL library to draw to. I'll look it up on teh googhels.

 

Ok, so yeah, follow the links I gave.  You just need to set up OGL and draw a full-screen textured quad w/ a texture that you create in memory.  Then get the pointer to the texels and you can set them to whatever RGB values you want.

1

Share this post


Link to post
Share on other sites
 

 

Wait, do you want to work on a 3D rendering program, or just a 2D one where you directly set each pixel of an image and then just draw that to the screen?

 

I recommend you find some simple OpenGL tutorials online and then start playing around with setting up OGL and drawing some simple shapes to the screen.  Then you can texture them.  (at that point you can get a pointer to the texel data and do whatever you want with it).  Then move on to more advanced stuff like moving the camera around, etc.

 

http://www.swiftless.com/opengltuts.html

 

http://www.blitzbasic.com/Community/posts.php?topic=42662

 

I'm going to be writing my own rasteriser that converts a 3D world space into a 2D image that is drawn on the screen. I managed to do it in Java but I got a new graphics card which is CUDA enabled. It means I can do lots of parallel processing and make the program run a lot faster. Problem is that I don't know how to draw 2D images with C++ ;D

I was thinking about using OpenGL to draw the 2D image but I don't know how to create a window to set the OpenGL library to draw to. I'll look it up on teh googhels.

 

Ok, so yeah, follow the links I gave.  You just need to set up OGL and draw a full-screen textured quad w/ a texture that you create in memory.  Then get the pointer to the texels and you can set them to whatever RGB values you want.

Thanks!

0

Share this post


Link to post
Share on other sites

Once you are comfortable with drawing pixels using openGL, you may also try cuda-opengl interop feature. This allows openGL to directly access texture from GPU device memory without needing to copy it to CPU memory. This tutorial could be helpful:

http://3dgep.com/?p=2082

0

Share this post


Link to post
Share on other sites

When it comes to OpenGL, Lets not forget about nehe's website. http://nehe.gamedev.net/ you can find plenty of tutorials there too.(Lesson 06 to 10 is what you really after)  Once you get the OpenGL up and running, rendering a 2D image is as simple as creating a quad with position vertices and texture coordinates, and binding the texture that you want to render. I must point out most of these tutorials are old. However, its a great start up for anyone who's new at it. 

0

Share this post


Link to post
Share on other sites

I started on graphics with nehe. It is old, but the nature of the pipeline has not changed overmuch since then, so you can easily move from there to newer API's and pick up new concepts.

Hmm... Maybe we should think about porting Nehe's tuts to a more recent API? Is he still around?

Edit -

*follows link*

*sees new page formatting*

lol, yeah, I'll email him and talk about it. Maybe GD can collab something.

 

Actually, I start classes on Monday, so I think I'll let it be for now.

Edited by Khatharr
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