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

OpenGL
OpenGL 3.3 VBOs and VAOs.. Why do my models not render properly?

14 posts in this topic

Okay, I need some wisdom from this wonderful place, thankyou please!

Here's the deal: I wrote (based on Ranger_Ones method) a loader for .obj files. It works well! I am happy. However, we live in a world of 3.3 core these days, and so the Immediate Mode rendering I was doing is now not good enough, so we turn to VAOs and VBOs.

I'm familiar with the idea of how all this works, but not the implementation. I've had a few forays into looking this up, and I've got this far thanks to rastertek (once again), my computer graphics tutor, and the SuperBible and Beginning Game... 2 with.OpenGL.

Enough history! Time for some code, because it's easier to see how it worked. In fact.. I should proably take this time to apologize for posting such a lot of code. Sorry, dude.

This is how I render my client/cpu-side -stored arrays with immediate mode, atm:

[CODE]


//------------------elsewhere-----------------------------------------
struct Vertex3D { float x, y, z; }; typedef Vertex3D Normal3D; struct UV { float u, v;};

class Mesh { //we could assume mesh/model looks like this for clarity
Vertex3D * vertices;
Normal3D * normals;
UV * uvs;

/* for VBO, VAO functionality */
GLuint meshVAO;
GLuint meshVertexBuffer;
GLuint meshNormalBuffer;
GLuint meshTexCoordBuffer;
GLuint meshIndexBuffer;
GLuint meshColB; //? Unused


} //etc
//----------------------------------------------------------
glBegin(GL_TRIANGLES);
for ( int i = 0; i < mesh.noTriangles; i++ ) { //for each triangle in the list
Vector3D vpos; Normal3D npos;
for( int j = 0; j < 3; j++ ) {
// this vertex is the said triangle, verts attached
vpos.x = mesh.vertices[ mesh.triangleList[i].Vertex[j] ].x;
vpos.y = mesh.vertices[ mesh.triangleList[i].Vertex[j] ].y;
vpos.z = mesh.vertices[ mesh.triangleList[i].Vertex[j] ].z;
// this vertex is the said triangle, normals attached
npos.x = mesh.normals[ mesh.triangleList[i].Normal[j] ].x;
npos.y = mesh.normals[ mesh.triangleList[i].Normal[j] ].y;
npos.z = mesh.normals[ mesh.triangleList[i].Normal[j] ].z;

//PS SOMETIMES TEX COORDS TOO
glNormal3f(npos.x, npos.y, npos.z);
glVertex3f(vpos.x, vpos.y, vpos.z);
} //j++
} // i++
glEnd();

[/CODE]

And Now I'd like to do it with VBOs and a VAO per model.. So wheres the error in my setup thats causing my model not to render properly?

I've loaded a model into memory, I'm not going to edit it, but I'd like my RAM back.. and so STATIC_DRAW is k for now..

[CODE]
void GLModel::LoadBuffers() {
//if (glGenVertexArrays)
// cout << "okay" << endl;
glGenVertexArrays(1, &meshVAO); //Allocate an OpenGL VAO
glBindVertexArray(meshVAO); //Bind the VAO to store all the buffers and attributes we create here

//position data
glGenBuffers(1, &meshVertexBuffer); //Generate an ID for the Vertex Buffer
glBindBuffer(GL_ARRAY_BUFFER, meshVertexBuffer); //Bind the Vertex Buffer and load the vertex (position, normal, texcoord data) into the Vertex Buffer
glBufferData(GL_ARRAY_BUFFER, sizeof( Vertex3D ) * mesh.noVerts, mesh.vertices, GL_STATIC_DRAW);
glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex3D), (const GLvoid * ) 0 ); //attribute 0 gets vertex position data
/*
(const GLvoid * ) 0 refers to a pointer.. a pointer to where? or size of pointer? an offset?
*/
// normal data
glGenBuffers(1, &meshNormalBuffer);
glBindBuffer(GL_ARRAY_BUFFER, meshNormalBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof( Normal3D ) * mesh.noNormals, mesh.normals, GL_STATIC_DRAW);
glVertexAttribPointer( 1, 3, GL_FLOAT, GL_FALSE, sizeof(Normal3D), (const GLvoid * ) 0 ); //attribute 1 gets normal data
// texcoord data
glGenBuffers(1, &meshTexCoordBuffer);
glBindBuffer(GL_ARRAY_BUFFER, meshTexCoordBuffer);
glBufferData(GL_ARRAY_BUFFER, sizeof( UV ) * mesh.noTexCoords, mesh.texcoords, GL_STATIC_DRAW);
glVertexAttribPointer( 2, 2, GL_FLOAT, GL_FALSE, sizeof(UV), (const GLvoid * ) 0 ); //attribute 2 gets UV data
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);

// Faces / Indices
glGenBuffers(1, &meshIndexBuffer);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, meshIndexBuffer);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof( Triangle ) * mesh.noTriangles, mesh.triangleList, GL_STATIC_DRAW);

glBindVertexArray(0); //done binding to meshVAO
}
[/CODE]
0

Share this post


Link to post
Share on other sites
try moving the glEnableAttribArray() to before you bind another vbo, and possibly enable that index for ONLYthat vbo =)
i think that's what's happening here
2

Share this post


Link to post
Share on other sites
[quote name='Kaptein' timestamp='1351018443' post='4993165']
try moving the glEnableAttribArray() to before you bind another vbo, and possibly enable that index for ONLYthat vbo =)
i think that's what's happening here
[/quote]

I will let you know in the 'morrow friend! Thanks for your advice!
0

Share this post


Link to post
Share on other sites
Now this may help [url="http://www.arcsynthesis.org/gltut/"]Learning Modern 3D Graphics Programming[/url] (OpenGL 3.3).

Aaand this may help too [url="http://www.opengl.org/sdk/docs/man/xhtml/glVertexAttribPointer.xml"]glVertexAttribPointer[/url] (spoiler: last parameter is an offset).

All OpenGL functions are documented in OpenGL.org so as long you have internet, you can know more or less what each one does :D
2

Share this post


Link to post
Share on other sites
Hi Guys.

I tried moving the glVertexAttribArrayPointer( n ) to after the buffer creation for each buffer (vertices, normals, texcoords etc), but the effect is the same.

It's been annoying me not knowing what the last pointer for glVertexAttribArray was, and you know, I wondered if it was an offset! Thing is there is no offset - each buffer is created from a seperate array..? Thanks though TheChubu, I'll be using that resource often methinks! Also, I think I've come across that 1st link before - also good, so thank you!

[quote name='Kaptein' timestamp='1351018443' post='4993165']
and possibly enable that index for ONLYthat vbo =)
[/quote]

..can you nudge me a bit harder please? Thanks!

I'm wondering if it's my render-time code? The set up at init time seeeeeems to be fine. Heres the render code (by the by, I'm not sure all of this is necessary):
[CODE]
void GLModel::RenderElements() {
glPushMatrix();
glTranslatef(pos.x, pos.y, pos.z);
glColor3f( 0.0f, 1.0f , 0.0f );
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_CULL_FACE);
glBindVertexArray( meshVAO );
glDrawElements(GL_TRIANGLES, mesh.noTriangles * 9, GL_UNSIGNED_INT, (const GLvoid*) 0);
glEnable(GL_CULL_FACE);
glPolygonMode(GL_FRONT, GL_FILL);
glPopMatrix();
}
[/CODE]

Thanks again guys!
0

Share this post


Link to post
Share on other sites
you can take it step by step, but as the above person is telling you, start using shaders immediately
then we'll help you with everything else once you know for certain that your shaders are loaded and linked properly!

if you are doing everything manually, as it looks like you're doing, then you should be able to find small functions to load and link shaders easily enough
check and double check that the shaders are loaded and without errors, then call 911-GAMEDEV again :)
2

Share this post


Link to post
Share on other sites
The problem was indeed indexing, I've now got it working beautifully:

thing is struct Triangle held 9 ints, not 3.. (immediate mode relic - now all gone).
So I've replaced with a struct Face that holds only vertices indices, which is the index used for all three arrays on the GPU - tex coords, normals, and verts.

One nested for loop later before I bind any buffers and I'm good to go.

[CODE]glBindVertexArray( meshVAO );
glDrawElements(GL_TRIANGLES, mesh.noTriangles * 3, GL_UNSIGNED_INT, (const GLvoid*) 0);[/CODE]

And next I'm doing shaders - hence the setup above - this will be a fully textured, shaded, properly lit object in a few weeks..
Come March it will be .3DS, animated, instead of .obj too.. Wish me luck!

[quote name='Kaptein' timestamp='1351107389' post='4993519']
then you should be able to find small functions to load and link shaders easily enough
check and double check that the shaders are loaded and without errors, then call 911-GAMEDEV again
[/quote]

Indeed - a wrapper for the shaders is next on the list. Ahh shaders.. how I love thee!

..Also a few more preliminaries like a decent camera class, a wrapper for lights, implement DirectInput, etc etc
0

Share this post


Link to post
Share on other sites
My tutor has read this thread, and he agrees with Koehler's consensus. As do I, it just took a while to sink in. Apologies guys!

It's a bit messy - this whole project - because I'm trying to rewrite something that was written for FFP and redirect it for 3.3 core, and perhaps some GLES (but forget I even mentioned that for now).

So my draw method should look like this, given that m_Program is a compiled, linked, shader program..?

[CODE]
void GLModel::RenderElements() {
glUseProgram( m_Program );
glTranslatef(pos.x, pos.y, pos.z);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glDisable(GL_CULL_FACE);

glBindVertexArray( meshVAO );
glDrawElements(GL_TRIANGLES, mesh.noTriangles * 3, GL_UNSIGNED_INT, (const GLvoid*) 0);

glEnable(GL_CULL_FACE);
glPolygonMode(GL_FRONT, GL_FILL);
glUseProgram( 0 );
}
[/CODE]

I'll obviously have to set some uniforms somewhere? _ I can figure that out I'm sure.

Thanks again guys. :)

[quote name='Koehler' timestamp='1351092048' post='4993455']
the first argument to glVertexAttribPointer is supposed to be an attribute index in the shader program you plan to draw with, that you either bound before linking said program or retrieved via glGetAttribLocation after. I believe that on some hardware the way you're doing it (by mapping position to 0, normal to 1, and tex coords to 2) might work, but I wouldn't trust it.

If you just want to get what you have now working without shaders, try using glVertexPointer, glNormalPointer, and glTexCoordPointer in lieu of glVertexAttribPointer, and replace glEnableVertexAttribArray with glEnableClientState (call it 3 times, passing one of GL_NORMAL_ARRAY, GL_TEXTURE_COORD_ARRAY, GL_VERTEX_ARRAY each time)

Not to nitpick, but 3.3 core has deprecated the matrix stack as well. If you want to bring your code completely "up to date", I would recommend handling matrices yourself or with a library, making use of shaders for drawing geometry, and also using generic attribute buffers (glVertexAttribPointer and the like).
[/quote]

Shaders please!
Okay..
So the first attribute of glVertexAttribPointer( 0, 3, GL_FLOAT, GL_FALSE, sizeof(Vertex3D), (const GLvoid * ) 0 );
refers to, in the shader file, somethin like "layout vec3 (location = 0) in VxPos;" where location is the first paramater of glVertexAttribPointer?

Deprecated Matrix Stack - indeed!
This has been bugging me no end. Is something like float some_matrix[16]; really the best way to represent a matrix? Would something like some_matrix[4][4] be more or less efficient? I imagine the code would be a bit nicer..?

Generic Attribute Buffers?

For what its worth, the nitpicking is good, dude! Always, always helpful - I'm learnig a lot here! :)
0

Share this post


Link to post
Share on other sites
Don't worry I've briefly seen some code that demonstrates how to build matrices and with all the maths we did last year I have no excuse not to have it covered :)

[quote name='Koehler' timestamp='1351266019' post='4994175']
One step at a time is best.
[/quote]

Indeed! ..Replace glTranslate() with glUniform3f() - Done

[quote name='Koehler' timestamp='1351266019' post='4994175']
In C++, the choice between matrix[16] and matrix[4][4] comes down to which you like better. matrix[1][1] in the second is the same offset as matrix[4] in the first. The important thing to remember for openGL is that it is column-major in its memory layout (so array element 0 (or [0][0]) is row 0, column 0, but element 1 (or [0][1]) is row 1, column 0.
[/quote]

Sounds complicated, but something I'm eager to tackle - can't not really! This is port of call number one methinks as I have no replacement for the deprecated stack, and the one we use at university belongs to my tutor, so can't really use that.

[quote name='Koehler' timestamp='1351266019' post='4994175']
using view/projection matrices you copied out of the stack with glGetFloatv
[/quote]

... I'll enquire my tutor and some sample codes about this - possibly need those matrices first?

[quote name='Koehler' timestamp='1351266019' post='4994175']
work on building full model transforms (translation*rotation*scale) as well as your own view/projection calculations
[/quote]

I can do all these calculations in the vertex shader methinks, I just need to get the matrices in as uniforms :)

Basically, I need to figure out how to get the uniforms I need and how to pass them to the shader ( pretty sure I know this/have done this before ), make the shader class a bit more static so I can say "Give shader" in the GLModels Init, and then test!

I'll come back in a few days and let you know how far I've gotten, I've got a few beneficial labs in the weel that will be helpful with this.

Thank you my friend! :)
0

Share this post


