Tag Info

New answers tagged

0

As suggested in the comments, the precision directives are not supported in the OpenGL version that haxe/lime compiles to. Adding a #version 130 doesn't work either, maybe haxe or lime doesn't read these I don't know. Anyway I found the solution reading through the lime samples: #if !desktop "precision mediump float;" + #end "varying vec4 v_color; void ...


0

Ok i found the problem. It came down to my misconception of when to call glBindAttribLocation.


2

glRotatef and glTranslatef are old functions meant for use with the fixed-function pipeline, so they don't work with opengl 4 shaders. Instead you need to create a matrix, send it to your shader, and multiply your vertices by it when setting gl_Position. The exact process will probably be covered in one of the following tutorials on that site, so I'd ...


5

Indeed, the values stored in the z-buffer are not linear to the actual z coordinates of your objects, but to their reciprocal, in order to give more resolution to what's near the eye than to what's closer to the back plane. What you do is that you map your zNear to 0 and your zFar to 1. For zNear=1 and zFar=2, it should look like this The way to ...


0

1000/65536 == 0.0152587890625. Just use increments of 0.015 or maybe 0.015625, because it has accurate binary representation (2**(-6)). With the latter you'll get 1000/(2**(-6)) == 64000 unique positions.


0

Maybe you should change You'r approach to something simpler. What I would do; Keep your Z depth thing, but keep a list of what you render. Order that list based on the z Depth value, and render objects in the order of the list. Hope this can help. People always tell me to keep things simple.


3

You can also assume that "laser beam" is cylinder, and create a billboard for that: http://www.opengl-tutorial.org/intermediate-tutorials/billboards-particles/billboards/


4

I would do this by rendering textured quads. A single laser beam would be two rectangles intersecting each other at the center by a perpendicular angle, each sharing the same texture of the laser beam. Not very much to it, you can use instancing for them, with a very simple pixel shader which just samples the texture, oh and additive blending.


0

There are a number of ways to color objects in OpenGL. You can specify colors as vertex attributes. You can apply textures to objects by supplying texture coordinates and the actual textures. You can write fragment shaders to determine the color programatically. Or you can use a combination of those 3 things (and possibly others). Does your "3ds" file ...


0

If you want a rounded corner like the true cube I would use a texture map with a black border and transparent area which you wish your base colour to be visible through. There is also newer methods of drawing shapes using paths but I haven't looked at these so I cannot advise how you could do those. Hope it helps.


0

It's not quite as simple as simply tinting the specular color with albedo for metals. For metals the albedo is used to define specular reflectance at normal incidence, but this color goes to white at grazing angles due to Fresnel effect. You can use Schlick's approximation for this computation.


1

You want to draw a 32x32 sprite, right? If so, Don't do what @Soapy said and don't call glViewport() to draw each sprite in your game! It probably will be very slow and it is not how you should make your graphics. It's like buying a new hammer each time you want to hammer a nail. Yes, it may work, but it's not the good way. You can't rotate sprites with ...


0

Generally, whether you rotate around "local Y" or "world Y" depends on the order you apply the rotations. If you're "free flying", then your variable ry no longer has a specific meaning, because all the moves are cumulative. You can keep a matrix, and apply successive rotations and translations to it to fly around. After a long while, there can be ...


2

