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

Get 3D coordinates of an object after rotation around arbitrary point ( car steering simulation )
Algorithm for coloring a triangle by vertex color
How does the Graphics Pipeline work?
Converting coordinates between 2 projection matrixes
Rendering to texture using FBO and shaders OpenGL
mat4 project/unproject not working
problems with gluLookAt
Portably and Correctly Getting Maximum 1D/2D/3D/Cube Texture Resolution in OpenGL
How to correctly represent 3D rotation in games
OpenGL 4: Stitched tesselation patches dont fit together
Opengl: first vertex always drawn at origin
OpenGL is averaging all colors in the texture?
how to calc the top point of a sphere in opengl?
GLSL tessellation control shader indexing gl_TessLevelOuter with gl_InvocationID
Using the same shader code in multiple processes
Occlusion queries with stencil test only

Categories

HOME
elasticsearch
ionic2
events
apple-push-notifications
opencv-python
activemq
celery
lvm
google-sheets-query
linker
openfoam
supercollider
ui-automation
erd
graphdb
chromecast
vimeo
bundler
squid
boomi
gmp
raml
cmake-gui
azure-machine-learning
altium-designer
perfino
data-collection
multi-dimensional-scaling
network-analysis
annotation-processing
basic-authentication
monitor
intune
dreamfactory
assertions
code-rally
forms-authentication
sbjson
suds
jacoco-maven-plugin
haar-classifier
sony-future-lab-n
head.js
sharpdx
maven-jaxb2-plugin
aurelia-fetch-client
pen
palindrome
test-data
stateless-session-bean
alertify
prefetch
yargs
deviare
bigdecimal
jsf-2.3
node.js-connect
urbit
gulp-uglify
currency-exchange-rates
msgpack
ambiguity
360-degrees
search-form
domino-designer-eclipse
swagger-maven-plugin
bootstrap-wysiwyg
algebraixlib
whitespace-language
shoes
android-audiomanager
mxe
debug-symbols
mobile-country-code
box2dweb
distributed-r
pageviews
code39
frontbase
san
sql-view
coalesce
sunstudio
mongo-jackson-mapper
image-formats
liveconnect
microblogging
server-variables
database-deadlocks
pyjamas
multiple-users
rawcontacts
ntruencrypt
stretchblt
jvm-bytecode

Resources

Database Users
RDBMS discuss
Database Dev&Adm
javascript
java
csharp
php
android
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App