Jump to content

  • Log In with Google      Sign In   
  • Create Account

Prot

Member Since 05 Jul 2013
Offline Last Active Oct 19 2014 08:56 AM

Topics I've Started

Please give me some advice for future plans.

08 September 2014 - 06:27 AM

When I had my first encounter (8 years old) with a PC I was pretty damn sure that I have to study this stuff and make it my profession. Many years later I finished studying computer science. You can't even imagine how big my disappointment was when I started looking for jobs.

 

In germany there is almost nothing to find and if you do find something it is mainly about developing browser games. My main topics in university were .NET with C# and I had plenty of time to learn XNA. But now I had to realize that nobody is looking for C# or XNA developers in the (german) gaming industry especially not for junior applicants. So I had no choice but to apply for a boring Sharepoint job (and I got it).

 

Still I did not want to accept this, so this is my plan for the future. I will go on with my current job for several years. Mainly because I think that getting a job with several years of experience is always easier. Meanwhile I started learning OpenGL.

 

Still there are some issues I am wondering about.

 

  1. It seems that nowadays nobody really needs that many game programmers (developers). I mean there is Unity, CryEngine, Unreal Engine...Does that mean that the game programmer is dying out and only the very best will find jobs in Engine developement?
  2. What are the best things I can do in order to meet the requirements for a game developer job, let's say in 2 years? By game developer job I mean everything but those freemium titles that pop everywhere! I mean want to do some real graphics/game logic programming. I hope you get the idea, it still do not have to be AAA titles but titles one can put his entire love for the medium in.

I really look forward for advice especially from people who are already in the industry.

 

Btw: The fact that I worked with C# for the most part, does not mean that I am not capable of anything else. Java, C/C++ are also languages I am pretty comfortable with. I also have experience with tools like 3Ds Max, Maya, Blender, Photoshop....


OpenGL window is not visible.

24 August 2014 - 06:39 AM

Hi there I followed the instructions to install freeglut and here for glew. I did this on my windows 7 machine and everything worked fine. Then I did the same on my windows 8 machine. I am using VS 2013 on both machines.

 

It also works and it seems to compile. But following happens:

 

1. As I created this as an empty console application the console does show up.

2. I can also see the Glut window in the system tray.

 

The problem is can not click the Glut window and I can't maximize it. There is always only the console in the foreground.

#include "glew.h"// Include the GLUT header file  
#include "GL/glut.h" // Include the GLEW header file  
#include "string.h"

struct Vector4
{
	float x;
	float y;
	float z;
	float w;
};

//GLSizei = Unsigned Integer
bool* const keyStates = new bool[256](); // Create an array of boolean values of length 256 (0-255)
bool* const keySpecialStates = new bool[256](); // Create an array of boolean values of length 256 (0-255)
bool* const keyPreviousStates = new bool[256]();

GLfloat redDiffuseMaterial[] = { 1.0, 0.0, 0.0 };
GLfloat whiteSpecularMaterial[] = { 1.0, 1.0, 1.0 };
GLfloat greenEmissiveMaterial[] = { 0.0, 1.0, 0.0 };
GLfloat blankMaterial[] = { 0.0, 0.0, 0.0 };
GLfloat mShininess[] = { 128 };


GLfloat whiteSpecularLight[] = { 1.0, 1.0, 1.0 };
GLfloat blackAmbientLight[] = { 0.0, 0.0, 0.0 };
GLfloat whiteDiffuseLight[] = { 1.0, 1.0, 1.0 };

bool diffuse = false;
bool emissive = false;
bool specular = false;

bool movingUp = false; // Whether or not we are moving up or down
float yLocation = 0.0f; // Keep track of our position on the y axis. 
float yRotationAngle = 0.0f; // The angle of rotation for our object

Vector4 bgColor = { 1.0f, 1.0f, 1.0f, 1.0f };



void renderPrimitive(void)
{
	glBegin(GL_QUADS); // Start drawing a quad primitive
	//glBegin(GL_LINE_LOOP);
	glColor3f(1.0f, 0.0f, 0.0f);
	glVertex3f(-1.0f, -1.0f, 0.0f); //Bottom Left
	glColor3f(0.0f, 1.0f, 0.0f);
	glVertex3f(-1.0f, 1.0f, 0.0f); //Top Left
	glColor3f(0.0f, 0.0f, 1.0f);
	glVertex3f(1.0f, 1.0f, 0.0f); //Top Right
	glColor3f(0.0f, 0.0f, 0.0f);
	glVertex3f(1.0f, -1.0f, 0.0f); //Bottom Right
	glEnd();
}

