Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 05 Dec 2011
Offline Last Active Dec 16 2014 02:17 PM

Topics I've Started

Need help with texture mapping (Software Renderer).

07 February 2014 - 02:32 PM

Hey there, it's my first time posting after being away for a while.


Basically, I'm writing a software 3D renderer for experience ('ll rarely use it) and I need help with texture mapping onto triangles which are being renderer using the scan-line algorithm. Currently, the 3D renderer I've written already has texture mapping but it maps onto a quad which is rendered using an algorithm I made up which is super slow at high resolutions (plus, it doesn't render triangles, only quads). 


I've implemented the scan-line algorithm pretty easily to render solid colour triangles and it's a lot faster than the algorithm I originally used. The only problem is texture mapping. I've literally been trying to get texture mapping to work for weeks. The resources online are pretty slim apart from a nice article here:




The problem I have with this is that to take a texture triangle and map it over another triangle, which has been split through a vertex, requires the texture to be split as well. It also has to split according to which vertex of the triangle to be rendered has been split with, and a whole load of other stuff.


I'm basically having a real bad time with this and I think I'm over complicating the way texture mapping is supposed to work. I'm getting pretty depressed over the whole thing because I feel like I'm giving up if I move onto another project without finishing one. I just want to finish this 3D renderer and get back to making games.


Can someone please explain how to implement (or how you implemented) texture mapping? At the moment, I'm just not getting it.


Thanks in advance.

Live streaming my first Ludum Dare

26 April 2013 - 09:55 AM

Hey guys, I'm live streaming my first Ludum Dare over Twitch.

I'm not sure if I'm going to do any good but my aim is to get something pretty up by the time the compo finishes.



Cool gadgets for a game programmer to enhance games?

20 April 2013 - 01:42 PM

Hey all, I've been trying to find some cool programmable gadgets or things that I would like to develop on. So far I've only been able to think of the Ouya and Oculus Rift. Both are pretty cool and and you can can use them to make some cool games. Unfortunately, they're not out yet. 


Does anybody know of any cool gadgets like these that I could get for my birthday?


I'm looking for something that I could use to make games for or something that I could enhance my games with. I'm particularly interested in the latter. For an example of this, I got an NVidia GTX 660 because it is CUDA enabled and can be used to enhance my games/programs. I'm looking for stuff like that.


Any suggestions would be greatly appreciated. I honestly don't know what is available.


OUYA: http://www.ouya.tv/

Oculus Rift: http://www.oculusvr.com/

C++ Graphics help.

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.

(SOLVED) Multi-threading help!

24 December 2012 - 12:40 PM

SOLVED: (Just in case anyone else has any trouble with something like this) The problem was that when you initialize a separate thread and pass objects from another thread into the new thread, it creates a copy of said object instead of referencing it like Java is supposed to do. To solve this you use the 'protected' keyword in front of the objects that you don't want to be copied.


Hey, I'm working on a multi-threaded server program which isn't working how I would like.
Basically, there is a thread that runs a program (main thread), a thread which accepts any connections and a thread for each connection which checks if the client is still connected.
Unfortunately, when the ConnectionGrabber thread accepts a connection, it initialized a Connection class with the socket. the Connection class then starts a thread and accesses the socket through the run() method (it implements Runnable).
For some reason, when the client is passed from the ConnectionGrabber thread to the Connection thread, the client is not the same object. When you send information to the client through the connectionGrabber thread it sends successfully, when you send it through the connection thread, it sends without an error but does not actually send it to the client. client.isClosed() also doesn't work when passing the object between threads.

here is the full code:

package Networking;import static Util.ConsoleUtil.*;import java.io.BufferedWriter;import java.io.DataOutputStream;import java.net.*;import java.util.*;public class ServerProgram {	ArrayList socketList;	Server server;	public void begin(Server server){		this.server = server;		socketList = new ArrayList();		consoleOutput("BEGINNING SERVER PROGRAM");		boolean running = true;				consoleOutput("Loading any Connections");		while(running == true){			update();					}	}	public void update(){		checkList();	}	public void checkList(){		for(int i = 0; i < Connection.connectionList.size(); i++){			Connection client = Connection.connectionList.get(i);			if(client.disconnected() == true){				Connection.connectionList.remove(client);				Connection.connectionList.trimToSize();				consoleOutput("Successfully Dropped A Client");			}		}	}	public static void sendMessage(Socket socket, String message) throws Exception{		new DataOutputStream(socket.getOutputStream()).writeBytes(message);	}}
package Networking;import static Util.ConsoleUtil.consoleOutput;import java.io.IOException;import java.net.ServerSocket;import java.net.Socket;import java.util.ArrayList;import Util.ConsoleUtil;public class ConnectionGrabber implements Runnable{	ServerSocket server;	boolean accepting = true;	Thread thread;		public ConnectionGrabber(ServerSocket server){		this.server = server;		thread = new Thread(this);		consoleOutput("Initialized Connection Grabber");	}		public void startAccepting(){		accepting = true;		if(thread.isAlive() == false){			thread.start();		}	}	public void stopAccepting(){		accepting = false;	}	public void run() {		consoleOutput("Now Accepting Incoming Connections");		while(accepting == true){			try {				Socket sock = server.accept();				Connection connection = new Connection(sock);				Connection.connectionList.add(connection);				consoleOutput("Connection Added To Connection List... Current Amount Of Connections: " + Connection.connectionList.size());			} catch (Exception e) {				e.printStackTrace();			}		}	}}
package Networking;import java.io.*;import java.net.Socket;import java.util.ArrayList;import static Util.ConsoleUtil.*;public class Connection implements Runnable{	public static ArrayList connectionList = new ArrayList();		final Socket client;	boolean checking = true;	Thread thread;		public Connection(Socket socket){		client = socket;		thread = new Thread(this);		thread.start();	}		public synchronized boolean disconnected(){		return !checking;	}		public synchronized void stopConnection(){		checking = false;	}		public void run() {			BufferedInputStream in = null;		PrintWriter out = null;		try{			in = new BufferedInputStream(new DataInputStream(client.getInputStream()));			out = new PrintWriter(client.getOutputStream());		}catch(Exception e){			consoleOutput("Failure To Establish Data Stream To Client... Dropping client...");			checking = false;		}		consoleOutput("Established Data Transfer");		while(checking == true){						try{				out.print(1000);			}catch(Exception e){				consoleOutput("Transfer Check Failed");				checking = false;			}						if(client.isClosed() == true || client.isConnected() == false){				checking = false;				consoleOutput("Client Dropped");			}						try{				thread.sleep(1000);			}catch(Exception e){							}		}	}	}

(ConnectionGrabber is initialized in another class)

Thanks in advance!
Any help at all will be appreciated!