- Viewing Profile: Posts: Lex224
Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics
Community Stats
- Group Members
- Active Posts 36
- Profile Views 699
- Member Title Member
- Age Age Unknown
- Birthday October 22
-
Gender
Male
-
Location
Glasgow, Scotland
128
Neutral
User Tools
Contacts
Lex224 hasn't added any contacts yet.
Posts I've Made
In Topic: Game genres, what do you want to develop?
16 May 2012 - 03:16 PM
I'd love to make a sandbox type game, basically because it would combines so many different things that I'd have to work hard to complete, and could always be added to. That's the beauty of a sandbox game!
In Topic: Camera and model frame issues
25 April 2012 - 09:11 AM
OK, disregard this.
I doubt anybody else will have this same issue, but if they do, all I did was change where I put the SetOrigin from inside the RenderScene function, to the SetupRC function. Silly me.
I doubt anybody else will have this same issue, but if they do, all I did was change where I put the SetOrigin from inside the RenderScene function, to the SetupRC function. Silly me.
In Topic: Camera and model frame issues
25 April 2012 - 08:31 AM
OK, I've stripped the project down to just some simple geometry. I now have a floor and a cylinder object which should be controllable. Again, when I set the cylinder's origin, it's unable to move, yet when I comment out it's origin, it can move. I need to set it's origin in front of the camera so that I can see it, so this is a problem.
Here is the stripped down code:
Is there a way to set it's origin and for it to move around? When I do set the origin and try to move it, it stays in place but flickers, showing that it is trying to move.
Here is the stripped down code:
// Based on SphereWorld4
#include <GLTools.h>
#include <GLShaderManager.h>
#include <GLFrustum.h>
#include <GLBatch.h>
#include <GLFrame.h>
#include <GLMatrixStack.h>
#include <GLGeometryTransform.h>
#include <StopWatch.h>
#include <math.h>
#include <stdio.h>
//#ifdef __APPLE__
//#include <glut/glut.h>
//#else
#define FREEGLUT_STATIC
#include <GL/glut.h>
//#endif
#define NUM_SPHERES 50
GLFrame spheres[NUM_SPHERES];
GLShaderManager shaderManager; // Shader Manager
GLMatrixStack modelViewMatrix; // Modelview Matrix
GLMatrixStack projectionMatrix; // Projection Matrix
GLFrustum viewFrustum; // View Frustum
GLGeometryTransform transformPipeline; // Geometry Transform Pipeline
GLBatch floorBatch;
GLFrame cameraFrame;
GLTriangleBatch cylinderBatch;
GLFrame cylinderFrame;
//////////////////////////////////////////////////////////////////
// This function does any needed initialization on the rendering
// context.
void SetupRC()
{
// Initialze Shader Manager
shaderManager.InitializeStockShaders();
glEnable(GL_DEPTH_TEST);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
// This makes a cylinder
gltMakeCylinder(cylinderBatch, 0.1f, 0.0f, 0.4f, 24, 6);
// Floor
floorBatch.Begin(GL_LINES, 324);
for(GLfloat x = -20.0; x <= 20.0f; x+= 0.5)
{
floorBatch.Vertex3f(x, -0.55f, 20.0f);
floorBatch.Vertex3f(x, -0.55f, -20.0f);
floorBatch.Vertex3f(20.0f, -0.55f, x);
floorBatch.Vertex3f(-20.0f, -0.55f, x);
}
floorBatch.End();
}
///////////////////////////////////////////////////
// Screen changes size or is initialized
void ChangeSize(int nWidth, int nHeight)
{
glViewport(0, 0, nWidth, nHeight);
// Create the projection matrix, and load it on the projection matrix stack
viewFrustum.SetPerspective(35.0f, float(nWidth)/float(nHeight), 1.0f, 100.0f);
projectionMatrix.LoadMatrix(viewFrustum.GetProjectionMatrix());
// Set the transformation pipeline to use the two matrix stacks
transformPipeline.SetMatrixStacks(modelViewMatrix, projectionMatrix);
}
// Called to draw scene
void RenderScene(void)
{
// Color values
static GLfloat vFloorColor[] = { 0.0f, 1.0f, 0.0f, 1.0f};
static GLfloat vCylColor[] = { 0.2f, 1.0f, 1.0f, 1.0f };
// Clear the color and depth buffers
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Save the current modelview matrix (the identity matrix)
modelViewMatrix.PushMatrix();
M3DMatrix44f mCamera;
cameraFrame.GetCameraMatrix(mCamera);
modelViewMatrix.PushMatrix(mCamera);
// Transform the light position into eye coordinates
M3DVector4f vLightPos = { 0.0f, 10.0f, 5.0f, 1.0f };
M3DVector4f vLightEyePos;
m3dTransformVector4(vLightEyePos, vLightPos, mCamera);
// Draw the ground
shaderManager.UseStockShader(GLT_SHADER_FLAT,
transformPipeline.GetModelViewProjectionMatrix(),
vFloorColor);
floorBatch.Draw();
// Draw cylinder
modelViewMatrix.PushMatrix();
modelViewMatrix.MultMatrix(cylinderFrame);
shaderManager.UseStockShader(GLT_SHADER_POINT_LIGHT_DIFF, transformPipeline.GetModelViewMatrix(),
transformPipeline.GetProjectionMatrix(), vLightEyePos, vCylColor);
cylinderFrame.SetOrigin(0.0f, 0.0f, -2.0f);
cylinderFrame.SetForwardVector(0.0f, 0.0f, 1.0f);
cylinderBatch.Draw();
modelViewMatrix.PopMatrix();
// Restore the previous modleview matrix (the identity matrix)
modelViewMatrix.PopMatrix();
modelViewMatrix.PopMatrix();
// Do the buffer Swap
glutSwapBuffers();
// Tell GLUT to do it again
glutPostRedisplay();
}
// Respond to arrow keys by moving the camera frame of reference
void SpecialKeys(int key, int x, int y)
{
float linear = 0.1f;
float angular = float(m3dDegToRad(5.0f));
if(key == GLUT_KEY_UP)
cameraFrame.MoveForward(linear);
if(key == GLUT_KEY_DOWN)
cameraFrame.MoveForward(-linear);
if(key == GLUT_KEY_LEFT)
cameraFrame.RotateWorld(angular, 0.0f, 1.0f, 0.0f);
if(key == GLUT_KEY_RIGHT)
cameraFrame.RotateWorld(-angular, 0.0f, 1.0f, 0.0f);
}
void Keyboard(unsigned char key, int x, int y)
{
switch(key)
{
case('w'):
{
cylinderFrame.MoveForward(0.1f);
break;
}
case('s'):
{
cylinderFrame.MoveForward(-0.1f);
break;
}
case('a'):
{
cylinderFrame.RotateLocalY(30.0f);
break;
}
case('d'):
{
cylinderFrame.RotateLocalY(-30.0f);
break;
}
}
}
int main(int argc, char* argv[])
{
gltSetWorkingDirectory(argv[0]);
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutInitWindowSize(800,600);
glutCreateWindow("OpenGL SphereWorld");
glutSpecialFunc(SpecialKeys);
glutKeyboardFunc(Keyboard);
glutReshapeFunc(ChangeSize);
glutDisplayFunc(RenderScene);
GLenum err = glewInit();
if (GLEW_OK != err) {
fprintf(stderr, "GLEW Error: %s\n", glewGetErrorString(err));
return 1;
}
SetupRC();
glutMainLoop();
return 0;
}
Is there a way to set it's origin and for it to move around? When I do set the origin and try to move it, it stays in place but flickers, showing that it is trying to move.
In Topic: Books to buy
28 February 2012 - 06:43 AM
I have a variety of book on all sorts of subjects, and some that have been strongly recommended for future purchases.
For C++ I've used 'Beginning C++ Through Game Programming' and 'C++ A Beginners Guide', the second on which I prefer for covering most of the beginner topics.
Due to my course teaching OpenGL and not Direct3D, I have the 'OpenGL SuperBible (5th Edition) which is good for more modern OpenGL programming, though it uses it's own libraries to get around using the older, deprecated OpenGL features (which you'd eventually need to know how not to use). I also have 'Interactive Computer Graphics' but this is very theory heavy and it lost me. It's up to date though so I'm sure it would be useful. I would say that you don't need to learn SDL or anything before you go onto OpenGL, but that's just me.
Also on the note of OpenGL, keep your eyes on the new 'OpenGL Programming Guide' which is out in a few months. This will surely cover the core of the latest versions of OpenGL.
Aside from general programming and graphics, I have a copy of 'Mathmatics for 3D Game Programming and Computer Graphics' which I've not looked at yet but it's meant to be the best beginners book on the subject. If you're feeling like really getting stuck in, there's also 'Programming AI By Example', which again I've not read, but it's similar to the last book in that it's meant to be the best for beginners.
Those are the books I have, anyways. The way I choose books for my learning is actually going on Amazon, and looking at the reviews.
Hope that helped somewhat.
P.S. I would recommend against the 'Beginning OpenGL for Game Programming' that you already have. I think people recommend it here because it was written, or partly written, by GameDev staff. In this case, that doesn't mean anything.
For C++ I've used 'Beginning C++ Through Game Programming' and 'C++ A Beginners Guide', the second on which I prefer for covering most of the beginner topics.
Due to my course teaching OpenGL and not Direct3D, I have the 'OpenGL SuperBible (5th Edition) which is good for more modern OpenGL programming, though it uses it's own libraries to get around using the older, deprecated OpenGL features (which you'd eventually need to know how not to use). I also have 'Interactive Computer Graphics' but this is very theory heavy and it lost me. It's up to date though so I'm sure it would be useful. I would say that you don't need to learn SDL or anything before you go onto OpenGL, but that's just me.
Also on the note of OpenGL, keep your eyes on the new 'OpenGL Programming Guide' which is out in a few months. This will surely cover the core of the latest versions of OpenGL.
Aside from general programming and graphics, I have a copy of 'Mathmatics for 3D Game Programming and Computer Graphics' which I've not looked at yet but it's meant to be the best beginners book on the subject. If you're feeling like really getting stuck in, there's also 'Programming AI By Example', which again I've not read, but it's similar to the last book in that it's meant to be the best for beginners.
Those are the books I have, anyways. The way I choose books for my learning is actually going on Amazon, and looking at the reviews.
Hope that helped somewhat.
P.S. I would recommend against the 'Beginning OpenGL for Game Programming' that you already have. I think people recommend it here because it was written, or partly written, by GameDev staff. In this case, that doesn't mean anything.
In Topic: Need CD for OpenGL Game Programming Book
29 January 2012 - 03:42 PM
- Home
- » Viewing Profile: Posts: Lex224

Find content