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

Best method for a top down, side scrolling camera.

5 posts in this topic

Ive seen examples using gluLookAt(), glOrtho(), gluOrtho2d(), etc. One example I saw said all you need is to just use glTranslate(). So what is presently the best, easiest method to achieve this effect?

Thanks in advance.
0

Share this post


Link to post
Share on other sites
Every time you render a frame, you have to specify your projection matrix and place your camera position, and the direction you are looking in. There is nothing special or different about a top down, side scrolling camera. Just put your camera where you need it, and then tell it what direction to point in.

Create a camera class, and use it to keep track of the camera's position, lookat vector, Field of View, and anything else you might want, like velocity.

http://nehe.gamedev.net/article/camera_class_tutorial/18010/ Edited by Daaark
0

Share this post


Link to post
Share on other sites
I understand the camera class. My question is what OpenGL commands to use.
0

Share this post


Link to post
Share on other sites
[quote name='Ahl' timestamp='1350619177' post='4991664']
My question is what OpenGL commands to use.
[/quote]

You need to encode the desired translation in the model-view matrix. In older versions of OpenGL, this could be done with glTranslate. In modern OpenGL, you would typically manage your own matrices, and send the raw data to the shader program, using glUniformMatrix.
0

Share this post


Link to post
Share on other sites
Alright, then I need to figure out what I'm doing wrong. I have the following:

[CODE]
void RenderScene()
{
std::sort (RenderList.begin(), RenderList.end(), SortRenderList);
glMatrixMode(GL_MODELVIEW);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3f(1.0f, 1.0f, 1.0f);
glLoadIdentity();
glTranslatef(MyCamera->GetPosX(), MyCamera->GetPosY(), MyCamera->GetPosZ());
uintptr_t LastKey = (uintptr_t)-1;
uintptr_t LastMeshKey = (uintptr_t)-1;
uintptr_t LastTexKey = (uintptr_t)-1;
uintptr_t LastMatKey = (uintptr_t)-1;
for (RenderListIT = RenderList.begin(); RenderListIT != RenderList.end(); RenderListIT++)
{
glPushMatrix();
glLoadIdentity();
glTranslatef((*RenderListIT)->Position->x, (*RenderListIT)->Position->y, (*RenderListIT)->Position->z);

glScalef ((*RenderListIT)->Scale->x, (*RenderListIT)->Scale->y, (*RenderListIT)->Scale->z);
glRotatef ((*RenderListIT)->Rotation->x, 1.0f, 0.0f, 0.0f);
glRotatef ((*RenderListIT)->Rotation->y, 0.0f, 1.0f, 0.0f);
glRotatef ((*RenderListIT)->Rotation->z, 0.0f, 0.0f, 1.0f);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glEnable(GL_LIGHTING);
if ((*RenderListIT)->Key != LastKey)
{
LastKey = (*RenderListIT)->Key;
DrawCalls++;
if ((*RenderListIT)->RenderMesh->Materials->Key != LastMatKey)
{
LastMatKey = (*RenderListIT)->RenderMesh->Materials->Key;
if ((*RenderListIT)->RenderMesh->HasMaterials == true)
{
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, (*RenderListIT)->RenderMesh->Materials->Diffuse );
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (*RenderListIT)->RenderMesh->Materials->Specular );
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, (*RenderListIT)->RenderMesh->Materials->Ambient );
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, (*RenderListIT)->RenderMesh->Materials->Emission );
}
}
if ((*RenderListIT)->RenderMesh->Key != LastMeshKey)
{
LastMeshKey = (*RenderListIT)->RenderMesh->Key;
if (VBO_Support)
{
glVertexPointer( 3, GL_FLOAT, sizeof(MyVertex), (GLvoid*) (*RenderListIT)->RenderMesh->VBO_Offset );
glNormalPointer( GL_FLOAT, sizeof(MyVertex), (GLvoid*)((*RenderListIT)->RenderMesh->VBO_Offset+sizeof(float)*3) );
glTexCoordPointer( 2, GL_FLOAT, sizeof(MyVertex), (GLvoid*)((*RenderListIT)->RenderMesh->VBO_Offset+sizeof(float)*6) );
glColorPointer( 3, GL_FLOAT, sizeof(MyVertex), (GLvoid*)((*RenderListIT)->RenderMesh->VBO_Offset+sizeof(float)*8) );
}
else
{
glVertexPointer( 3, GL_FLOAT, sizeof(MyVertex), &(*RenderListIT)->RenderMesh->VertexData->x );
glNormalPointer( GL_FLOAT, sizeof(MyVertex), &(*RenderListIT)->RenderMesh->VertexData->nx );
glTexCoordPointer( 2, GL_FLOAT, sizeof(MyVertex), &(*RenderListIT)->RenderMesh->VertexData->u );
glColorPointer( 3, GL_FLOAT, sizeof(MyVertex), &(*RenderListIT)->RenderMesh->VertexData->a );
}
}
if ((*RenderListIT)->RenderMesh->Active->Key != LastTexKey)
{
LastTexKey = (*RenderListIT)->RenderMesh->Active->Key;
if ((*RenderListIT)->RenderMesh->HasTexture == true)
{
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, (*RenderListIT)->RenderMesh->Active->TextureHandle);
}
else
{
glDisable(GL_TEXTURE_2D);
}
}
}
glDrawArrays(GL_TRIANGLES, 0, (*RenderListIT)->RenderMesh->NumVerticies);
glPopMatrix();
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_COLOR_ARRAY);
glDisable(GL_LIGHTING);
}
[/CODE]

And it's not moving the screen.

HELP!
0

Share this post


Link to post
Share on other sites
I would say that the effects of the initial glTranslate call (made for the camera) are being eliminated by by the glLoadIdentity calls in the render loop.

The push/pop matrix calls should be used to preserve the view transform, which can then be further modified to include world-space transformations for the object in question.

You should do additional research on matrices.

PS:

It's often a good idea to start with a very simple example, rather than a piece of your own complex system, especially when you're just learning the basics. So, for this question, it would be better for everyone if you were simply trying to move a single quad, rather than process some pipeline of your own design.

Also, if you're interested, you can look at a demo that I wrote for someone else, where translation and zoom are demonstrated in a fairly simple OpenGL program: [url="http://www.gamedev.net/topic/630672-2d-tile-based-world-problem/page__p__4976391#entry4976391"]Link[/url]
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