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

Is cl-opengl glut mature?
glDrawPixels in opengl or jogl
OpenGL lighting question?
Understanding the relationship between glutDisplayFunc and glutPostRedisplay
Problems mapping cubemaps to a sphere
OpenGL Transformation Problem
.obj file conversion to OpenGL model header file - indices and f parameters?
Where can I download original OpenGL SDK (not GLUT) for WindowsXP?
gl calls end in EXC_BAC_ACCESS - bad opengl context?
Add Toxi library to Processing
OpenGL - How do you scroll a texture?
Check GPU OpenGL Limits
Can't Build wxWidgets on Cygwin with OpenGL Support
Mipmapping issue with textures rendered on to a flat quad (OpenGL)
Drawing Normals to Surfaces
Repeating Textures in OpenGL

Categories

HOME
apache-nifi
automapper
weblogic12c
dotnetnuke
adfs3.0
antd
activemq
message-queue
code-formatting
liferay-7
header
google-sheets-query
moodle-api
implicit-conversion
drag-and-drop
repair
capistrano
responsive-design
parsley.js
phpstorm-2017.1
jquery-select2-4
jquery-file-upload
cuba-platform
squirrel-sql
xbox360
supervisord
checkout
boomi
gmp
psql
parceler
jest
jitsi
uislider
amazon-sns
jackrabbit-oak
oracleforms
basex
macromedia
social-networking
amazon-iam
john-the-ripper
counting
transform
stackpanel
cordys-opentext
flowchart
classnotfoundexception
httphandler
icecast
subforms
simple-schema
watir-webdriver
nslayoutconstraint
pecl
mechanicalturk
hmmlearn
d3v4
oracle-fusion-apps
qtextedit
cocoa-bindings
bigdecimal
nclam
jsf-2.3
django-testing
dojo-build
powerpoint-2013
gnucash
teamviewer
seadragon
ui4j
deeplink
green-threads
angular-amd
wicked-gem
clarion
sablecc
subview
baseadapter
sql-processor
phonegap-facebook-plugin
adwords-apiv201402
dmake
producer
visual-studio-6
nosql-aggregation
windows-taskbar
progress-db
discovery
apache-shindig
postgres-xc
xcode4.5
system-information
wcf-callbacks
navigationcontroller
fbml
boost-foreach
canonicalization
kernel32
3des
cleartype
browser-based
fuzzy-comparison
index.dat
datagridcolumn

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App