void keyOperations(void)
{
	if ((!keyStates['e']) && keyPreviousStates['e']) // If the 'a' key has been pressed 
	{
		// Perform 'a' key operations
		//exit(0);
		/*bgColor.x = 1.0f;
		bgColor.y = .0f;
		bgColor.z = .0f;*/

	}
}


void keySpecialOperations(void)
{
	if (keySpecialStates[GLUT_KEY_LEFT]) // If the left arrow key has been pressed
	{
		// Perform left arrow key operations
	}
}

void moveObject(void)
{
	if (movingUp) // If we are moving up
	{
		yLocation -= 0.0025f; // Move up along our yLocation
	}
	else // Otherwise
	{
		yLocation += 0.0025f; // Move down along our yLocation 
	}

	if (yLocation < -3.0f) // If we have gone up too far
	{
		movingUp = false; // Reverse our direction so we are moving down
	}
	else if (yLocation > 3.0f) // Else if we have gone down too far
	{
		movingUp = true; // Reverse our direction so we are moving up
	}

	yRotationAngle += 0.005f; // Increment our rotation value
	if (yRotationAngle > 360.0f) // If we have rotated beyond 360 degrees (a full rotation)
	{
		yRotationAngle = 0.0f; // Subtract 360 degrees off of our rotation
	}
}

void light(void)
{
	glLightfv(GL_LIGHT0, GL_SPECULAR, whiteSpecularLight);
	glLightfv(GL_LIGHT0, GL_AMBIENT, blackAmbientLight);
	glLightfv(GL_LIGHT0, GL_DIFFUSE, whiteDiffuseLight);
}

void cubeWireCustom(void)
{
	glTranslatef(0.0f, yLocation, -5.0f);
	glRotatef(yRotationAngle, 0.0f, 1.0f, 0.0f);
	glColor4f(1.0f, 0.0f, 0.0f, 0.5f);
	glScalef(0.5f, 1.0f, 2.0f);
	glutSolidCube(2.0f);
	glutWireCube(2.0f);
}

void display(void) {

	moveObject();
	keyOperations();
	keySpecialOperations();

	glEnable(GL_BLEND); // Enable the OpenGL Blending functionality
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Set the blend mode to blend our current RGBA with what is already in the buffer

	glClearColor(bgColor.x, bgColor.y, bgColor.z, bgColor.w);
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //Clear the colour buffer (more buffers later on)  
	glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations  
	gluLookAt(0.0, 0.0, 5.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0);
	light();
	glTranslatef(0.0f, 0.0f, -5.0f); // Push eveything 5 units back into the scene, otherwise we won't see the primitive

	//renderPrimitive();

	cubeWireCustom();

	//renderPrimitive(); //render the primitive	
	//glutWireCube(2.0f);	
	//glutWireSphere(2.0f,20,20);
	//glutWireTeapot(2.0f);	
	//glutSolidTeapot(2.0f);
	glutSwapBuffers(); //Swap our buffers

	memcpy(keyPreviousStates, keyStates, 256 * sizeof(bool));

}

void reshape(int width, int height)
{
	glViewport(0, 0, (GLsizei)width, (GLsizei)height); // Set our viewport to the size of our window. (0,0) being bottom left in the window.
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity(); // Reset the projection matrix to the identity matrix so that we don't get any artifacts (cleaning up)
	gluPerspective(60, (GLfloat)width / (GLfloat)height, 1.0, 100.0); // Set the Field of view angle (in degrees), the aspect ratio of our window, and the new and far planes
	glMatrixMode(GL_MODELVIEW);
}

void keyPressed(unsigned char key, int x, int y)
{
	keyStates[key] = true; //Set the state of the current key to pressed	

	if (key == 's')
	{
		if (!specular)
		{
			specular = true;
			glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, whiteSpecularMaterial);
			glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, mShininess);
		}
		else if (specular)
		{
			specular = false;
			glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, blankMaterial);
			glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, blankMaterial);
		}
	}

	if (key = 'd')
	{
		if (!diffuse)
		{
			diffuse = true;
			glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, redDiffuseMaterial);
		}
		else if (diffuse)
		{
			diffuse = false;
			glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, blankMaterial);
		}
	}

	if (key == 'e')
	{
		if (!emissive)
		{
			emissive = true;
			glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, greenEmissiveMaterial);
		}
		else if (emissive)
		{
			emissive = true;
			glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, blankMaterial);
		}
	}

}