Link to post
Share on other sites
Okay, I have the shaders working :) - I can see a white aeroplane, with the colour just hardcoded into the shader for now.

I'm also in the process of replacing anything that can be replaced with GLM, with GLM, which is how I'm getting uniform matrices into the shader.. ( Anything on the runtime side of loading the model that is - so animation / transformations and such )

The problem I'm having at the mo is finding a decent camera tutorial
- the camera I have at the moment is locked to look at the model while zooming in and out and moving around it, and it makes use of Fixed Function bits and bobs..

Does anybody have a favourite (GLM ?) camera tutorial..?

A quick final question.. what is the difference between these two frustum calls? They produce different results..

[CODE]
GLdouble fW, fH;
fH = tan( (fovY / 2) / (180 * gl_PI) ) * zNear;
fH = tan( fovY / 360 * gl_PI ) * zNear;
fW = fH * aspect;

//glm::frustum(-fW, fW, -fH, fH, zNear, zFar);
glFrustum( -fW, fW, -fH, fH, zNear, zFar ); // <- deprecated
[/CODE]
0

Share this post


Link to post
Share on other sites
What i posted before was wrong, so here is something right:
http://gamedev.stackexchange.com/questions/12726/opengl-es-2-0-understanding-perspective-projection-matrix
Edited by Kaptein
0

Share this post


Link to post
Share on other sites
[quote name='Kaptein' timestamp='1352098546' post='4997464']
i think you need 2 glfrustum calls (one for each Z-plane), but i could be wrong
[/quote]
That is completely wrong.

[quote name='Kaptein' timestamp='1352098546' post='4997464']
glm::frustum probably creates a perspective frustum directly for you with both planes
it could also create 6 normalized planes internally that you could do frustum culling with, such as bool glm::pointInFrustum(x, y, z)
(but i dont know the specifics)
[/quote]
I have no real clue what you are talking about.