CLARIFICATION glViewport will set the size of your viewport you are rendering to. This answer assumes that you were doing something along the lines of this: glViewport(0, 0, 1920, 1080); Which would give you a 16:9 aspect ratio. Setting it to something like: glViewport(0, 0, 800, 600); Would give you the correct aspect ratio (and hopefully answers ...


0

A good solution is rendering the face black, then render the face with your selected color with less height and width. Also, render it a bit outwards, for eviting z-fighting.


1

Given that top left is at 0, and each tile is square with length 10: int squareClickedX = clickPosX / 10 int squareClickedY = clickPosY / 10 So, if clicked on x23, y12 int squareClickedX = 23 / 10 int squareClickedY = 12 / 10 results int squareClickedX = 2 int squareClickedY = 1 Means that you clicked Was this any good? This is quite common way ...


3

I believe that OpenGL's standard clipping volume is [-1, 1] x [-1, 1] x [-1, 1]. You want to clip at [-1, 1] x [-1, 1] x [0, 1]. You can achieve this by transforming the z-coordinate after all transformations have been applied to the vertex position (model, view and projection transforms). In other words, you want to operate on the screen coordinates of the ...


0

its fixed now, onbegin always set the viewport. because onEnd method the viewport restored to the original screen viewport regardless its return to another fbo. so everytime more than > 1 deep will call viewport with scale of screen, this causing mess because the screen viewport has design ratio. so fix it by ensuring the viewport to original set for each ...


0

For that kind of behaviour you generally Rotate about the origin, then Translate, then Scale. Since you want to rotate from the center bottom of your quad, from the origin you'd: 1. Translate the image to have its center at the origin ((width/2)) 2. Rotate 3. Translate to the desired location I'm not familiar with the inner works of OpenGL (I work with a ...


1

You can use an Orthographic projection matrix to transform your vertexes. Then you can simply provide your triangle verts in terms of screen pixels, e.g.: a vertex at (0,0), one at (10, 0) and one at (5, 10). Here's another reference of OpenGL matrices, with a lot of maths. Make sure to do a search for "OpenGL orthographic projection" and "2D drawing with ...


0

The title of your question is different from what you're actually asking. I assume you are asking how to render a textured quad like a part of your game's HUD. Here's what you can do to have an object rendered on top of your other objects: void renderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Set up matrixes in order to ...


0

my friend helped me to solve the problem, honestly, i still dont know what the problem was in the previous one, but i changed function as void keypress(unsigned char key, int x, int y) { Matrix R; HomVector a; switch(key) { ... case 'i': cam.rotation.x -=1.0f; break; case 'I': cam.rotation.x += 1.0f; break; case 'j': cam.rotation.y -= ...


0

With open gl you can't just bind a texture before creating it. Instead of keeping a counter called num_textures. Each time you want to create a new texture, retrieve a handle from OpenGL's glGenTextures function. int id; glGenTextures(1, &id); So you would get rid of num_texture and all its usages. And instead of this: glBindTexture(GL_TEXTURE_2D, ...


0

I can't post comments yet, but.. You said that you're moving the object, but from your code it seems that you're moving the camera (not the object). I see nothing wrong with the key presses though, the only thing that comes to mind is that if your camera happens to be centered on, say, a Cube, with no lights, rotating 90 degrees won't change the image so you ...


0

You need to use a textured quad with an orthographic projection matrix. Using alpha blending will make the image partially transparent allowing for the image to not appear square.


0

You question is a little unclear, but if you asked how to render, for instance a GUI, I have an answer. Basically you need to render a textured 2d quad. Note that it should be rendered last. Heres a video tutorial: https://www.youtube.com/watch?v=vOmJ1lyiJ4A&list=PLRIWtICgwaX0u7Rf9zkZhLoLuZVfUksDP&index=24


0

i have done like this to supprot multiple resolution............. my AppMacro.h #ifndef __APPMACROS_H__ #define __APPMACROS_H__ #include "cocos2d.h" #define DESIGN_RESOLUTION_480X320 0 #define DESIGN_RESOLUTION_480X320 1 #define DESIGN_RESOLUTION_1024X768 2 #define DESIGN_RESOLUTION_1280X800 3 #define DESIGN_RESOLUTION_2048X1536 4 /* If you ...


0

You have to send the data to the first address of the array, e.g. t[0] glUniform1fv(glGetUniformLocation(_program, "t[0]"), 2, threshold);


2

VAO stores data about vertex attribute locations. (And some other data related to them.) "VBO bindings, active shader program, texture bindings, texture sampling/wrapping settings, uniforms" are completely unrelated to it. You may ask why it doesn't remember VBO binding. Because you don't need to bind VBO to draw something, you only need to bind it when ...


1

It only stores the vertex binding and the index buffer binding That is all the parameters of glVertexAttribPointer plus the buffer bound to Vertex_Array_buffer at the time of the call to glVertexAttribPointer and the bound Element_Array_buffer. Uniforms are part of the current program. Everything else is global state. In doubt you can check the state ...


0

You probably should avoid sphere to intersect multiple triangles. Since you can determine time to collision for a sphere and triangle, therefore, when you detect case of multiplie collision just choose shortest time and advance your simulation for this time instead of fixed timestep. Thus you can be sure you always will deal with single collision.


0

The problem is that your rendering is not pixel aligned. The same problem is visible with the bigger text as well. When zooming in, you can clearly see blurred edges everywhere. Interestingly this only happens in horizontal direction, not vertical. Without any code it's impossible to tell where the problem is, but first thing to do is make sure your ...


4

You can get this behaviour without a branch using the step function: float blendFactor = step(3.0f, dot(B.rgb, B.rgb)); return lerp(B, A, blendFactor); When B = (1, 1, 1), dot(B, B) = 3.0f, so step returns 1, blendFactor = 1, and the lerp gives a result of A. When B is anything less, dot(B, B) < 3.0f, so step returns 0, blendFactor drops to 0, and the ...


0

Now that I know that the context is rendering to a texture frame buffer I can try to answer. Yes, you do have to glDisable(GL_BLEND) otherwise it will blend according to whatever glBlendFunc is currently set, which will mess with the RGB channels based on what you're writing to the alpha channel. Then you need to do blending you write it in your shader. ...


0

A solution is to avoid deallocating the btBvhTriangleMeshShape altogether. Instead of this: physics_object->triangle_mesh_shape = new btBvhTriangleMeshShape{physics_object->triangle_mesh, true}; physics_object->collision_shape = new btBvhTriangleMeshShape{*physics_object->triangle_mesh_shape}; Use this: physics_object->collision_shape = ...


5

If the textures are the same general "shape" (dimensions, mip levels, etc.) then use texture arrays. You can pack differently "shaped" textures into different arrays if you have any regularity, which you should. This approach gives you all the advantages of individual textures (e.g., no bleeding) plus all the advantages of a texture atlas (e.g. fewer state ...


0

Use big texture, it's better. Avoiding pixel leakage is no that hard: If you can, use GL_NEAREST, else add small empty lines between textures.


0

Profiling is always the best choice... But I've liked the combined texture approach the most it makes it easier to deal with trying to minimize swaps because you don't have to :) You may also want to look at some of the sampling options you selected they could reduce the issue of the neighbor pixels bleeding into other textures.


0

I finally figured this out, and it's impossible to solve knowing only the code here, because it is actually right. The issue was the way normal maps were uploaded to OpenGL. In glTexImage2D you specify the internalFormat - the normal map was uploaded to OpenGL using the same code as diffuse textures, which are in non-linear colorspaces, so i was using ...



Top 50 recent answers are included