void keyUp(unsigned char key, int x, int y)
{
	keyStates[key] = false; //Set the state of the current key to not pressed
}

void keySpecial(int key, int x, int y)
{
	keySpecialStates[key] = true;
}

void keySpecialUp(int key, int x, int y)
{
	keySpecialStates[key] = false;
}

void init()
{
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_LIGHTING);
	glEnable(GL_COLOR_MATERIAL);
	glEnable(GL_LIGHT0);
}



int main(int argc, char **argv) {
	glutInit(&argc, argv); // Initialize GLUT  
	glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_DEPTH); // Set up a basic display buffer (now double buffered)   
	glutInitWindowSize(500, 500); // Set the width and height of the window  
	glutInitWindowPosition(2500, 100); // Set the position of the window  
	glutCreateWindow("Your first OpenGL Window"); // Set the title for the window  

	init();

	glutDisplayFunc(display); // Tell GLUT to use the method "display" for rendering  
	glutIdleFunc(display); // Tell GLUT to use the method "display" as our idle method as well
	glutReshapeFunc(reshape); // Tell GLUT to use the method "reshape" for reshaping
	glutKeyboardFunc(keyPressed); // Tell GLUT to use the method "keyPressed" for key presses 
	glutKeyboardUpFunc(keyUp); // Tell GLUT to use the method "keyUp" for key up events  
	glutSpecialFunc(keySpecial); // Tell GLUT to use the method "keySpecial" for special key presses
	glutSpecialUpFunc(keySpecialUp); // Tell GLUT to use the method "keySpecialUp" for special up key events	
	glutMainLoop(); // Enter GLUT's main loop  
}

Please tell me if you need more information.


Why does this code fail to read Blender's .obj file?

22 August 2014 - 06:38 AM

Hi I am trying to read a Wavefront file which was created using Blender. I put a copy of this file into the solution Explorer. When I tried to compile for the first time I got the following message:

 

fatal error LNK1107: invalid or corrupt file: cannot read at 0x...

 

 

It seemed like the compiler confused Blender's .obj files with some other format which also uses the .obj ending. The solution was to exclude the file from the build process in its properties.

fatal error LNK1107: invalid or corrupt file: cannot read at 0x...

Now the application does compile but there is no data displayed like I would expect it. Not sure if this is a code issue.

#include "stdafx.h"
#include <iostream>
#include <stdlib.h>
#include <fstream>
#include <string>
using namespace std;

void ReadPrintFile(string _fileName)
{
std::string line;
std::ifstream fileStream (_fileName); 

if (fileStream.is_open())
{
while (getline(fileStream,line))
{
cout << line << '\n';
}
fileStream.close();
}
else
{
cout << "Unable to read file";
}
}

int _tmain(int argc, _TCHAR* argv[])
{

ReadPrintFile("Drone.obj");
std::cin.get();

return 0;
}

The code does not jump into the else statement. The filestream simply seems to be empty and I am directly forwarded to the cin.get(); statement. I know that there are tons of tutorials on how to parse .OBJ in C++ but I want to understand.

 


Efficient way to read .obj files in Visual Studio 2013

22 August 2014 - 03:40 AM

Hi there,

 

so I started out exploring the world of OpenGL using VS 2013,

 

When it came to reading .obj-files my plan was to open it as a filestream, read it linewise....In order to do so I wanted to Drag and Drop the file into the solution explorer. But then I accidentally dropped it somewhere else and then I had a serious DUFUQ moment.

 

It seems that VS is able not only to interpret .obj files but also to visualize them in a manner, like Autodesk's tools do. This leads me to the following question.

 

Does that mean that there are some libraries, prebuilt methods or something like this that would make it needless to write custom methods in order to let's say reading the vertex data?

 

What are those "libraries"? Where do I find them? And most important can I use them for my own purposes?


How to react on KeyPress + Release?

18 August 2014 - 07:42 AM

Hi I followed the tutorial on Swiftless. The last post I worked through was about Keyboard input and it does work. Basically what he covers is how to detect whether a key was pressed or realeased.

 

So I tried to experiment around. To do so I wanted to make the application to terminate when 'e' is pressed.

