opengl


What am I doing wrong, in regards to multi-texture(OpenGL)?


I am writing a bump mapping demo, so I need an image texture, and a normal texture which should be loaded into the fragment shader.
This is the texture part of my OpenGL code:
glActiveTexture(GL_TEXTURE0);
GLuint textureID;
glGenTextures(1, &textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE, brick);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint textureLocation = glGetUniformLocation(shader, "texture");
glUniform1i(textureLocation, 0);
glActiveTexture(GL_TEXTURE1);
GLuint normal_textureID;
glGenTextures(1, &normal_textureID);
glBindTexture(GL_TEXTURE_2D, normal_textureID);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 1024, 1024, 0, GL_RGB, GL_UNSIGNED_BYTE,
brick_texture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLint normalTextureLocation = glGetUniformLocation(shader, "normal_texture");
glUniform1i(normalTextureLocation, 1);
Here is the fragment shader:
uniform vec3 light;
uniform sampler2D texture;
uniform sampler2D normal_texture;
void main() {
vec3 tex = texture2D(normal_texture, gl_TexCoord[0].st).rgb;
gl_FragColor = vec4(tex, 1.0);
}
I am sure that the brick array contains the image texture, and the brick_texture array contains the normal texture; but it seems normal_texture and texture are both the image texture, not the normal texture. What am I doing wrong, in regards to multi-texture?

Related Links

How to use VBOs efficiently
OpenGL Lighting and Material Error When Switching Between Different Scenes
OpenGL rotation too sensitive
Bad Performance with VBO and shaders
128bit texture in openGL does not display (black screen)
What is the logic behind forming co-ordinate points for circle in opengl
Besides how texels are fetched, what differences are there between 2D and 3D textures?
vertex shader Normalization
pyopengl: glFramebuffer function errors
How to get library: OpenGL 3.1 and GLUT 3 on Ubuntu 12.04 [closed]
minimum/maximum depth of tile in opengl
Should this depth buffer visualisation appear smooth?
Shadow mapping shader
glutPostRedisplay calls display method but doesn't redraw window
GLSL loading core dumped
Vertex buffer object won't render, other primitives will

Categories

HOME
php
openshift
mc
angular-ui-grid
workflow
antd
timber
solution
freertos
mahout-recommender
texas-instruments
google-cloud-logging
android-contacts
robolectric
clr
jest
web-analytics
connection-refused
candlestick-chart
points
marquee
pyspark-sql
dotcms
winsock
gsp
express-session
nsuserdefaults
strapi
xll
stat
imgur
netapp
hypothesis-test
latexml
asihttprequest
sequence-diagram
algebra
msxml
gapi
bilinear-interpolation
livecycle
dpkg
adp
simian
ioexception
teensy
outlook.com
msgpack
chicagoboss
supercomputers
swagger-maven-plugin
artisan
fat32
thoughtworks-go
vs-unit-testing-framework
ildasm
libgcc
coding-efficiency
xmi
assetic
eclim
unrealscript
blobstorage
aero
ui-design
donut-chart
tfs-sdk
ntlmv2
email-verification
chronometer
server-name
multidrop-bus
representation
database-deadlocks
digiflow
printqueue
ccnet-config
raw-data
processors

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile