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

not using texture right? model not drawing

4 posts in this topic

I am trying to draw a model that I loaded into memory using a custom format. I think it might have to do with the way I'm handling textures. I'm not getting any GLSL errors. These are the two functions I use that deal with loading and drawing the model

/**************************************************
Model object has the following functions to load
and to draw:
**************************************************/
 
bool Model::loadModel(const std::string& fname, GLuint pgm_id){
 
        ModelTexture* texture = nullptr;
 
        unsigned int vbo_size = 0;
        unsigned int tbo_size = 0;
 
        program_id = pgm_id;
 
        if(!BPFImporter::importBPFModel(fname,data)){
                return false;
        }
 
        vbos.resize(data.file_header.object_count);
        glGenBuffers(data.file_header.object_count, &vbos.front());
 
        for(unsigned int obj = 0; obj < data.file_header.object_count; obj++){
                vbo_size = data.objects.at(obj).object_header.vertex_count*sizeof(ModelVertex);
                glBindBuffer(GL_ARRAY_BUFFER, vbos.at(obj));
                if(data.objects.at(obj).object_header.animated_flag != 0){
                        glBufferData(GL_ARRAY_BUFFER,vbo_size,&data.objects.at(obj).vertices.front(),GL_STREAM_DRAW);
                }else{
                        glBufferData(GL_ARRAY_BUFFER,vbo_size,&data.objects.at(obj).vertices.front(),GL_STATIC_DRAW);
                }
        }
 
        tbos.resize(data.file_header.material_count);
        glGenTextures(data.file_header.material_count, &tbos.front());
 
        //store appropriate textures... (only does first texture of every material...)
        for(unsigned int mat = 0; mat < data.file_header.material_count; mat++){
                texture = &data.materials.at(mat).textures.front();
 
                glBindTexture(GL_TEXTURE_2D, tbos.at(mat));
                glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
                                         texture->texture_header.width,
                                         texture->texture_header.height,
                                         0,
                                         GL_RGBA,
                                         GL_UNSIGNED_BYTE,
                                         &texture->texels.front());
 
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
                glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
        }
 
        return true;
}
 
void Model::drawModel(){
 
        ModelObjectHeader *object_header;
        std::vector<ModelFace> *faces;
 
        glUseProgram(program_id);
 
        for(unsigned int obj = 0; obj < data.file_header.object_count; obj++){
 
                object_header = &data.objects.at(obj).object_header;
                faces = &data.objects.at(obj).faces;
 
                glBindBuffer(GL_ARRAY_BUFFER,vbos.at(obj));
                glBindTexture(GL_TEXTURE_2D, tbos.front());
               
                //setup vertex position pointer
                glEnableVertexAttribArray(0);
                glVertexAttribPointer(0,4,GL_FLOAT,GL_FALSE,sizeof(ModelVertex),(void*)COORD_OFFSET);
 
                //setup vertex normal pointer
                glEnableVertexAttribArray(1);
                glVertexAttribPointer(1,3,GL_FLOAT,GL_FALSE,sizeof(ModelVertex),(void*)NORMAL_OFFSET);
 
                //setup vertex texture pointer
                glEnableVertexAttribArray(2);
                glVertexAttribPointer(2,2,GL_FLOAT,GL_FALSE,sizeof(ModelVertex),(void*)TEXTURE_OFFSET);
 
 
                glDrawElements(GL_TRIANGLES, object_header->face_count,GL_UNSIGNED_BYTE, (void*)&faces->front());
                glDisableVertexAttribArray(0);
                glDisableVertexAttribArray(1);
                glDisableVertexAttribArray(2);
        }
        return;
}
 
I've tested data in the structures that hold the model data. This is what I got printed out:
 

 

