• 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
Adam West

please help me!

2 posts in this topic

hey there,
im currently in a bit of trouble with my code:
firstly, the skybox is not showing up on my screen, just a grey overlay.
Also, i cant assign one texture to different objects.
Lastly, Why is my box being cut off where it is ( yes that's a box!)
please help me,
CODE:

main.h
[CODE]
//Include STD headers
#ifndef MAIN_H
#define MAIN_H

#include<GL/glew.h>
#include<GL/glfw.h>
#include<GL/freeglut.h>
#include <vector>
#include<algorithm>
#include <fstream>
#include<cstdio>
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cmath>
#include <SFML/Graphics.hpp>
#include <SOIL.h>

//Include GLM
#include <glm/glm.hpp>
using namespace std;
extern GLuint loadShader(const char* vertex_file_path, const char* fragment_file_path);
extern int loadTexture(const char* texfilename,GLuint textureObject);
extern void deleteTexture(GLuint textureObject);
extern void InitializeWindow();
extern void shutdown();
#endif
[/CODE]

skybox.h
[CODE]
#include "main.h"

class skybox
{
public:
void initSkybox( const char* xpos, const char* xneg, const char* ypos, const char* yneg, const char* zpos, const char* zneg);
void skyboxVBO();
void drawSkybox();
void destroySkybox();
//constants for the skybox
};
[/CODE]
texture.cpp
[CODE]
#include "3dsloader.h"

int loadTexture(const char* texfilename,GLuint textureObject) //load bitmap and convert to texture
{
glGenTextures(1,&textureObject); // allocate memory for one texture
glBindTexture( GL_TEXTURE_2D,textureObject); // use our newest texture

textureObject = SOIL_load_OGL_texture(texfilename,SOIL_LOAD_AUTO,SOIL_CREATE_NEW_ID,SOIL_FLAG_MIPMAPS);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // give the best result for texture magnification
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //give the best result for texture minification
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); // don't repeat texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); // don't repeat texture
return textureObject;
}

//MAY NOT WORK PROPERLY
void deleteTexture(GLuint textureObject)
{
glDeleteTextures(1,&textureObject);
}
[/CODE]
shader.cpp
[CODE]
#include "3dsloader.h"

int loadTexture(const char* texfilename,GLuint textureObject) //load bitmap and convert to texture
{
glGenTextures(1,&textureObject); // allocate memory for one texture
glBindTexture( GL_TEXTURE_2D,textureObject); // use our newest texture

textureObject = SOIL_load_OGL_texture(texfilename,SOIL_LOAD_AUTO,SOIL_CREATE_NEW_ID,SOIL_FLAG_MIPMAPS);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // give the best result for texture magnification
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); //give the best result for texture minification
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP); // don't repeat texture
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP); // don't repeat texture
return textureObject;
}

//MAY NOT WORK PROPERLY
void deleteTexture(GLuint textureObject)
{
glDeleteTextures(1,&textureObject);
}
[/CODE]
skybox.cpp
[CODE]
#include "skybox.h"
GLuint skyboxShaderID;
GLuint skytexture;
GLint vertex;
void skybox::initSkybox(const char* xpos, const char* xneg, const char* ypos, const char* yneg, const char* zpos, const char* zneg)
{

glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_CUBE_MAP);
glGenTextures(1,&skytexture);
skytexture = SOIL_load_OGL_cubemap(
xpos,
xneg,
ypos,
yneg,
zpos,
zneg,
SOIL_LOAD_RGB,
SOIL_CREATE_NEW_ID,
0
);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

}

void skybox::destroySkybox()
{
glDeleteTextures(1, &skytexture);
}