#include "glew.h"// Include the GLUT header file  
#include "glut.h" // Include the GLEW header file  

bool* keyStates = new bool[256](); // Create an array of boolean values of length 256 (0-255)
bool* keySpecialStates = new bool[256](); // Create an array of boolean values of length 256 (0-255)
bool* keyPreviousStates = new bool[256]();


void renderPrimitive(void)
{
	glBegin(GL_QUADS); // Start drawing a quad primitive
	glVertex3f(-1.0f,-1.0f,0.0f); //Bottom Left
	glVertex3f(-1.0f,1.0f,0.0f); //Top Left
	glVertex3f(1.0f,1.0f,0.0f); //Top Right
	glVertex3f(1.0f,-1.0f,0.0f); //Bottom Right
	glEnd();
}

void keyOperations(void)
{
	if ((!keyStates['e']) && keyPreviousStates['e']) // If the 'a' key has been pressed 
	{
		// Perform 'e' key operations
		exit(0);
	}
}

void keySpecialOperations(void)
{
	if (keySpecialStates[GLUT_KEY_LEFT]) // If the left arrow key has been pressed
	{
		// Perform left arrow key operations
	}
}

void display(void) {
	keyOperations();
	keySpecialOperations();
	glClearColor(0.706f, 0.706f, 0.706f, 2.0f); // Clear the background of our window to red  
	glClear(GL_COLOR_BUFFER_BIT); //Clear the colour buffer (more buffers later on)  
	glLoadIdentity(); // Load the Identity Matrix to reset our drawing locations  

	glTranslatef(0.0f,0.0f,-5.0f); // Push eveything 5 units back into the scene, otherwise we won't see the primitive
	renderPrimitive(); //render the primitive
	glFlush(); // Flush the OpenGL buffers to the window  
	keyPreviousStates = keyStates;
}

void reshape(int width, int height)
{
	glViewport(0, 0, (GLsizei)width, (GLsizei)height); // Set our viewport to the size of our window. (0,0) being bottom left in the window.
	glMatrixMode(GL_PROJECTION);
	glLoadIdentity(); // Reset the projection matrix to the identity matrix so that we don't get any artifacts (cleaning up)
	gluPerspective(60,(GLfloat)width/(GLfloat)height,1.0,100.0); // Set the Field of view angle (in degrees), the aspect ratio of our window, and the new and far planes
	glMatrixMode(GL_MODELVIEW);
}

void keyPressed(unsigned char key,int x, int y)
{
	keyStates[key] = true; //Set the state of the current key to pressed	
}

void keyUp(unsigned char key,int x, int y)
{
	keyStates[key] = false; //Set the state of the current key to not pressed
}

void keySpecial(int key, int x,int y)
{
	keySpecialStates[key] = true;
}

void keySpecialUp(int key,int x,int y)
{
	keySpecialStates[key] = false;
}

int main(int argc, char **argv) {
	glutInit(&argc, argv); // Initialize GLUT  
	glutInitDisplayMode(GLUT_SINGLE); // Set up a basic display buffer (only single buffered for now)  
	glutInitWindowSize(500, 500); // Set the width and height of the window  
	glutInitWindowPosition(100, 100); // Set the position of the window  
	glutCreateWindow("Your first OpenGL Window"); // Set the title for the window  

	glutDisplayFunc(display); // Tell GLUT to use the method "display" for rendering  
	glutReshapeFunc(reshape); // Tell GLUT to use the method "reshape" for reshaping
	glutKeyboardFunc(keyPressed); // Tell GLUT to use the method "keyPressed" for key presses 
	glutKeyboardUpFunc(keyUp); // Tell GLUT to use the method "keyUp" for key up events  
	glutSpecialFunc(keySpecial); // Tell GLUT to use the method "keySpecial" for special key presses
	glutSpecialUpFunc(keySpecialUp); // Tell GLUT to use the method "keySpecialUp" for special up key events

	glutMainLoop(); // Enter GLUT's main loop  
}

So I changed the keyOperations() code a little. I tried to add another bool-array which stores the state of the keys from the previous display()-iteration. Then I try to check if 'e' is currently released and if its previous state was pressed. But nothing happens smile.png

 

I guess this a very basic thing but I am very new to OpenGL and C++ so I could only think of the way I would implement this in XNA. Btw I am assigning the previous key states at the end of the display function.

 

Thanks in advance.


PARTNERS