Object[0]
---------
 
        Object Header
        -------------
 
        vertex_count:24
        face_count:12
        material_index:0
        coord_flag:1
        color_flag:0
        normal_flag:1
        texture_flag:1
        animated_flag:0
 
                Vertex Positions
                ----------------
 
                1,1,-1,1
                1,-1,-1,1
                -1,-1,-1,1
                -1,1,-1,1
                1,0.999999,1,1
                -1,1,1,1
                -1,-1,1,1
                0.999999,-1,1,1
                1,1,-1,1
                1,0.999999,1,1
                0.999999,-1,1,1
                1,-1,-1,1
                1,-1,-1,1
                0.999999,-1,1,1
                -1,-1,1,1
                -1,-1,-1,1
                -1,-1,-1,1
                -1,-1,1,1
                -1,1,1,1
                -1,1,-1,1
                1,0.999999,1,1
                1,1,-1,1
                -1,1,-1,1
                -1,1,1,1
               
                Vertex Normals
                --------------
 
                0.666667,0.333333,-0.666667
                0.408248,-0.816497,-0.408248
                -0.666667,-0.333333,-0.666667
                -0.408248,0.816497,-0.408248
                0.333333,0.666666,0.666667
                -0.816496,0.408249,0.408248
                -0.333333,-0.666667,0.666667
                0.816496,-0.408249,0.408248
                0.666667,0.333333,-0.666667
                0.333333,0.666666,0.666667
                0.816496,-0.408249,0.408248
                0.408248,-0.816497,-0.408248
                0.408248,-0.816497,-0.408248
                0.816496,-0.408249,0.408248
                -0.333333,-0.666667,0.666667
                -0.666667,-0.333333,-0.666667
                -0.666667,-0.333333,-0.666667
                -0.333333,-0.666667,0.666667
                -0.816496,0.408249,0.408248
                -0.408248,0.816497,-0.408248
                0.333333,0.666666,0.666667
                0.666667,0.333333,-0.666667
                -0.408248,0.816497,-0.408248
                -0.816496,0.408249,0.408248
               
                Vertex TCoords
                --------------
 
                0.9999,0.9999
                0.0001,0.0001
                0.0001,0.0001
                0.9999,0.9999
                0.9999,0.9999
                0.0001,0.0001
                0.0001,0.0001
                0.999899,0.999899
                0.9999,0.9999
                0.9999,0.9999
                0.0001,0.0001
                0.0001,0.0001
                0.9999,0.9999
                0.9999,0.9999
                0.0001,0.0001
                0.0001,0.0001
                0.0001,0.0001
                0.0001,0.0001
                0.9999,0.9999
                0.9999,0.9999
                0.9999,0.9999
                0.9999,0.9999
                0.0001,0.0001
                0.0001,0.0001
 
/**********************************************************
data.objects.at(obj).faces contains the following:
**********************************************************/
                Vertex Indices
                --------------
 
                0,1,2
                0,2,3
                4,5,6
                4,6,7
                8,9,10
                8,10,11
                12,13,14
                12,14,15
                16,17,18
                16,18,19
                20,21,22
                20,22,23

 

The model is just a simple crate with one texture. Something easy to test values on. I've printed out and checked the texel values too and they are correct. I matched the rgba values to what I get in gimp. They all match.

0

Share this post


Link to post
Share on other sites

You don't need to store the w coordinate for your positions, just xyz.

Are you using a version of opengl that you can call glVertex3f()? Your question is too broad. Disable the shader and see what you get normally. There are a lot of options, disable the shader, strip out all the normal/tex coord stuff and just deal with positions without a shader.

0

Share this post


Link to post
Share on other sites

Ok, I am forcing a OpenGL 3.2 context. Using GLSL 330. I've had models with no textures working in my custom format. But I've done a major reworking of everything to make it cleaner and smoother.  The model that was working was just the traditional colored triangle I wrote in my file format by hand using a hex editor. At this point, I decided to write my exporter to export .3ds files to my format. It's completed. I've tested it thoroughly. I wrote a set of importer functions and tested them out and it all gets loaded in the data structures in the same form that I was originally using.

Anyways, I took your suggestion. There are no matrix transformations occuring in my program at the moment.  The view, projection and everything hasn't been touched. I'm using a grey colored cube. with dimenions in the range of 1,1,1 to -1,-1,-1. I clear the background to black, and draw this grey cube. Nothing shows up. Is my problem that I'm looking from inside the cube out? Interestingly enough if I turn the background color to something like blue, go into wireframe mode then I can see the polygons of a square. This is what I'd expect. a grey square taking up the entire view... but yeah

0

Share this post


Link to post
Share on other sites

What's your viewport setting? Are you sure of the winding order? Are you front or back face culling?

 

Edit - try translating along the -Z axis, I guess you looking from the inside out.

Edited by mark ds
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