All glFrustum did was creating a projection matrix that maps a capped world-space pyramid into [-1,+1]^3 and then implicitly calling glMultMatrix with that matrix (see [url=http://www.khronos.org/opengles/documentation/opengles1_0/html/glFrustum.html]the documentation[/url]). The reason glFrustum is deprecated is because modern OpenGL is no longer responsible for having a static projection/modelview matrix and applying it - you are now responsible for generating the matrices and sending them to your shaders as needed.
glm::frustum is identical to glFrustum as far as the creation of the matrix goes. Instead of multiplying it onto a global state that no longer exists, it returns that matrix as a glm::mat4 though so you can send it to your shaders.
1

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

  • Similar Content

    • By Toastmastern
      So it's been a while since I took a break from my whole creating a planet in DX11. Last time around I got stuck on fixing a nice LOD.
      A week back or so I got help to find this:
      https://github.com/sp4cerat/Planet-LOD
      In general this is what I'm trying to recreate in DX11, he that made that planet LOD uses OpenGL but that is a minor issue and something I can solve. But I have a question regarding the code
      He gets the position using this row
      vec4d pos = b.var.vec4d["position"]; Which is then used further down when he sends the variable "center" into the drawing function:
      if (pos.len() < 1) pos.norm(); world::draw(vec3d(pos.x, pos.y, pos.z));  
      Inside the draw function this happens:
      draw_recursive(p3[0], p3[1], p3[2], center); Basically the 3 vertices of the triangle and the center of details that he sent as a parameter earlier: vec3d(pos.x, pos.y, pos.z)
      Now onto my real question, he does vec3d edge_center[3] = { (p1 + p2) / 2, (p2 + p3) / 2, (p3 + p1) / 2 }; to get the edge center of each edge, nothing weird there.
      But this is used later on with:
      vec3d d = center + edge_center[i]; edge_test[i] = d.len() > ratio_size; edge_test is then used to evaluate if there should be a triangle drawn or if it should be split up into 3 new triangles instead. Why is it working for him? shouldn't it be like center - edge_center or something like that? Why adding them togheter? I asume here that the center is the center of details for the LOD. the position of the camera if stood on the ground of the planet and not up int he air like it is now.

      Full code can be seen here:
      https://github.com/sp4cerat/Planet-LOD/blob/master/src.simple/Main.cpp
      If anyone would like to take a look and try to help me understand this code I would love this person. I'm running out of ideas on how to solve this in my own head, most likely twisted it one time to many up in my head
      Thanks in advance
      Toastmastern
       
       
    • By fllwr0491
      I googled around but are unable to find source code or details of implementation.
      What keywords should I search for this topic?
      Things I would like to know:
      A. How to ensure that partially covered pixels are rasterized?
         Apparently by expanding each triangle by 1 pixel or so, rasterization problem is almost solved.
         But it will result in an unindexable triangle list without tons of overlaps. Will it incur a large performance penalty?
      B. A-buffer like bitmask needs a read-modiry-write operation.
         How to ensure proper synchronizations in GLSL?
         GLSL seems to only allow int32 atomics on image.
      C. Is there some simple ways to estimate coverage on-the-fly?
         In case I am to draw 2D shapes onto an exisitng target:
         1. A multi-pass whatever-buffer seems overkill.
         2. Multisampling could cost a lot memory though all I need is better coverage.
            Besides, I have to blit twice, if draw target is not multisampled.
       
    • By mapra99
      Hello

      I am working on a recent project and I have been learning how to code in C# using OpenGL libraries for some graphics. I have achieved some quite interesting things using TAO Framework writing in Console Applications, creating a GLUT Window. But my problem now is that I need to incorporate the Graphics in a Windows Form so I can relate the objects that I render with some .NET Controls.

      To deal with this problem, I have seen in some forums that it's better to use OpenTK instead of TAO Framework, so I can use the glControl that OpenTK libraries offer. However, I haven't found complete articles, tutorials or source codes that help using the glControl or that may insert me into de OpenTK functions. Would somebody please share in this forum some links or files where I can find good documentation about this topic? Or may I use another library different of OpenTK?

      Thanks!
    • By Solid_Spy
      Hello, I have been working on SH Irradiance map rendering, and I have been using a GLSL pixel shader to render SH irradiance to 2D irradiance maps for my static objects. I already have it working with 9 3D textures so far for the first 9 SH functions.
      In my GLSL shader, I have to send in 9 SH Coefficient 3D Texures that use RGBA8 as a pixel format. RGB being used for the coefficients for red, green, and blue, and the A for checking if the voxel is in use (for the 3D texture solidification shader to prevent bleeding).
      My problem is, I want to knock this number of textures down to something like 4 or 5. Getting even lower would be a godsend. This is because I eventually plan on adding more SH Coefficient 3D Textures for other parts of the game map (such as inside rooms, as opposed to the outside), to circumvent irradiance probe bleeding between rooms separated by walls. I don't want to reach the 32 texture limit too soon. Also, I figure that it would be a LOT faster.
      Is there a way I could, say, store 2 sets of SH Coefficients for 2 SH functions inside a texture with RGBA16 pixels? If so, how would I extract them from inside GLSL? Let me know if you have any suggestions ^^.
    • By KarimIO
      EDIT: I thought this was restricted to Attribute-Created GL contexts, but it isn't, so I rewrote the post.
      Hey guys, whenever I call SwapBuffers(hDC), I get a crash, and I get a "Too many posts were made to a semaphore." from Windows as I call SwapBuffers. What could be the cause of this?
      Update: No crash occurs if I don't draw, just clear and swap.
      static PIXELFORMATDESCRIPTOR pfd = // pfd Tells Windows How We Want Things To Be { sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor 1, // Version Number PFD_DRAW_TO_WINDOW | // Format Must Support Window PFD_SUPPORT_OPENGL | // Format Must Support OpenGL PFD_DOUBLEBUFFER, // Must Support Double Buffering PFD_TYPE_RGBA, // Request An RGBA Format 32, // Select Our Color Depth 0, 0, 0, 0, 0, 0, // Color Bits Ignored 0, // No Alpha Buffer 0, // Shift Bit Ignored 0, // No Accumulation Buffer 0, 0, 0, 0, // Accumulation Bits Ignored 24, // 24Bit Z-Buffer (Depth Buffer) 0, // No Stencil Buffer 0, // No Auxiliary Buffer PFD_MAIN_PLANE, // Main Drawing Layer 0, // Reserved 0, 0, 0 // Layer Masks Ignored }; if (!(hDC = GetDC(windowHandle))) return false; unsigned int PixelFormat; if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd))) return false; if (!SetPixelFormat(hDC, PixelFormat, &pfd)) return false; hRC = wglCreateContext(hDC); if (!hRC) { std::cout << "wglCreateContext Failed!\n"; return false; } if (wglMakeCurrent(hDC, hRC) == NULL) { std::cout << "Make Context Current Second Failed!\n"; return false; } ... // OGL Buffer Initialization glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); glBindVertexArray(vao); glUseProgram(myprogram); glDrawElements(GL_TRIANGLES, indexCount, GL_UNSIGNED_SHORT, (void *)indexStart); SwapBuffers(GetDC(window_handle));  
  • Popular Now