GLuint skyboxVertexBuffer;
GLuint skyboxIndexBuffer;
void skybox::skyboxVBO()
{
glGenBuffers(1, &skyboxVertexBuffer);
glBindBuffer(GL_ARRAY_BUFFER, skyboxVertexBuffer);

GLfloat skybox_vertex_data[] =
{
-1.0, -1.0, 1.0,
1.0, -1.0, 1.0,
-1.0, 1.0, 1.0,
1.0, 1.0, 1.0,
-1.0, -1.0, -1.0,
1.0, -1.0, -1.0,
-1.0, 1.0, -1.0,
1.0, 1.0, -1.0,
};

glBufferData(GL_ARRAY_BUFFER, sizeof(skybox_vertex_data), skybox_vertex_data, GL_STATIC_DRAW);
glGenBuffers(1, &skyboxIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, skyboxIndexBuffer);

GLubyte indices[14] = {0, 1, 2, 3, 7, 1, 5, 4, 7, 6, 2, 4, 0, 1};
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(indices), indices, GL_STATIC_DRAW);
}
void skybox::drawSkybox()
{
glClearColor(0.5f, 0.5f, 0.5f, 1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
skyboxShaderID = loadShader("assets/skybox/skybox.vert","assets/skybox.skybox.frag");
glUseProgram(skyboxShaderID);
glDisable(GL_DEPTH_TEST); // skybox should be drawn behind anything else
glBindTexture(GL_TEXTURE_CUBE_MAP,skytexture);

glBindBuffer(GL_ARRAY_BUFFER,skyboxVertexBuffer);
glVertexAttribPointer(skyboxShaderID, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glEnableVertexAttribArray(skyboxShaderID);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, skyboxIndexBuffer);
glDrawElements(GL_TRIANGLE_STRIP, 14, GL_UNSIGNED_BYTE, 0);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
glEnable(GL_DEPTH_TEST);
}
[/CODE]
main.cpp
[CODE]
#include "main.h"
#include "3dsloader.h"
#include "camera.h"
#include "skybox.h"
bool mousein= false;
GLuint programID;
void lighting();
void initRendering();
void drawScene();
void mainLoop();
FPSCamera * camera;
Object* testcube;
GLuint testObjTex;
skybox* sky;

int main(int argc, char **argv)
{
bool running = true;

InitializeWindow();

sky->initSkybox("assets/skybox/citystorm/xpos.jpg","assets/skybox/citystorm/xneg.jpg","assets/skybox/citystorm/ypos.jpg","assets/skybox/citystorm/yneg.jpg","assets/skybox/citystorm/zpos.jpg","assets/skybox/citystorm/zneg.jpg");
sky->skyboxVBO();
testcube = new Object("test.3ds");

testcube->CreateVBO();
initRendering();

//shader setup
programID = loadShader("emptyshader.vert","bokehDOF.frag");
mainLoop();


return 0;
}
void initRendering()
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glShadeModel(GL_SMOOTH);
glEnable(GL_TEXTURE_2D);
glEnable(GL_DEPTH_TEST);
glDepthMask(GL_TRUE);
// Enable lighting and set the position of the light
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
GLfloat pos[] = { 0.0, 4.0, 4.0 };
glLightfv(GL_LIGHT0, GL_POSITION, pos);

}

void mainLoop(void)
{
// the time of the previous frame
double old_time = glfwGetTime();
// this just loops as long as the program runs
while(1)
{
// KEY EVENTS 1
// escape to quit,

//use shader
glUseProgram(programID);
camera->updateCamera();

if (glfwGetKey(GLFW_KEY_ESC) == GLFW_PRESS)
break;

if (glfwGetMouseButton(GLFW_MOUSE_BUTTON_LEFT) == GLFW_PRESS)
{
mousein = true;
glfwDisable(GLFW_MOUSE_CURSOR);

}
if(glfwGetKey('P') == GLFW_PRESS)
{
mousein=false;
glfwEnable(GLFW_MOUSE_CURSOR);

}
camera->Control(0.2,0.2,mousein);
// draw the figure

drawScene();


// swap back and front buffers
glfwSwapBuffers();

}
}

void drawScene()
{
//clear info from last draw
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

//skybox for scene
sky->drawSkybox();
// ADD SCENE OBJECTS TO RENDER HERE


//model loading and stuff
glEnable(GL_TEXTURE_2D);
loadTexture("texture.jpg",testObjTex);
testcube->Draw();
glDisable(GL_TEXTURE_2D);
glLoadIdentity();
};

void shutdown()
{
glfwTerminate();
sky->destroySkybox();
delete sky;
sky= NULL;
deleteTexture(testObjTex);
delete testcube;
testcube = NULL;
delete camera;
camera = NULL;
exit(1);
}
[/CODE]


all input is welcome as i am in a rush to get this working!
0

Share this post


Link to post
Share on other sites
Are you sure, in case if your skybox, that the shader is correct?

About the box, seems like your far clipping plane is causing this. Have you tried moving the box towards the camera and see if it gets in view? If you rotate it, will it be cut off at the same place? Does the model always look like that no matter what orientation?

If you, for example, treat the skybox the same as any other model, your skybox might also be the victim of your clipping plane.

If you're using a model loader. Are you sure the exported model is correct? Is the data you read in correct? Do you pass all the correct data for rendering?

Seeing your past posts, I think you should take a step down and try to understand what you are doing here, because I think you're rather clueless on what is going on right now. It might be a good idea to get a grip on the fixed function pipeline, the basics at least, to learn some basic opengl. You can move to shaders later.
-1

Share this post


Link to post
Share on other sites
[code]skyboxShaderID = loadShader("assets/skybox/skybox.vert","assets/skybox.skybox.frag");[/code]
You are creating new shader object each frame (if I understand your code correctly).
[code]glVertexAttribPointer(skyboxShaderID, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);
glEnableVertexAttribArray(skyboxShaderID);[/code]
You are using shader ID as attribute index here.
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