Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


C++ Graphics help.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
11 replies to this topic

#1 CryoGenesis   Members   -  Reputation: 496

Like
0Likes
Like

Posted 01 January 2013 - 11:13 AM

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.



Sponsor:

#2 GeneralQuery   Crossbones+   -  Reputation: 1263

Like
2Likes
Like

Posted 01 January 2013 - 11:22 AM

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.



#3 CryoGenesis   Members   -  Reputation: 496

Like
0Likes
Like

Posted 01 January 2013 - 11:26 AM

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,



#4 0r0d   Members   -  Reputation: 819

Like
1Likes
Like

Posted 01 January 2013 - 02:18 PM

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, 01 January 2013 - 02:22 PM.


#5 Karsten_   Members   -  Reputation: 1653

Like
1Likes
Like

Posted 01 January 2013 - 02:53 PM

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.


Mutiny - Open-source C++ Unity re-implementation.
Defile of Eden 2 - FreeBSD and OpenBSD binaries of our latest game.


#6 CryoGenesis   Members   -  Reputation: 496

Like
0Likes
Like

Posted 01 January 2013 - 04:06 PM

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.



#7 CryoGenesis   Members   -  Reputation: 496

Like
0Likes
Like

Posted 01 January 2013 - 04:11 PM

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. 



#8 0r0d   Members   -  Reputation: 819

Like
1Likes
Like

Posted 01 January 2013 - 04:55 PM

 

 

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.



#9 CryoGenesis   Members   -  Reputation: 496

Like
0Likes
Like

Posted 01 January 2013 - 07:04 PM

 

 

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!



#10 ankan_ban   Members   -  Reputation: 102

Like
0Likes
Like

Posted 01 January 2013 - 10:34 PM

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



#11 Nusakan   Members   -  Reputation: 444

Like
0Likes
Like

Posted 05 January 2013 - 05:46 AM

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. 



#12 Khatharr   Crossbones+   -  Reputation: 3031

Like
0Likes
Like

Posted 05 January 2013 - 08:41 PM

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, 05 January 2013 - 08:49 PM.

void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS